API Documentation

for 0.0.1
Show:

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 Object

    The parameters object

    • [url=""] String optional

      The URL of the server on which the MobilizingServer instance is running

    • [autoConnect=true] Boolean optional

      Whether the connection should be automatically opened

Example:

//TODO

Methods

close

()

Close the socket connection

getID

()

Get the socket id

open

(
  • url
)

Open the socket connection

Parameters:

  • url String

    URL of the server on which the MobilizingServer instance is running

publish

(
  • channel
  • message
)

Publish a message to a specific channel

Parameters:

  • channel String

    The channel on which to publish the message

  • message Mixed

    The message to publish

subscribe

(
  • channel
  • callback
)

Subscribe for messages from a specific channel

Parameters:

  • channel String

    The channel on which to subscribe

  • callback Function

    The callback to call when a message is received on the channel

unsubscribe

(
  • channel
  • [callback]
)

Unsubscribe for messages from a specific channel

Parameters:

  • channel String

    The channel from which to unsubscribe

  • [callback] Function optional

    The 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