Skip to content

Commit 23401ad

Browse files
committed
Fix nullreferenceerror or whatever it is called in javascript
1 parent c08d1c0 commit 23401ad

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

functions.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,14 @@ function start(io, rooms, numusers, devv) {
118118
let extraData;
119119

120120
socket.on("disconnect", () => {
121+
if (room === null) return;
121122
if (extraData.userid === room.owner.userid) {
122123
room.terminate();
123124
global.rooms.splice(global.rooms.indexOf(room));
124125
} else {
125126
room.userLeft(extraData.userid);
126127
}
128+
room = null;
127129
})
128130
socket.on('open-room', function(data, cb) {
129131
if (getRoom(data.extra.domain, data.extra.game_id, data.extra.sessionid) !== null) {
@@ -154,6 +156,7 @@ function start(io, rooms, numusers, devv) {
154156

155157
})
156158
socket.on("data-message", (data) => {
159+
if (room === null) return;
157160
socket.to(room.id).emit("data-message", data);
158161
})
159162
});

0 commit comments

Comments
 (0)