Initial commit
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
const Game = require("../Game/Game");
|
||||
const { players } = Game;
|
||||
|
||||
const extractBehaviourFeatures = require("../Utility/extractBehaviourFeatures");
|
||||
|
||||
// const NORMAL_CLOSE_CODES = [0, 1, 2];
|
||||
|
||||
module.exports = function (ws, code, message) {
|
||||
if (code === 1337) return;
|
||||
|
||||
const player = players[ws.accountID];
|
||||
if (!player) {
|
||||
ws.isInterrupted = true;
|
||||
delete socket.sockets[ws.id];
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
const playerActions = global.actions[player.id];
|
||||
const features = extractBehaviourFeatures(playerActions);
|
||||
|
||||
delete global.actions[player.id];
|
||||
|
||||
if (features) {
|
||||
features.playerID = player.id;
|
||||
features.timestampStart = new Date(ws.connectedAt);
|
||||
|
||||
global.StatisticsWorker.postMessage({
|
||||
id: 2,
|
||||
data: features
|
||||
});
|
||||
};
|
||||
|
||||
player.inDistance = {};
|
||||
player.isAvailable = false;
|
||||
player.hasUnexpectedlyLeft = true;
|
||||
|
||||
const individualPackets = player.map.networkPacketsInvidiual[player.id];
|
||||
if (individualPackets) individualPackets.length = 0;
|
||||
console.info("close event", performance.now());
|
||||
delete socket.sockets[ws.id];
|
||||
};
|
||||
Reference in New Issue
Block a user