- case "duplicate":
- alert(this.st.tr["Warning: multi-tabs not supported"]);
- break;
- // 0.2] Receive clients list (just socket IDs)
- case "pollclients":
- data.sockIds.forEach(sid => {
- this.$set(this.people, sid, {id:0, name:""});
- // Ask identity and challenges
- this.st.conn.send(JSON.stringify({code:"askidentity", target:sid}));
- this.st.conn.send(JSON.stringify({code:"askchallenge", target:sid}));
+ case "pollclientsandgamers":
+ {
+ // Since people can be both in Hall and Game,
+ // need to track "askIdentity" requests:
+ let identityAsked = {};
+ data.sockIds.forEach(s => {
+ if (s.sid != this.st.user.sid && !identityAsked[s.sid])
+ {
+ identityAsked[s.sid] = true;
+ this.send("askidentity", {target:s.sid, page:s.page || "/"});
+ }
+ if (!this.people[s.sid])
+ this.$set(this.people, s.sid, {id:0, name:"", pages:[s.page || "/"]});
+ else if (!!s.page && this.people[s.sid].pages.indexOf(s.page) < 0)
+ this.people[s.sid].pages.push(s.page);
+ if (!s.page) //peer is in Hall
+ this.send("askchallenge", {target:s.sid});
+ else //peer is in Game
+ this.send("askgame", {target:s.sid, page:s.page});