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

Commit

Permalink
Merge pull request #443 from mcottontensor/stale_legacy_timer
Browse files Browse the repository at this point in the history
Small signalling server fixes.
  • Loading branch information
mcottontensor committed Dec 10, 2023
2 parents c05f3b1 + c6ad00f commit 4ebc522
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
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

0 comments on commit 4ebc522

Please sign in to comment.