2011-11-06 147 views

回答

3

这里是你如何能做到这一点在客户端的例子:

var chat = io.connect('http://localhost:4000/chat'); 
chat.on('connect', function() { 
    console.log('Connected to the chat!'); 
}); 
chat.on('disconnect', function() { 
    console.log('Disconnected from the chat!'); 
}); 

正如你所看到的,你保持连接变量和使用connection_variable.on(“脱节”,callback_function_here)

+0

谢谢你,我觉得更容易:) –

相关问题