- if (!!this.$route.params["id"])
- {
- this.gameRef.id = this.$route.params["id"];
- this.gameRef.rid = this.$route.query["rid"];
- this.loadGame();
- }
- // TODO: onopen, ask lastState informations + update observers and players status
+ // Always add myself to players' list
+ const my = this.st.user;
+ this.people.push({sid:my.sid, id:my.id, name:my.name});
+ this.gameRef.id = this.$route.params["id"];
+ this.gameRef.rid = this.$route.query["rid"]; //may be undefined
+ if (!this.gameRef.rid)
+ this.loadGame(); //local or corr: can load from now
+ // TODO: mode analyse (/analyze/Atomic/rn
+ // ... fen = query[], vname=params[] ...
+ // 0.1] Ask server for room composition:
+ const initialize = () => {
+ // Poll clients + load game if stored remotely
+ this.st.conn.send(JSON.stringify({code:"pollclients"}));
+ if (!!this.gameRef.rid)
+ this.loadGame();
+ };
+ if (!!this.st.conn && this.st.conn.readyState == 1) //1 == OPEN state
+ initialize();
+ else //socket not ready yet (initial loading)
+ this.st.conn.onopen = initialize;
+ this.st.conn.onmessage = this.socketMessageListener;