Skip to main content

AuviousEventClient

@auvious/common / Exports / AuviousEventClient

Class: AuviousEventClient

Event client implementation for auvious' services.

Setup to work via the mqtt protocol with the paho-mqtt package.

More info: http://www.eclipse.org/paho/clients/js

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new AuviousEventClient(client, mqttUrl?, host?, port?, path?, sslEnabled?, user?, pass?, refreshConnectionOnUpdatedCredentials?)

Parameters

NameTypeDefault value
clientAuviousCommonundefined
mqttUrl?stringundefined
host?stringundefined
port?numberundefined
pathstring"/mqtt"
sslEnabled?booleanundefined
user?stringundefined
pass?stringundefined
refreshConnectionOnUpdatedCredentialsbooleantrue

Overrides

EventClient.constructor

Properties

_client

Private _client: AuviousCommon


_eventHandlers

Protected _eventHandlers: EventClientHandlers

Inherited from

EventClient._eventHandlers


_realEventHandlers

Protected _realEventHandlers: any

Inherited from

EventClient._realEventHandlers


_userTopic

Private _userTopic: string


log

Protected log: Logger

Inherited from

EventClient.log


refreshConnectionOnUpdatedCredentials

Protected refreshConnectionOnUpdatedCredentials: boolean = true

Inherited from

EventClient.refreshConnectionOnUpdatedCredentials


PROMISE_TIMEOUT_MILLISEC

Static Protected PROMISE_TIMEOUT_MILLISEC: number = 5000

Inherited from

EventClient.PROMISE_TIMEOUT_MILLISEC

Accessors

_defaultHandlers

Protected get _defaultHandlers(): EventClientHandlers

Returns

EventClientHandlers

Inherited from

EventClient._defaultHandlers


initialized

get initialized(): boolean

Returns

boolean

Inherited from

EventClient.initialized


isSubscribedToUserTopic

get isSubscribedToUserTopic(): boolean

Returns

boolean


subscriptionHandlers

Protected get subscriptionHandlers(): EventClientHandlers

Returns

EventClientHandlers

Inherited from

EventClient.subscriptionHandlers


userTopic

get userTopic(): string

Returns

string

Methods

_cleanEventHandlers

Protected _cleanEventHandlers(): void

Clean event handler callbacks.

We actually just reassign to the default callbacks.

Returns

void

Inherited from

EventClient._cleanEventHandlers


_setEventHandlers

Protected _setEventHandlers(handlers): void

Sets event handler callbacks.

Every event handler callback defaults to _defaultHandlers which just prints the event to console.

An event callback that was not passed in the argument, will default to either:

  • the previous callback is ever set.
  • the _defaultHandlers's corresponding callback.

The default behaviour when appendToPrevious = true is to append the handlers passed in the arguments.

If appendToPrevious is set to false the previous handlers will be cleaned before we the the argument handlers.

Parameters

NameType
handlersEventClientHandlers

Returns

void

Inherited from

EventClient._setEventHandlers


cleanEventHandlers

cleanEventHandlers(): void

Exposes cleanEventHandlers of EventFiringClient's implementation to the public api.

Returns

void

Inherited from

EventClient.cleanEventHandlers


connect

connect(handlers?): Promise<IEventClientSubscription>

Connect the client with the server.

Events are fired via the callbacks of the EventClientHandlers argument.

Parameters

NameType
handlers?EventClientHandlers

Returns

Promise<IEventClientSubscription>

Inherited from

EventClient.connect


connected

connected(): Promise<boolean>

Returns

Promise<boolean>

Inherited from

EventClient.connected


disconnect

disconnect(): Promise<void>

Disconnect the client from the server.

The current event handlers are not cleaned. They can be reused from a followup .connect() without args.

Returns

Promise<void>

Inherited from

EventClient.disconnect


dispose

dispose(subscription): void

Parameters

NameType
subscriptionIEventClientSubscription

Returns

void

Inherited from

EventClient.dispose


setEventHandlers

setEventHandlers(handlers): IEventClientSubscription

Exposes setEventHandlers of EventFiringClient's implementation to the public api.

Parameters

NameType
handlersEventClientHandlers

Returns

IEventClientSubscription

Inherited from

EventClient.setEventHandlers


subscribe

subscribe(topic): Promise<Event<any>>

Subscribe to a topic to listen to receive events sent to that.

Parameters

NameType
topicstring

Returns

Promise<Event<any>>

Inherited from

EventClient.subscribe


unsubscribe

unsubscribe(topic): Promise<Event<any>>

Unsubscribe from a topic to listen to stop receiving events sent to that.

Parameters

NameType
topicstring

Returns

Promise<Event<any>>

Inherited from

EventClient.unsubscribe


updateCredentials

updateCredentials(username, password): Promise<void>

Parameters

NameType
usernamestring
passwordstring

Returns

Promise<void>

Inherited from

EventClient.updateCredentials