Add onboarding weather and template gradients
This commit is contained in:
+22
-1
@@ -32,6 +32,21 @@ function createPlayerRuntime(options) {
|
||||
const announcementListenersBySlug = new Map();
|
||||
const wss = new WebSocketServer({ noServer: true });
|
||||
|
||||
function hasActiveClientId(clientId, currentConnection) {
|
||||
const normalizedClientId = String(clientId || '').trim();
|
||||
if (!normalizedClientId) {
|
||||
return false;
|
||||
}
|
||||
for (const connections of connectionsBySlug.values()) {
|
||||
for (const connection of connections.values()) {
|
||||
if (connection !== currentConnection && String(connection.clientId || '').trim() === normalizedClientId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function normalizeClientIp(value) {
|
||||
const ip = String(value || '').trim();
|
||||
if (!ip) {
|
||||
@@ -534,7 +549,13 @@ function createPlayerRuntime(options) {
|
||||
return;
|
||||
}
|
||||
|
||||
connection.clientId = payload.clientId ? String(payload.clientId).trim() : connection.clientId;
|
||||
const nextClientId = payload.clientId ? String(payload.clientId).trim() : connection.clientId;
|
||||
if (nextClientId && hasActiveClientId(nextClientId, connection)) {
|
||||
socket.send(JSON.stringify({ type: 'client-id-conflict' }));
|
||||
socket.close(4009, 'Client ID is already in use.');
|
||||
return;
|
||||
}
|
||||
connection.clientId = nextClientId;
|
||||
connection.clientName = payload.clientName ? String(payload.clientName).trim() : connection.clientName;
|
||||
connection.deviceId = payload.deviceId ? normalizeDeviceId(payload.deviceId) || connection.deviceId : connection.deviceId;
|
||||
if (!connection.clientName && connection.clientId) {
|
||||
|
||||
Reference in New Issue
Block a user