Compare commits

..

2 Commits

2 changed files with 20 additions and 15 deletions

View File

@ -29,6 +29,7 @@ module.exports = {
"semi": [
"error",
"always"
]
],
"no-mixed-spaces-and-tabs": "off"
}
};

View File

@ -31,8 +31,9 @@ app.get("/", (req, res) => {
io.on("connection", (socket) => {
// Handle disconnection
socket.on("disconnect", () => {
if (players[socket.id]) {
const room = players[socket.id].room;
delete players[socket.id];
var playerUpdate = {};
if (io.sockets.adapter.rooms[room]) {
@ -48,6 +49,9 @@ io.on("connection", (socket) => {
if (io.sockets.adapter.rooms[room] == undefined) {
console.log(traffic.int + colours.room(`Room ${room} has been deleted due to a lack of players`));
}
}
delete players[socket.id];
});
// Request identification