- case "identity":
- {
- // NOTE: sometimes player.id fails because player is undefined...
- // Probably because the event was meant for Hall?
- if (!this.people[data.user.sid])
- return;
- this.$set(this.people, data.user.sid,
- {id: data.user.id, name: data.user.name});
- // Sending last state only for live games: corr games are complete,
- // only if I played a move (otherwise opponent has all)
- if (!!this.game.mycolor && this.game.type == "live"
- && this.game.oppsid == data.user.sid
- && this.game.moves.length > 0 && this.vr.turn != this.game.mycolor)
- {
- // Send our "last state" informations to opponent
- const L = this.game.moves.length;
- this.st.conn.send(JSON.stringify({
- code: "lastate",
- target: data.user.sid,
- state:
- {
- lastMove: this.game.moves[L-1],
- // Since we played a move, only drawOffer=="sent" is possible
- drawSent: this.drawOffer == "sent",
- score: this.game.score,
- movesCount: L,
- clocks: this.game.clocks,
+ case "identity": {
+ const user = data.data;
+ if (user.name) {
+ // If I multi-connect, kill current connexion if no mark (I'm older)
+ if (
+ this.newConnect[user.sid] &&
+ user.id > 0 &&
+ user.id == this.st.user.id &&
+ user.sid != this.st.user.sid
+ ) {
+ if (!this.killed[this.st.user.sid]) {
+ this.send("killme", { sid: this.st.user.sid });
+ this.killed[this.st.user.sid] = true;