diff --git a/server.js b/server.js index 47ee38f..cfdf7a5 100644 --- a/server.js +++ b/server.js @@ -91,41 +91,34 @@ clientNSP.on('connection', socket => { // monitorNSP.emit('updateGameState', 1); + let pl = getPlayerFromId(socket.request.headers.referer.split('/').slice(-1)[0]); socket.on('moveStart_left', () => { - let pl = getPlayerFromId(socket.request.headers.referer.split('/').slice(-1)[0]); console.log('moveStart_left: ' + pl.type); monitorNSP.emit('moveStart_left', pl.type); }); socket.on('moveStart_right', () => { - let pl = getPlayerFromId(socket.request.headers.referer.split('/').slice(-1)[0]); console.log('moveStart_right: ' + pl.type); monitorNSP.emit('moveStart_right', pl.type); }); socket.on('moveStart_jump', () => { - let pl = getPlayerFromId(socket.request.headers.referer.split('/').slice(-1)[0]); console.log('moveStart_jump: ' + pl.type); monitorNSP.emit('moveStart_jump', pl.type) }); socket.on('moveStart_crouch', () => { - let pl = getPlayerFromId(socket.request.headers.referer.split('/').slice(-1)[0]); console.log('moveStart_crouch: ' + pl.type); }); socket.on('moveEnd_left', () => { - let pl = getPlayerFromId(socket.request.headers.referer.split('/').slice(-1)[0]); console.log('moveEnd_left: ' + pl.type); monitorNSP.emit('moveEnd_left', pl.type); }); socket.on('moveEnd_right', () => { - let pl = getPlayerFromId(socket.request.headers.referer.split('/').slice(-1)[0]); console.log('moveEnd_right: ' + pl.type); monitorNSP.emit('moveEnd_right', pl.type); }); socket.on('moveEnd_jump', () => { - let pl = getPlayerFromId(socket.request.headers.referer.split('/').slice(-1)[0]); console.log('moveEnd_jump: ' + pl.type); }); socket.on('moveEnd_crouch', () => { - let pl = getPlayerFromId(socket.request.headers.referer.split('/').slice(-1)[0]); console.log('moveEnd_crouch: ' + pl.type); });