+ // 0.2] Receive clients list (just socket IDs)
+ case "pollclients":
+ {
+ data.sockIds.forEach(sid => {
+ this.people.push({sid:sid, id:0, name:""});
+ // Ask only identity
+ this.st.conn.send(JSON.stringify({code:"askidentity", target:sid}));
+ });
+ break;
+ }
+ case "askidentity":
+ {
+ // Request for identification: reply if I'm not anonymous
+ if (this.st.user.id > 0)
+ {
+ this.st.conn.send(JSON.stringify(
+ // people[0] instead of st.user to avoid sending email
+ {code:"identity", user:this.people[0], target:data.from}));
+ }
+ break;
+ }
+ case "identity":
+ {
+ const pIdx = this.people.findIndex(p => p.sid == data.user.sid);
+ this.people[pIdx].id = data.user.id;
+ this.people[pIdx].name = data.user.name;
+ break;
+ }