communication.Bridge - ZeMA-gGmbH/NoPE-JS GitHub Wiki

Class: Bridge

communication.Bridge

A ICommunicationBridge is used to establish different connections (a bridge can establish several connections with different layers).

The ICommunicationBridge is the core interface with which all Nope core elements interact. Its main task is to add and remove multiple layers (like 'mqtt' or 'io-sockets'; see ICommunicationInterface)

To the outside, the bridge behaves like a ICommunicationInterface. I.e. the methods on and emit are also implemented. However, the bridge ensures that each of the ICommunicationInterface added, are able to receive and send the messages. Furthermore the status connected indicates whether all layers are connected or not.

If different layers are only optional, e.g. all connections are covered by io-sockets, but all messages are to be mirrored to MQTT because they are to be picked up there, then this can be taken into account in the add method. These connections are then not taken into account in the connected status.

Export

ICommunicationBridge

Implements

Constructors

constructor

new Bridge(id?, logger?)

Creates an instance of Bridge.

Memberof

Bridge

Parameters

Name Type Default value Description
id? string undefined The ID. (this can be adapted later and is only used to simplify debugging)
logger ValidLoggerDefinition false -

Properties

connected

connected: INopeObservable<boolean, boolean, boolean, IEventAdditionalData>

Flag, indication, whether the Layer is connected or not.

Implementation of

ICommunicationBridge.connected


considerConnection

considerConnection: boolean = true


id

id: string

ID of the Layer.

Author

M.Karkowski

Memberof

ICommunicationInterface

Implementation of

ICommunicationBridge.id


ownDispatcherId

ownDispatcherId: string

Accessors

receivesOwnMessages

get receivesOwnMessages(): boolean

Used to show, whether the the layer receives its own messages

Memberof

ICommunicationInterface

Returns

boolean

Implementation of

ICommunicationBridge.receivesOwnMessages

Methods

addCommunicationLayer

addCommunicationLayer(layer, forwardData?, considerConnection?): Promise<void>

Function, to add an Layer to the Bridge

Memberof

ICommunicationBridge

Parameters

Name Type Default value Description
layer ICommunicationInterface undefined The Layer to Add.
forwardData boolean false -
considerConnection boolean false Flag, that enables considering this flag in the connected flag.

Returns

Promise<void>

Implementation of

ICommunicationBridge.addCommunicationLayer


detailListeners

detailListeners(type, listeners): void

Helper to detail the listeners of the "event", "rpc", "data" or "responses"

Parameters

Name Type Description
type "event" | "rpc" | "data" | "response" valid type to detail the name
listeners string[] the currently used listeners.

Returns

void

Implementation of

ICommunicationBridge.detailListeners


dispose

dispose(): Promise<void>

Disconnect the Layer.

Memberof

ICommunicationInterface

Returns

Promise<void>

{Promise}

Implementation of

ICommunicationBridge.dispose


emit

emit<T>(eventname, data): Promise<void>

used to emit some data on the bride. It will distribute the event accors

Author

M.Karkowski

Memberof

ICommunicationInterface

Type parameters

Name Type
T extends keyof EventnameToEventType

Parameters

Name Type
eventname T
data EventnameToEventType[T]

Returns

Promise<void>

{Promise}

Implementation of

ICommunicationBridge.emit


on

on<T>(eventname, cb): Promise<void>

used to emit some data.

Author

M.Karkowski

Memberof

ICommunicationInterface

Type parameters

Name Type
T extends keyof EventnameToEventType

Parameters

Name Type Description
eventname T The Event name
cb (data: EventnameToEventType[T]) => void The Callback to use.

Returns

Promise<void>

Implementation of

ICommunicationBridge.on


removeCommunicationLayer

removeCommunicationLayer(layer): Promise<void>

Function, to remove the Layer again. Data wont be forwarded any more.

Memberof

ICommunicationBridge

Parameters

Name Type Description
layer ICommunicationInterface The Layer to Remove

Returns

Promise<void>

Implementation of

ICommunicationBridge.removeCommunicationLayer


toDescription

toDescription(): Object

Readable status of the Connection.

Memberof

ICommunicationBridge

Returns

Object

The Statsus

Name Type
connected boolean
layers { considerConnection: boolean = item.considerConnection; forwardData: boolean = item.forwardData; id: string = item.layer.id; receivesOwnMessages: boolean = item.layer.receivesOwnMessages }[]

Implementation of

ICommunicationBridge.toDescription

⚠️ **GitHub.com Fallback** ⚠️