PubSub Class
PubSub is a publish-subscribe messaging system based on socket.io It allows simple socket communication between different clients An runing instance of MobilizingServer is required to make this work
Constructor
PubSub
-
params
Parameters:
-
params
ObjectThe parameters object
-
[url=""]
String optionalThe URL of the server on which the MobilizingServer instance is running
-
[autoConnect=true]
Boolean optionalWhether the connection should be automatically opened
-
Example:
//TODO
Item Index
Events
Methods
close
()
Close the socket connection
getID
()
Get the socket id
open
-
url
Open the socket connection
Parameters:
-
url
StringURL of the server on which the MobilizingServer instance is running
publish
-
channel
-
message
Publish a message to a specific channel
Parameters:
-
channel
StringThe channel on which to publish the message
-
message
MixedThe message to publish
subscribe
-
channel
-
callback
Subscribe for messages from a specific channel
Parameters:
-
channel
StringThe channel on which to subscribe
-
callback
FunctionThe callback to call when a message is received on the channel
unsubscribe
-
channel
-
[callback]
Unsubscribe for messages from a specific channel
Parameters:
-
channel
StringThe channel from which to unsubscribe
-
[callback]
Function optionalThe callback to remove, all callbacks will be removed if unspecified
Events
connect
Fired when the client successfully connects to the server
connect_timeout
Fired when a connection times out
disconnect
Fired when the client disconnects from the server
error
Fired when a connection error occurs