Q.Socket Class
Q.Socket class can be used to manage sockets (implemented with socket.io)
Instantiate sockets with Q.Socket.connect
Constructor
Item Index
Methods
- connect static
- destroyAll static
- disconnect
- disconnectAll static
- get static
- getAll static
- reconnectAll static
Methods
connect
-
ns
-
url
-
[callback]
-
[callback2]
Connects a socket, and stores it in the list of connected sockets
destroyAll
()
static
Completely remove all sockets, and de-register events
disconnect
()
Disconnects a socket corresponding to a Q.Socket
disconnectAll
-
ns
Disconnects all sockets that have been connected
Parameters:
-
ns
StringAny namespace for the sockets to disconnect
get
-
ns
-
url
Returns a socket, if it was already connected, or returns undefined
Parameters:
Returns:
getAll
()
Object
static
Returns all the sockets, whether connected or not. Note that a socket really disconnects when all the namespaces disconnect.
Returns:
indexed by socket.io namespace, url
reconnectAll
()
static
Reconnect all sockets that have been connected
Events
onConnect
Be notified when a socket connects and obtain a Q.Event based on the parameters
onEvent
Subscribe to a socket event and obtain a Q.Event based on the parameters
onEvent
Returns Q.Event which occurs on a message post event coming from socket.io Generic callbacks can be assigend by setting messageType to ""
Event Payload:
-
name
Stringname of the event to listen for