btford / angular-socket-io

Socket.IO component for AngularJS
1.51k stars 233 forks source link

how can i confirm the angular app is successful connected ? #146

Open ghost opened 8 years ago

ghost commented 8 years ago

how to confirm the angular app is successful connected to some ip address ? please give some example code. thanks!

AzRu commented 8 years ago

if you log the socket object, it has 'disconnected' and 'connected' fields

so how about something like

var socket = io.connect(YOUR_URL);
if (socket.connected) console.log('connected!');