2011-11-06 148 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

謝謝你,我覺得更容易:) –

相關問題