Sequencer

Sequencer

new Sequencer(opts, adapter)

Source:

Optional sequencer plugin. Manages creating sequence ids and registering callback handlers to them.

Parameters:
Name Type Description
opts Object

Sequencer id settings (range, start, etc.)

Properties
Name Type Attributes Description
min Number

The minimum sequence id

max Number

The maximum sequence id

start String | Number <optional>

Can be set to 'random' or a number to start the sequence id with

adapter Adapter

The adapter object associated with this sequencer

Methods

cancelExternal(id)

Source:

Cancel a pending external sequence id

Parameters:
Name Type Description
id String/Number

The sequence id

cancelInternal(id)

Source:

Cancel a pending internal sequence id

Parameters:
Name Type Description
id Number

The sequence id

checkIfHandlerForIdExists(id) → {Array}

Source:

Indicates if a particular sequencer id has already been registered and has neither been resolved nor cancelled

Parameters:
Name Type Description
id String/Number
Returns:

First element is a Boolean indicating if the id has been registered with handler. The second element is an Array of types of seqId usages (internal, external) where the specified id is being used.

Type
Array

next(callbackopt, scopeopt) → {Number}

Source:

Get the next sequence id

Parameters:
Name Type Attributes Description
callback function <optional>

Optional callback handler. Will be called if transport receives data with the corresponding sequence id

scope Object <optional>

Scope to call callback with

Returns:
Type
Number

(private) random() → {Number}

Source:

Generates a random sequence id between min and max configs

Returns:
Type
Number

(private) received(data) → {Boolean}

Source:

Processed received data from transport

Parameters:
Name Type Description
data Buffer

The data received

Returns:

True if sequencer handled the data

Type
Boolean

registerExternal(id, callback, scopeopt)

Source:

Register an external sequence id. External id numbers must not overlap internal id numbers.

Parameters:
Name Type Attributes Description
id String/Number

The sequence id

callback function

Callback handler

scope Object <optional>

Scope to call callback with

registerInternal(num, callback, scopeopt)

Source:

Registers a handler for the specified internal sequence id. Normally, next() would both obtain a sequence id and register a handler (and this method would not need to be called). However, this method allows next() to be called without a callback, and then a handler can be manually registered here corresponding to the sequence id returned by that next() call.

Parameters:
Name Type Attributes Description
num Number

The sequence id

callback function

Callback handler

scope Object <optional>

Scope to call callback with