},
created: function() {
const url = socketUrl;
- this.conn = new WebSocket(url + "/?sid=" + this.myid + "&page=" + variant);
+ this.conn = new WebSocket(url + "/?sid=" + this.myid + "&page=" + variant._id);
// const socketOpenListener = () => {
// };
switch (data.code)
{
case "newmove": //..he played!
- this.play(data.move, (variant!="Dark" ? "animate" : null));
+ this.play(data.move, (variant.name!="Dark" ? "animate" : null));
break;
case "pong": //received if we sent a ping (game still alive on our side)
if (this.gameId != data.gameId)
};
const socketCloseListener = () => {
- this.conn = new WebSocket(url + "/?sid=" + this.myid + "&page=" + variant);
+ this.conn = new WebSocket(url + "/?sid=" + this.myid + "&page=" + variant._id);
//this.conn.addEventListener('open', socketOpenListener);
this.conn.addEventListener('message', socketMessageListener);
this.conn.addEventListener('close', socketCloseListener);
// Computer moves web worker logic: (TODO: also for observers in HH games)
- this.compWorker.postMessage(["scripts",variant]);
+ this.compWorker.postMessage(["scripts",variant.name]);
const self = this;
this.compWorker.onmessage = function(e) {
let compMove = e.data;
// before they appear on page:
const delay = Math.max(500-(Date.now()-self.timeStart), 0);
setTimeout(() => {
- const animate = (variant!="Dark" ? "animate" : null);
+ const animate = (variant.name!="Dark" ? "animate" : null);
if (self.mode == "computer") //warning: mode could have changed!
self.play(compMove[0], animate);
if (compMove.length == 2)