+ const socketCloseListener = () => {
+ console.log("Lost connection -- reconnect"); //TODO: be more subtle than that, reconnect only when needed!
+ this.conn = new WebSocket(url + "/?sid=" + this.myid + "&page=" + variant);
+ this.conn.addEventListener('open', socketOpenListener);
+ this.conn.addEventListener('message', socketMessageListener);
+ this.conn.addEventListener('close', socketCloseListener);
+ };
+ this.conn.onopen = socketOpenListener;
+ this.conn.onmessage = socketMessageListener;
+ this.conn.onclose = socketCloseListener;