Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Node<MessageTypes>

Node within the network. Nodes are individual instances that you can receive and send messages from/to.

Nodes are usually retrieved via a Network or Group. When a node becomes available you may opt in to events about the node via subscribable functions such as onMessage and onUnavailable.

When a node becomes unavailable you should stop listening to events and discard the node.

Messages to the specific node may be sent via send.

Type parameters

  • MessageTypes: object = any

Hierarchy

  • Node

Index

Properties

Readonly estimatedLatency

estimatedLatency: number

Advanced: Estimated latency to the node.

Readonly id

id: string

The identifier of this node.

Readonly onMessage

onMessage: Subscribable<Node<MessageTypes>, [message: MessageUnion<MessageTypes>]>

Event emitted when a message is received by this node.

Readonly onUnavailable

onUnavailable: Subscribable<Node<MessageTypes>, []>

Event emitted when this node is no longer available and should be discarded.

Methods

send

  • send<T>(type: T, data: MessageData<MessageTypes, T>): Promise<void>
  • Send a message to this node. This will return a promise that will complete when the message has initially been sent.

    Type parameters

    • T: string

    Parameters

    • type: T
      • the type of message being sent
    • data: MessageData<MessageTypes, T>
      • data being sent

    Returns Promise<void>

Generated using TypeDoc