fix switch case statement

This commit is contained in:
Hri7566 2022-07-09 00:28:52 -04:00
parent 6adfa121d6
commit 9aeba87af1
1 changed files with 10 additions and 12 deletions

View File

@ -13,28 +13,26 @@ module.exports = class Notification {
} }
send(_id, room) { send(_id, room) {
let obj = {}; let msg = {};
Object.assign(obj, this); Object.assign(msg, this);
obj.m = "notification"; msg.m = "notification";
switch (_id) { switch (_id) {
case "all": { case "all":
for (let con of Array.from(room.server.connections.values())) { for (let con of Array.from(room.server.connections.values())) {
con.sendArray([obj]); con.sendArray([msg]);
} }
break; break;
} case "room":
case "room": {
for (let con of room.connections) { for (let con of room.connections) {
con.sendArray([obj]); con.sendArray([msg]);
} }
break; break;
} default:
default: {
Array.from(room.server.connections.values()).filter((usr) => typeof(usr.user) !== 'undefined' ? usr.user._id == _id : null).forEach((p) => { Array.from(room.server.connections.values()).filter((usr) => typeof(usr.user) !== 'undefined' ? usr.user._id == _id : null).forEach((p) => {
p.sendArray([obj]); p.sendArray([msg]);
}); });
} break;
} }
} }
} }