- [/components/component-emitter/index.js] (#componentscomponent-emitterindexjs)
- [/lib/client/Client.js] (#libclientclientjs)
- [/lib/client/index.js] (#libclientindexjs)
- [/lib/server/Adapter.js] (#libserveradapterjs)
- [/lib/server/Connection.js] (#libserverconnectionjs)
- [/lib/server/Message.js] (#libservermessagejs)
- [/lib/server/Server.js] (#libserverserverjs)
- [/lib/server/adapters/Memory.js] (#libserveradaptersmemoryjs)
- [/lib/server/adapters/Mongo.js] (#libserveradaptersmongojs)
- [/lib/server/index.js] (#libserverindexjs)
- [/lib/shared/Multiplexer.js] (#libsharedmultiplexerjs)
- [/lib/shared/utils.js] (#libsharedutilsjs)
Initialize a new Emitter
.
Listen on the given event
with fn
.
-
String event
-
Function fn
- Emitter
Adds an event
listener that will be invoked a single
time then automatically removed.
-
String event
-
Function fn
- Emitter
Remove the given callback for event
or all
registered callbacks.
-
String event
-
Function fn
- Emitter
Emit event
with the given args.
-
String event
-
Mixed ...
- Emitter
Return array of callbacks for event
.
- String event
- Array
Check if this emitter has event
handlers.
- String event
- Boolean
Client constructor. Inherits from Emitter.
See: Emitter
- Object options
Default options, will be overwritten by options passed to the constructor.
ajax
required jQuery ajax api (web client only)url
connection url, default is/simpleio
reconnectionDelay
ms amount to wait before to reconnect in case of error, will be increased on every further error until maxReconnectionDelay, default is1000
maxReconnectionDelay
max ms amount to wait before to reconnect in case of error, default is10000
multiplexDuration
ms amount for multiplexing messages before emitting, default is500
Start polling.
- Object [data] data to send with every request.
- Client this
Stop polling.
- Client this
Send message to the server.
-
Mixed message message to send.
-
Function [callback] is called when message was send to the server without error.
- Client this
Client constructor.
See: Client
Create client.
See: Client
- Object [options]
- Client
Adapter interface. Inherits from `Emitter. All adapters should inherit from this class.
Dispatch a message.
-
String recipient
-
Mixed data
-
Function callback
- Adapter this
A client opened a connection. Save it to determine later if the client is connected.
-
String|Number sender
-
Function callback
- Adapter this
Get users who opened a connection since x date.
-
Date since the date since user has send messages
-
Function callback
- Adapter this
Get all messages for the recipient, which are deliverable.
-
String recipient id
-
Date since which date to consider messages, the oldest message would
-
Function callback
- Adapter this
Mark message status as deliverable, save clients who has got the message.
Options
deliverable
boolean, message is undeliverable if falsedelivered
boolean, true if some client got a messageclient
client id which got a messagepublic
boolean, true if delivered event needs to be published on the storage
-
Object opts
-
Function callback
- Adapter this
Destroy the adapter. Remove all event listeners, close connections to the storage etc.
- Adapter this
Incomming connection.
Inherits from Emitter
.
-
Object params
-
Server server
-
Adapter adapter
Open a connection.
- Connection this
Close a connection.
- String [status] message
- Connection this
Message constructor - a higher level way to build and send a message.
- Server server
Define recipients.
- Array|String|Number recipients you can pass multiple recipients using
- Message this
Define an event name. If no event defined, the message can be subscribed on the client using "message" event.
- String event
- Message this
Define data to be send within a message
- Mixed data
- Message this
Send the message. Message is sent successful if every recipient has confirmed the delivery. Callback is called with "true" as second parameter if succeeded.
- Function callback
- Message this
Broadcast a message. There is no delivery confirmation. Callback is called after the message is stored.
- Function callback
- Message this
Server constructor.
Inherits from Emitter
.
- Object [options]
Default options, will be overwritten by options passed to the Server.
deliveryTimeout
Message is not delivered if confirmation was not received during this time, default is40000
keepAlive
amount of ms to keep connection open. (Heroku requires this value to be less than 30s.), default is25000
disconnectedAfter
amount of ms after which client counts as disconnected, default is40000
multiplexDuration
amount of ms messages will be collected before send, default is500
Client has opened a connection.
Params object:
user
user idclient
client id of the user (one user can have multiple clients)delivered
optional delivered messages ids array
- Object params
- Connection
Close connection to one/all clients.
- String|Number client id
- Server this
Destroy the server.
- Server this
Create a message.
- Message
Get connected users.
- Function callback
- Server this
Send a message to recipient(s). If all recipients receive and confirm the message, second callback parameter will be true.
Recommended to use a Server#message which is a higher level to send a message.
-
String|Number|Array recipients one or multiple recipients
-
Object data to send
-
Function [callback]
- Server this
Memory adapter constructor.
Inherits from Adapter
.
- Object opts will overwrite default options, see
Memory.options
Default options.
maxAge
message lifetimecleanupInterval
interval when to cleanup the cachecleanup
true if cache should be periodically cleaned up
@see Adapter#dispatch
@see Adapter#open
@see Adapter#connected
@see Adapter#get
@see Adapter#delivery
@see Adapter#destroy
Mongo adapter constructor.
-
String|Object uri or Db instance from mongo driver.
-
Object opts will overwrite defaults, see
Mongo.options
Mongo adapter defaults.
Inherits from Adapter
.
uri
mongo uridb
mongo optionsname
collection name, mubsub channel namechannel
mubsub channel optionsmaxClients
max amount of clients per recipient. Needed to reserve space in docs, because capped collections can't grow.stringify
function for data serialization, defaults to JSON.stringifyparse
function for data deserialization, defaults to JSON.parse
@see Adapter#dispatch
@see Adapter#open
@see Adapter#connected
@see Adapter#get
@see Adapter#delivery
@see Adapter#destroy
Expose Server constructor.
Expose Message constructor.
Expose Connection constructor.
Expose Multiplexer constructor.
Expose utils.
Expose adapters.
Create a Server instance.
See: exports.Server
- Object [opts]
- Server
Multiplexer constructor.
Inherits from Emitter
.
- Object opts
Add message(s).
- Mixed messages
- Multiplexer this
Reset multiplexer, emit "reset" if there are messages.
- Boolean [emit] only emit "reset" if true.
- Multiplexer this
Get messages.
- Array
Stop multiplexer
- Multiplexer this
Crossengine detecttion if passed object is an array.
- Object obj
- Boolean
Crossbrowser Date.now.
- Number
The cornerstone, an each
implementation, aka forEach
.
Handles objects with the built-in forEach
, arrays, and raw objects.
Delegates to ECMAScript 5's native forEach
if available.
-
Object obj
-
Function iterator
-
Object [context]
Shortcut for hasOwnProperty.
-
Object obj
-
String key
- Boolean
Extend first passed object by the following.
- Object obj
Generate a unique id.
- Number
No operation.