我正在制作像 Crazy Eights 这样的纸牌游戏。而且我已经发布了原型。
接下来,我想实现限时(每回合 5 秒)如果回合玩家不玩,我想让服务器跳过它的玩家。我编写代码并在浏览器上运行,但它不起作用。
function Table(tableID, name){
this.id = tableID;
this.name = name;
this.players = [];
this.deck = [];
this.aCardOnTable = -1;
this.turn = 0;
this.reverse = false;
this.clearid = 0;
this.count = 0;
};
Table.prototype.nextPlayer = function(){
if(this.reverse === false) {
if(this.turn >= this.players.length - 1) {
this.turn = 0;
} else {
this.turn += 1;
}
}
if(this.reverse === true) {
if(this.turn <= 0) {
this.turn = this.players.length - 1;
} else {
this.turn -= 1;
}
}
clearInterval(this.clearid);
var that = this;
var countup = function(){
console.log(that.count++);
}
that.clearid = setInterval(function(){
countup();
if(that.count > 5){
clearInterval(that.clearid);
that.nextPlayer();
//update_playerlist(table);
}
}, 1000);
};
错误信息
Missing error handler on `socket`.
RangeError: Maximum call stack size exceeded
at _hasBinary (/Users/ryu/Desktop/poker/node_modules/socket.io/node_modules/has-binary/index.js:48:16)
问题:如何解决此错误?