Removed redundant websockets.
This commit is contained in:
+5
-31
@@ -15,7 +15,7 @@ The `PULSE_SIGNAGE_SHARED_SECRET` setting does not change the websocket message
|
||||
### `GET /ws/screens/{slug}`
|
||||
Player control channel.
|
||||
|
||||
This is the bidirectional socket used by the player page. The player sends status messages to the server, and the server sends commands back to the player.
|
||||
This is the bidirectional socket used by the player page. The player sends state messages to the server, and the server sends commands back to the player.
|
||||
|
||||
Access: the player page appends a valid `auth` query parameter signed with the shared secret when one is configured. The browser page refreshes this token automatically while it is active.
|
||||
|
||||
@@ -28,34 +28,10 @@ Access: internal-only. The web backend subscribes with signed request headers; b
|
||||
|
||||
## Player Control Channel
|
||||
|
||||
### Messages from player to server
|
||||
|
||||
The player sends two message types:
|
||||
|
||||
- `hello`
|
||||
- `state`
|
||||
|
||||
#### `hello`
|
||||
|
||||
Example payload:
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "hello",
|
||||
"clientId": "client-id",
|
||||
"clientName": "friendly label",
|
||||
"deviceId": "device-id",
|
||||
"userAgent": "browser ua",
|
||||
"page": "http://.../screen/demo",
|
||||
"viewport": { "width": 1920, "height": 1080 },
|
||||
"paused": false,
|
||||
"blackout": false,
|
||||
"currentSlide": null
|
||||
}
|
||||
```
|
||||
|
||||
#### `state`
|
||||
|
||||
The player sends `state` when the socket opens and whenever playback or screen state changes.
|
||||
|
||||
Example payload:
|
||||
|
||||
```json
|
||||
@@ -101,8 +77,6 @@ Supported commands:
|
||||
- `blackout`
|
||||
- `previous`
|
||||
- `next`
|
||||
- `left`
|
||||
- `right`
|
||||
- `setclientname`
|
||||
|
||||
#### `refresh`
|
||||
@@ -132,10 +106,10 @@ Use `false` to restore and `true` to blackout.
|
||||
#### `redirect`
|
||||
Requests the player page to navigate to a new location. The destination is supplied as `url` by the caller that forwarded the command.
|
||||
|
||||
#### `previous` / `left`
|
||||
#### `previous`
|
||||
Moves to the previous slide.
|
||||
|
||||
#### `next` / `right`
|
||||
#### `next`
|
||||
Moves to the next slide.
|
||||
|
||||
#### `setclientname`
|
||||
|
||||
@@ -71,26 +71,6 @@
|
||||
app.innerHTML = '<div class="empty">' + escapeHtml(message) + '</div>';
|
||||
}
|
||||
|
||||
// Announce the player to the command websocket.
|
||||
function sendCommandHello(socket) {
|
||||
if (!socket || socket.readyState !== WebSocket.OPEN) {
|
||||
return;
|
||||
}
|
||||
var clientName = getOnboardingClientName();
|
||||
socket.send(JSON.stringify({
|
||||
type: 'hello',
|
||||
clientId: getCommandClientId(),
|
||||
clientName: clientName || null,
|
||||
deviceId: getOnboardingDeviceId() || null,
|
||||
userAgent: window.navigator.userAgent || '',
|
||||
page: window.location.href,
|
||||
viewport: getCurrentViewport(),
|
||||
paused: isPaused,
|
||||
blackout: isBlackout,
|
||||
currentSlide: null
|
||||
}));
|
||||
}
|
||||
|
||||
window.addEventListener('error', function (event) {
|
||||
logDebug('Player script error.', String(event.message || event.error || 'unknown error'), 'error');
|
||||
});
|
||||
|
||||
@@ -381,11 +381,9 @@ function handleCommandMessage(rawMessage) {
|
||||
}
|
||||
return;
|
||||
case 'previous':
|
||||
case 'left':
|
||||
navigateSlides(-1);
|
||||
return;
|
||||
case 'next':
|
||||
case 'right':
|
||||
navigateSlides(1);
|
||||
return;
|
||||
case 'reload':
|
||||
@@ -424,11 +422,11 @@ function connectCommandSocket() {
|
||||
socket.onopen = function () {
|
||||
if (typeof syncOnboardingClientNameFromServer === 'function') {
|
||||
syncOnboardingClientNameFromServer(socket).then(function () {
|
||||
sendCommandHello(socket);
|
||||
sendCommandState(lastRenderedSlide);
|
||||
});
|
||||
return;
|
||||
}
|
||||
sendCommandHello(socket);
|
||||
sendCommandState(lastRenderedSlide);
|
||||
};
|
||||
|
||||
socket.onmessage = function (event) {
|
||||
|
||||
@@ -309,7 +309,7 @@ function registerPlayerRoutes(app, options) {
|
||||
if (!command) {
|
||||
return res.status(400).json({ error: 'Command is required' });
|
||||
}
|
||||
if (['refresh', 'reload', 'redirect', 'pause', 'blackout', 'previous', 'next', 'left', 'right', 'setclientname'].indexOf(command) === -1) {
|
||||
if (['refresh', 'reload', 'redirect', 'pause', 'blackout', 'previous', 'next', 'setclientname'].indexOf(command) === -1) {
|
||||
return res.status(400).json({ error: 'Unsupported command' });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user