- case "room":
- // TODO: receive room composition (sids at least, id + names if registered)
- // TODO: also receive "askchallenges", "askgames"
+ case "clients":
+ data.sockIds.forEach(sid => {
+ this.players.push({sid:sid, id:0, name:""});
+ this.st.conn.send(JSON.stringify({code:"askidentity", target:sid}));
+ });
+ break;
+ // TODO: also receive "askchallenges", "askgames"
+ case "identify":
+ // Request for identification
+ this.st.conn.send(JSON.stringify({code:"identity", user:this.st.user, target:data.from}));
+ break;
+ case "identity":
+ if (data.user.id > 0)
+ {
+ const pIdx = this.players.findIndex(p => p.sid == data.user.sid);
+ this.players[pIdx].id = data.user.id;
+ this.players[pIdx].name = data.user.name;
+ }
+ break;