[英]socket.io object has no method 'emit'
I am getting this error message 我收到此错误消息
TypeError: Object [object Object] has no method 'emit' TypeError:对象[object Object]没有方法'emit'
when trying to access a socket in helpQue
, which is constructed with helpQue.push(socket)
. 尝试访问helpQue
的套接字时,该helpQue.push(socket)
由helpQue.push(socket)
构造。
Both helpQue
and cxsQue
are arrays of sockets. helpQue
和cxsQue
都是套接字数组。
setInterval(function() {
if(helpQue.length > 0 && cxsQue.length > 0) {
var id = makeid(),
helpee = helpQue.splice(0, 1);
helpee.emit('server-output', 'Test'); //ERROR here
}
}, 1000);
I switched the code to 我将代码切换到
setInterval(function() {
if(helpQue.length > 0 && cxsQue.length > 0) {
var id = makeid(),
helpee = helpQue[0];
helpQue.splice(0, 1);
helpee.emit('server-output', 'Test');
}
}, 1000);
it worked. 有效。 I assume there was something going on with splice
, but can't figure out what. 我认为splice
发生了什么事,但无法弄清楚是什么。 If anyone knows please let me know. 如果有人知道,请告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.