better logging
This commit is contained in:
parent
d9daef380e
commit
13cd3db387
3 changed files with 22 additions and 8 deletions
11
index.js
11
index.js
|
@ -25,7 +25,7 @@ app.ws('/', function (ws, req) {
|
|||
ws.ent = player;
|
||||
|
||||
// This will only work under NGINX.
|
||||
console.log(`A player ${player.you} joined under IP ${req.headers["x-real-ip"]}`)
|
||||
console.log(`Player ${player.you} joined under IP ${req.headers["x-real-ip"]}`)
|
||||
|
||||
ws.on('message', function message(msg) {
|
||||
let data = {};
|
||||
|
@ -49,12 +49,17 @@ app.ws('/', function (ws, req) {
|
|||
let you2 = newEnt.you;
|
||||
|
||||
if (you != you2) {
|
||||
console.log(`A player ${you} now identifies as ${you2}`);
|
||||
console.log(`Player ${you} now identifies as ${you2}`);
|
||||
}
|
||||
|
||||
if (newEnt.ref) {
|
||||
console.log(`Player ${you2} discovered this game from ${newEnt.ref}`);
|
||||
newEnt.ref = undefined;
|
||||
}
|
||||
})
|
||||
|
||||
ws.on('close', function () {
|
||||
console.log(`A player ${game.entities[playerI].you} left`);
|
||||
console.log(`Player ${game.entities[playerI].you} left`);
|
||||
ws.active = false;
|
||||
player.health = -1;
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue