Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Small signalling server fixes. #443

Merged
merged 2 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions SignallingWebServer/cirrus.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ function registerStreamer(id, streamer) {
}

function onStreamerDisconnected(streamer) {
if (!!streamer.idTimer) {
clearTimeout(streamer.idTimer);
}

if (!streamer.id || !streamers.has(streamer.id)) {
return;
}
Expand Down Expand Up @@ -665,7 +669,10 @@ streamerServer.on('connection', function (ws, req) {
}
});

ws.send(JSON.stringify(clientConfig));
const configStr = JSON.stringify(clientConfig);
logOutgoing(streamer.id, configStr)
ws.send(configStr);

requestStreamerId(streamer);
});

Expand Down Expand Up @@ -960,7 +967,11 @@ playerServer.on('connection', function (ws, req) {

sendPlayerConnectedToFrontend();
sendPlayerConnectedToMatchmaker();
player.ws.send(JSON.stringify(clientConfig));

const configStr = JSON.stringify(clientConfig);
logOutgoing(player.id, configStr)
player.ws.send(configStr);

sendPlayersCount();
});

Expand Down
36 changes: 24 additions & 12 deletions SignallingWebServer/modules/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@ var loggers=[];
var logFunctions=[];
var logColorFunctions=[];

console.log = function(msg, ...args) {
logFunctions.forEach((logFunction) => {
logFunction(msg, ...args);
});
}

console.logColor = function(color, msg, ...args) {
logColorFunctions.forEach((logColorFunction) => {
logColorFunction(color, msg, ...args);
});
}

const AllAttributesOff = '\x1b[0m';
const BoldOn = '\x1b[1m';
const Black = '\x1b[30m';
Expand All @@ -31,6 +19,30 @@ const Cyan = '\x1b[36m';
const White = '\x1b[37m';
const Orange = '\x1b[38;5;215m';

console.log = function(msg, ...args) {
logFunctions.forEach((logFunction) => {
logFunction(msg, ...args);
});
}

console.warn = function(msg, ...args) {
logColorFunctions.forEach((logColorFunction) => {
logColorFunction(Yellow, msg, ...args);
});
}

console.error = function(msg, ...args) {
logColorFunctions.forEach((logColorFunction) => {
logColorFunction(Red, msg, ...args);
});
}

console.logColor = function(color, msg, ...args) {
logColorFunctions.forEach((logColorFunction) => {
logColorFunction(color, msg, ...args);
});
}

/**
* Pad the start of the given number with zeros so it takes up the number of digits.
* e.g. zeroPad(5, 3) = '005' and zeroPad(23, 2) = '23'.
Expand Down