types.nope.ICommunicationInterface - ZeMA-gGmbH/NoPE-JS GitHub Wiki

Interface: ICommunicationInterface

types.nope.ICommunicationInterface

A layer is an element that is used to establish a communication connection. This element implements the connection (e.g. a MQTT layer).

A layer is utilized by the ICommunicationBridge

A layer has the following functionalities provided by its interface:

  • The layer must implement the methods on, which are used to listen for various events that can be subscribed to by the nope systems.
  • Messages are sent out using the emit method.
  • The connection status of the layer is indicated in the connected observable. This value is allowed to be true only if there is a connection.
  • Sometimes the layer receives its own messages (the implementation of an udp-broadcast based layer, while broadcasting we will receive our own messages). If this is the case, the receivesOwnMessages flag must be set to true to prevent messages from being received twice.
  • If a layer is not used, we can destroy it with dispose.

Currently there are 3 layers implemented:

Export

ICommunicationInterface

Hierarchy

Implemented by

Properties

connected

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

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


id

Readonly id: string

ID of the Layer.

Author

M.Karkowski

Memberof

ICommunicationInterface


receivesOwnMessages

Readonly receivesOwnMessages: boolean

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

Memberof

ICommunicationInterface

Methods

detailListeners

Optional detailListeners(type, listeners): any

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

any


dispose

dispose(): Promise<void>

Disconnect the Layer.

Memberof

ICommunicationInterface

Returns

Promise<void>

{Promise}


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] & IExtraData

Returns

Promise<void>

{Promise}


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] & IExtraData) => void The Callback to use.

Returns

Promise<void>

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