Add Lobby #43
1 changed files with 14 additions and 9 deletions
|
@ -29,6 +29,10 @@ export abstract class Client extends EventEmitter {
|
||||||
this.metadata.name = data.newname;
|
this.metadata.name = data.newname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only mutate player list if we have one
|
||||||
|
// This is because rename messages can be received during the initial
|
||||||
|
// handshake, to signal a forced name change before joining.
|
||||||
|
if (this.players) {
|
||||||
let idx = this.players.indexOf(data.oldname);
|
let idx = this.players.indexOf(data.oldname);
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
// Weird
|
// Weird
|
||||||
|
@ -39,6 +43,7 @@ export abstract class Client extends EventEmitter {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Vue.set(this.players, idx, data.newname);
|
Vue.set(this.players, idx, data.newname);
|
||||||
|
}
|
||||||
this.emit("rename", data.oldname, data.newname);
|
this.emit("rename", data.oldname, data.newname);
|
||||||
break;
|
break;
|
||||||
// A new player joined the room (this includes us)
|
// A new player joined the room (this includes us)
|
||||||
|
|
Loading…
Reference in a new issue