Repository

PubSub

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

Example:

   //TODO

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public

events: *

public

id: *

public

socket: *

public
public

url: *

Method Summary

Public Methods
public

Close the socket connection

public

getID(): *

Get the socket id

public

open(url: String)

Open the socket connection

public

publish(channel: String, message: Mixed)

Publish a message to a specific channel

public

subscribe(channel: String, callback: Function)

Subscribe for messages from a specific channel

public

unsubscribe(channel: String, callback: Function)

Unsubscribe for messages from a specific channel

Public Constructors

public constructor(params: Object) source

Params:

NameTypeAttributeDescription
paramsObject

Parameters object, given by the constructor.

params.urlString
  • optional
  • default: ""

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

params.autoConnectBoolean
  • optional
  • default: true

Whether the connection should be automatically opened

Public Members

public autoConnect: * source

public events: * source

public id: * source

public socket: * source

public subscriptions: {} source

public url: * source

Public Methods

public close() source

Close the socket connection

public getID(): * source

Get the socket id

Return:

*

public open(url: String) source

Open the socket connection

Params:

NameTypeAttributeDescription
urlString

URL of the server on which the MobilizingServer instance is running

public publish(channel: String, message: Mixed) source

Publish a message to a specific channel

Params:

NameTypeAttributeDescription
channelString

The channel on which to publish the message

messageMixed

The message to publish

public subscribe(channel: String, callback: Function) source

Subscribe for messages from a specific channel

Params:

NameTypeAttributeDescription
channelString

The channel on which to subscribe

callbackFunction

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

public unsubscribe(channel: String, callback: Function) source

Unsubscribe for messages from a specific channel

Params:

NameTypeAttributeDescription
channelString

The channel from which to unsubscribe

callbackFunction
  • optional

The callback to remove, all callbacks will be removed if unspecified