2013-09-29 37 views
0

試圖訪問在helpQue的插座,其被構造爲具有helpQue.push(socket)當我正在此錯誤消息socket.io對象沒有方法「發出」

TypeError: Object [object Object] has no method 'emit'

helpQuecxsQue都是插座陣列。

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); 

回答

0

我切換代碼

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); 

它的工作。我猜想splice有些事情正在發生,但無法弄清楚什麼。如果有人知道,請讓我知道。