types.nope.ICommunicationInterface - ZeMA-gGmbH/NoPE-JS GitHub Wiki
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:
-
MQTT(see MQTTLayer) -
IO-Sockets:-
io-client(see IoSocketClientLayer) -
io-server(see ioSocketServerLayer runs as Standalone)
-
-
event: an internal layer only. Is defaultly provided. (see EventCommunicationInterface)
Export
ICommunicationInterface
-
ICommunicationInterface
Readonly connected: INopeObservable<boolean, boolean, boolean, IEventAdditionalData>
Flag, indication, whether the Layer is connected or not.
Readonly id: string
ID of the Layer.
Author
M.Karkowski
Memberof
ICommunicationInterface
Readonly receivesOwnMessages: boolean
Used to show, whether the the layer receives its own messages
Memberof
ICommunicationInterface
Optional detailListeners(type, listeners): any
Helper to detail the listeners of the "event", "rpc", "data" or "responses"
| Name | Type | Description |
|---|---|---|
type |
"event" | "rpc" | "data" | "response"
|
valid type to detail the name |
listeners |
string[] |
the currently used listeners. |
any
dispose(): Promise<void>
Disconnect the Layer.
Memberof
ICommunicationInterface
Promise<void>
{Promise}
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
| Name | Type |
|---|---|
T |
extends keyof EventnameToEventType
|
| Name | Type |
|---|---|
eventname |
T |
data |
EventnameToEventType[T] & IExtraData
|
Promise<void>
{Promise}
on<T>(eventname, cb): Promise<void>
used to emit some data.
Author
M.Karkowski
Memberof
ICommunicationInterface
| Name | Type |
|---|---|
T |
extends keyof EventnameToEventType
|
| Name | Type | Description |
|---|---|---|
eventname |
T |
The Event name |
cb |
(data: EventnameToEventType[T] & IExtraData) => void
|
The Callback to use. |
Promise<void>