forked from socketio/socket.io
-
Notifications
You must be signed in to change notification settings - Fork 1
Exposed events
DanielBaulig edited this page Mar 20, 2012
·
13 revisions
Struggling to find this documentation, so adding here what I know...
The following are rumored to exist, but need documentation. If you know, please add to either the client or server section below.
-
'reconnect_failed'event. -
'reconnect'event.
On the server, assuming var io = require('socket.io'),
-
io.sockets.on('connection', function(socket) {})- initial connection from a client.socketargument should be used in further communication with the client. -
socket.on('message', function(message, callback) {})- "message" is emitted when a message sent with socket.send is received. message is the message sent, and callback is an optional acknowledgement function. -
socket.on('anything', function(data) {})- "anything" can be any event except for the reserved ones. -
socket.on('disconnect', function() {})- fired when the socket disconnects? Not sure when exactly, i.e. will it only fire if client initiates disconnect or also if server initiates disconnect. Does it fire on unexpected network failure, or a mobile device losing connection?
The client doc (including event list) is available here: https://github.com/LearnBoost/socket.io-client
On the client, assuming var socket = io.connect(host, options),
-
socket.on('connect', function () {})- "connect" is emitted when the socket connected successfully -
socket.on('message', function (message, callback) {})- "message" is emitted when a message sent witch socket.send is received. message is the sent message, and callback is an optional acknowledgement function. -
socket.on('anything', function(data, callback) {})- "anything" can be any event except for the reserved ones. data is data, and callback can be used to send a reply.