From cd71430087ac3574f347b9b053996869ead39e0c Mon Sep 17 00:00:00 2001 From: BopItFreak Date: Wed, 12 Jun 2019 13:28:15 -0400 Subject: [PATCH] trying to debug some bugs --- src/Message.js | 4 ++++ src/Room.js | 2 -- src/User.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Message.js b/src/Message.js index a56a1fd..bee6aa3 100644 --- a/src/Message.js +++ b/src/Message.js @@ -78,6 +78,7 @@ module.exports = (cl) => { cl.channel.playNote(cl, msg); }) cl.on('+ls', msg => { + if (!(cl.channel && cl.participantId)) return; cl.server.roomlisteners.set(cl.connectionid, cl); let rooms = []; for (let room of Array.from(cl.server.rooms.values())) { @@ -94,9 +95,11 @@ module.exports = (cl) => { }]) }) cl.on('-ls', msg => { + if (!(cl.channel && cl.participantId)) return; cl.server.roomlisteners.delete(cl.connectionid); }) cl.on("userset", msg => { + if (!(cl.channel && cl.participantId)) return; if (!msg.hasOwnProperty("set") || !msg.set) msg.set = {}; if (msg.set.hasOwnProperty('name') && typeof msg.set.name == "string") { if (msg.set.name.length > 40) return; @@ -107,6 +110,7 @@ module.exports = (cl) => { if (!dbentry) return; dbentry.name = msg.set.name; user.updatedb(); + console.log("Updateing user ", usr.name, msg.set.name); cl.server.rooms.forEach((room) => { room.updateParticipant(cl.participantId, msg.set.name); }) diff --git a/src/Room.js b/src/Room.js index ae47b5b..cfce3d3 100644 --- a/src/Room.js +++ b/src/Room.js @@ -50,7 +50,6 @@ class Room extends EventEmitter { } this.ppl.set(participantId, cl); this.connections.push(cl); - this.sendArray([{ color: this.ppl.get(cl.participantId).user.color, id: this.ppl.get(cl.participantId).participantId, @@ -64,7 +63,6 @@ class Room extends EventEmitter { m: "c", c: this.chatmsgs.slice(-1 * 32) }]) - console.log("trying send chat", this.chatmsgs.slice(-1 * 32)) this.updateCh(cl); } else { cl.user.id = otheruser.participantId; diff --git a/src/User.js b/src/User.js index 248d6c8..8aebc0a 100644 --- a/src/User.js +++ b/src/User.js @@ -18,7 +18,7 @@ class User { "_id": _id, "ip": this.cl.ip }); - console.log("Set database", user.name, user._id) + console.log("Set database", _id) this.updatedb(); } let user = this.userdb.get(_id);