Release v2.12.0
This commit is contained in:
+23
-1
@@ -32,6 +32,7 @@ function createPlayerRuntime(options) {
|
||||
const connectionsBySlug = new Map();
|
||||
const dashboardListenersBySlug = new Map();
|
||||
const announcementListenersBySlug = new Map();
|
||||
const snapshotListeners = new Set();
|
||||
const pendingCommandAcks = new Map();
|
||||
const wss = new WebSocketServer({ noServer: true });
|
||||
const staleConnectionMs = Number(options && options.staleConnectionMs) > 0
|
||||
@@ -379,6 +380,12 @@ function createPlayerRuntime(options) {
|
||||
} catch (_error) {
|
||||
}
|
||||
}
|
||||
snapshotListeners.forEach(function (listener) {
|
||||
try {
|
||||
listener({ slug: key, connections: connections });
|
||||
} catch (_error) {
|
||||
}
|
||||
});
|
||||
if (!bucket || !bucket.size) {
|
||||
return;
|
||||
}
|
||||
@@ -503,6 +510,10 @@ function createPlayerRuntime(options) {
|
||||
const playerMatch = pathname.match(/^\/ws\/screens\/([^/]+)$/);
|
||||
const announcementMatch = pathname.match(/^\/ws\/screens\/([^/]+)\/announcements$/);
|
||||
|
||||
if (pathname === '/local-control/ws') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dashboardMatch && !playerMatch && !announcementMatch) {
|
||||
socket.destroy();
|
||||
return;
|
||||
@@ -720,6 +731,16 @@ function createPlayerRuntime(options) {
|
||||
server.on('upgrade', handleUpgrade);
|
||||
}
|
||||
|
||||
function subscribeSnapshot(listener) {
|
||||
if (typeof listener !== 'function') {
|
||||
return function () {};
|
||||
}
|
||||
snapshotListeners.add(listener);
|
||||
return function () {
|
||||
snapshotListeners.delete(listener);
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
installWebsocket: installWebsocket,
|
||||
broadcastAnnouncementRefresh: broadcastAnnouncementRefresh,
|
||||
@@ -728,7 +749,8 @@ function createPlayerRuntime(options) {
|
||||
snapshotSlugs: snapshotSlugs,
|
||||
isClientNameAvailableOnScreen: isClientNameAvailableOnScreen,
|
||||
sendCommandToConnection: sendCommandToConnection,
|
||||
broadcastCommand: broadcastCommand
|
||||
broadcastCommand: broadcastCommand,
|
||||
subscribeSnapshot: subscribeSnapshot
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user