smart player afk detection added

This commit is contained in:
2023-04-03 12:38:52 +03:00
parent d9e2ae0f53
commit 063e8c25b7
2 changed files with 62 additions and 0 deletions
+11
View File
@@ -372,6 +372,7 @@ streamerServer.on('connection', function (ws, req) {
ws.on('message', (msgRaw) => {
var msg;
try {
msg = JSON.parse(msgRaw);
} catch(err) {
@@ -622,6 +623,13 @@ playerServer.on('connection', function (ws, req) {
p.ws.send(playerCountMsg);
}
}
function sendPlayersLastInputTime() {
let playerCountMsg = JSON.stringify({ type: 'lastOtherPlayerInput'});
for (let p of players.values()) {
p.ws.send(playerCountMsg);
}
}
ws.on('message', (msgRaw) =>{
@@ -659,6 +667,9 @@ playerServer.on('connection', function (ws, req) {
} else if (msg.type == "peerDataChannelsReady") {
msg.playerId = playerId;
sendMessageToController(msg, skipSFU, true);
} else if (msg.type == "playerInput") {
//msg.playerId = playerId;
sendPlayersLastInputTime();
}
else {
console.error(`player ${playerId}: unsupported message type: ${msg.type}`);