Show:

Conveying messages over MQTT protocol, in Node.JS.

Constructor

webduino.transport.NodeMqttTransport
(
  • options
)

Parameters:

  • options Object

    Options to build a proper transport

Methods

addListener
(
  • type
  • listener
)

Add a listener for a certain type of event.

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

close ()

Close and terminate the transport.

emit
(
  • type
  • object,...
)

Emit an event of certain type.

Parameters:

  • type String

    Event type.

  • [object,...] Object optional

    Event object(s).

flush ()

Flush any buffered data of the transport.

listeners
(
  • type
)

Return the listener list bound to certain type of event.

Parameters:

  • type String

    Evnet type.

on
(
  • type
  • listener
)

Alias for EventEmitter.addListener(type, listener)

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

once
(
  • type
  • listener
)

Add a one-time listener for a certain type of event.

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

removeAllListeners
(
  • type
)

Remove all listeners of certain type.

Parameters:

  • type String

    Event type.

removeListener
(
  • type
  • listener
)

Remove a listener for certain type of event.

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

send
(
  • payload
)

Send payload through the transport.

Parameters:

  • payload Array

    The actual data to be sent.

setMaxListeners
(
  • n
)

Set maximum number of listeners that is allow to bind on an emitter.

Parameters:

  • n Number

    Number of listeners.

Properties

CONNECT_TIMEOUT

Number static

Time to wait before throwing connection timeout exception. Measured in seconds.

KEEPALIVE_INTERVAL

Number static

MQTT keepalive interval. Measured in seconds.

MAX_PACKET_SIZE

Number static

Maximum packet size in KB.

RECONNECT_PERIOD

Number static

Reconnect period when MQTT connection goes down. Measured in seconds.

Attributes

isOpen

Boolean readonly

Indicates if the state of the transport is open.

Events

TransportEvent.CLOSE

Fires when a transport is closed.

TransportEvent.ERROR

Fires when a transport get an error.

TransportEvent.MESSAGE

Fires when a transport receives a message.

TransportEvent.OPEN

Fires when a transport is opened.