forked from Hri7566/mpp-server-dev2
Merge pull request #13 from Charsy89/master
Name only updates in one room
This commit is contained in:
commit
afb0e210cb
|
@ -150,7 +150,7 @@ module.exports = (cl) => {
|
||||||
dbentry.name = msg.set.name;
|
dbentry.name = msg.set.name;
|
||||||
user.updatedb();
|
user.updatedb();
|
||||||
cl.server.rooms.forEach((room) => {
|
cl.server.rooms.forEach((room) => {
|
||||||
room.updateParticipant(cl.participantId, {
|
room.updateParticipant(cl.user._id, {
|
||||||
name: msg.set.name
|
name: msg.set.name
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -194,7 +194,7 @@ module.exports = (cl) => {
|
||||||
dbentry.color = msg.color;
|
dbentry.color = msg.color;
|
||||||
user.updatedb();
|
user.updatedb();
|
||||||
cl.server.rooms.forEach((room) => {
|
cl.server.rooms.forEach((room) => {
|
||||||
room.updateParticipant(usr.participantId, {
|
room.updateParticipant(usr.user._id, {
|
||||||
color: msg.color
|
color: msg.color
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
13
src/Room.js
13
src/Room.js
|
@ -105,11 +105,14 @@ class Room extends EventEmitter {
|
||||||
this.server.updateRoom(this.fetchData());
|
this.server.updateRoom(this.fetchData());
|
||||||
}
|
}
|
||||||
updateParticipant(pid, options) {
|
updateParticipant(pid, options) {
|
||||||
let p = this.ppl.get(pid);
|
let p = null;
|
||||||
if (!p) return;
|
Array.from(this.ppl).map(rpg => {
|
||||||
options.name ? this.ppl.get(pid).user.name = options.name : {};
|
if(e[1].user._id == pid) p = e[1];
|
||||||
options._id ? this.ppl.get(pid).user._id = options._id : {};
|
});
|
||||||
options.color ? this.ppl.get(pid).user.color = options.color : {};
|
if (p == null) return;
|
||||||
|
options.name ? p.user.name = options.name : {};
|
||||||
|
options._id ? p.user._id = options._id : {};
|
||||||
|
options.color ? p.user.color = options.color : {};
|
||||||
this.connections.filter((ofo) => ofo.participantId == p.participantId).forEach((usr) => {
|
this.connections.filter((ofo) => ofo.participantId == p.participantId).forEach((usr) => {
|
||||||
options.name ? usr.user.name = options.name : {};
|
options.name ? usr.user.name = options.name : {};
|
||||||
options._id ? usr.user._id = options._id : {};
|
options._id ? usr.user._id = options._id : {};
|
||||||
|
|
Loading…
Reference in New Issue