Commit dadf43ce authored by 18신대성's avatar 18신대성 Committed by 16이지혜

findPlayer 함수 추가

잡다한거 고침
parent 47103550
......@@ -28,6 +28,19 @@ GameServer.getPlayerNumber = function()
if (!this.waitingRoom.includes(num)) return num;
} while (true)
}
GameServer.findPlayer = function(playerId)
{
var idx = this.waitingRoom.findIndex(function(element)
{
return element.id === socket;
});
if (idx != -1) return this.waitingRoom[idx];
else
{
console.log('[ERR] wrong playerId to find');
return null;
}
}
// 클라이언트 요청에 대한 콜백 정의
io.on('connection', function(socket)
......@@ -51,7 +64,7 @@ io.on('connection', function(socket)
{
var idxToDel = GameServer.waitingRoom.findIndex( function(element)
{
return element.socketId == socket;
return element.socketId === socket;
}
);
if (idxToDel != -1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment