Options
All
  • Public
  • Public/Protected
  • All
Menu

Class NamedGroup<MessageTypes>

Group with a specific name, lets nodes in the network join and leave as needed.

const group = new NamedGroup(net, 'name-of-group');

// Groups need to be joined
await group.join();

// Broadcast to the known members
await group.broadcast('typeOfMessage', dataOfMessage);

Type parameters

  • MessageTypes: object

Hierarchy

  • NamedGroup

Implements

Index

Constructors

constructor

  • new NamedGroup<MessageTypes>(net: Network<any>, name: string): NamedGroup<MessageTypes>

Properties

Readonly name

name: string

Get the name of this group in the network. Will be prefixed with the network name.

Accessors

nodes

  • get nodes(): Node<any>[]

onMessage

  • get onMessage(): Subscribable<this, [message: MessageUnion<MessageTypes>]>

onNodeAvailable

  • get onNodeAvailable(): Subscribable<this, [node: Node<MessageTypes>]>

onNodeUnavailable

  • get onNodeUnavailable(): Subscribable<this, [node: Node<MessageTypes>]>

Methods

broadcast

  • broadcast<T>(type: T, payload: MessageData<MessageTypes, T>): Promise<void>

join

  • join(): Promise<void>

leave

  • leave(): Promise<void>

Generated using TypeDoc