From a6ec9bfa6e0f7858666e402282a85e583acc1f2f Mon Sep 17 00:00:00 2001 From: Simon Giesel Date: Wed, 25 Apr 2018 23:49:49 +0200 Subject: [PATCH] Refactor --- server.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) 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); });