Class: DDP

DDP(options)

Represents a DDP client that interfaces with the Meteor server backend

Constructor

new DDP(options)

Create a new DDP instance and runs the following init procedure: - init event interfaces for this instance - create a new message Queue - instantiates the WebSocket - open websocket and establish DDP protocol messaging - setup close handling for proper garbage collection etc.
Parameters:
Name Type Description
options object constructor options
Properties
Name Type Attributes Description
autoConnect boolean <optional>
set to true to auto connect
Source:
See:
  • {Queue} the internal Queue implementation that is used
  • {Socket} the internal Socket implementation that is used

Methods

connect()

Initiates the underlying websocket to open the connection
Source:

disconnect()

Closes the underlying socket connection. If `disconnect` is called, the caller likely doesn't want the instance to try to auto-reconnect. Therefore, we set the `autoReconnect` flag to false.
Source:

emit()

Emits a new event. Wraps emitting in a setTimeout (macrotask)
Source:

method(name, params) → {string}

Pushes a method to the message queue. This is what happens under the hood when using {Meteor.call}
Parameters:
Name Type Description
name string the name of the Meteor Method that is to be called
params any the params to pass, likely an object
Source:
Returns:
a unique message id, beginning from 1, counting up for each message
Type
string

sub(name, params) → {string}

Subscribes to a Meteor Publication by adding a sub message to the message queue. This is what is called when using {Meteor.subscribe}
Parameters:
Name Type Description
name string name of the publication to sub
params any args, passed to the sub, likely an object
Source:
Returns:
a unique message id, beginning from 1, counting up for each message
Type
string

unsub(id) → {string}

Subscribes to a Meteor Publication by adding a sub message to the message queue. This is what is called when calling the `stop()` method of a subscription.
Parameters:
Name Type Description
id string id of the prior sub message
Source:
Returns:
the id of the prior sub message
Type
string