Class: Connection(socket)

Upgrade a net.Socket like object into a protocol specific connection object.

Events

Event: connect

Emitted with a ctx object containing the following.

  • ctx.auth - Object containing auth information
  • ctx.auth.username - Object containing client username
  • ctx.auth.password - Object containing client password

Emitted on successful connection (or reconnection).

Event: error

Emitted when a connection error has occurred.

Event: publish

Emitted with a ctx object containing the following.

  • ctx.topic - String the topic the client would like to publish the message to
  • ctx.message - String or Buffer the message to publish
  • ctx.options - Object protocol specific options

Event: subscribe

Emitted with a ctx object containing the following.

  • ctx.topic - String the topic the client would like to publish the message to
  • ctx.options - Object protocol specific options

Event: unsubscribe

Emitted with a ctx object containing the following.

  • String the topic the client would like to unsubscribe from.
Arguments
Name Type Description
socket net.Socket

The Socket like object to upgrade.