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
↳
AuviousEventClient
Table of contents
Constructors
Properties
- _client
- _eventHandlers
- _realEventHandlers
- _userTopic
- log
- refreshConnectionOnUpdatedCredentials
- PROMISE_TIMEOUT_MILLISEC
Accessors
Methods
- _cleanEventHandlers
- _setEventHandlers
- cleanEventHandlers
- connect
- connected
- disconnect
- dispose
- setEventHandlers
- subscribe
- unsubscribe
- updateCredentials
Constructors
constructor
• new AuviousEventClient(client, assetsLocation, mqttUrl?, host?, port?, path?, sslEnabled?, user?, pass?, refreshConnectionOnUpdatedCredentials?)
Parameters
| Name | Type | Default value |
|---|---|---|
client | AuviousCommon | undefined |
assetsLocation | string | undefined |
mqttUrl? | string | undefined |
host? | string | undefined |
port? | number | undefined |
path | string | "/mqtt" |
sslEnabled? | boolean | undefined |
user? | string | undefined |
pass? | string | undefined |
refreshConnectionOnUpdatedCredentials | boolean | true |
Overrides
Properties
_client
• Private _client: AuviousCommon
_eventHandlers
• Protected _eventHandlers: EventClientHandlers
Inherited from
_realEventHandlers
• Protected _realEventHandlers: any
Inherited from
EventClient._realEventHandlers
_userTopic
• Private _userTopic: string
log
• Protected log: Logger
Inherited from
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
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
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
| Name | Type |
|---|---|
handlers | EventClientHandlers |
Returns
void
Inherited from
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
| Name | Type |
|---|---|
handlers? | EventClientHandlers |
Returns
Promise<IEventClientSubscription>
Inherited from
connected
▸ connected(): Promise<boolean>
Returns
Promise<boolean>
Inherited from
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
dispose
▸ dispose(subscription): void
Parameters
| Name | Type |
|---|---|
subscription | IEventClientSubscription |
Returns
void
Inherited from
setEventHandlers
▸ setEventHandlers(handlers): IEventClientSubscription
Exposes setEventHandlers of EventFiringClient's implementation to the public api.
Parameters
| Name | Type |
|---|---|
handlers | EventClientHandlers |
Returns
Inherited from
subscribe
▸ subscribe(topic): Promise<Event<any>>
Subscribe to a topic to listen to receive events sent to that.
Parameters
| Name | Type |
|---|---|
topic | string |
Returns
Promise<Event<any>>
Inherited from
unsubscribe
▸ unsubscribe(topic): Promise<Event<any>>
Unsubscribe from a topic to listen to stop receiving events sent to that.
Parameters
| Name | Type |
|---|---|
topic | string |
Returns
Promise<Event<any>>
Inherited from
updateCredentials
▸ updateCredentials(username, password): Promise<void>
Parameters
| Name | Type |
|---|---|
username | string |
password | string |
Returns
Promise<void>