Options
All
  • Public
  • Public/Protected
  • All
Menu

MMRP Nodes are created to transmit data encapsulated into MmrpEnvelopes across MAGE servers within a cluster

class

MmrpNode

Hierarchy

  • MmrpNode

Index

Constructors

constructor

  • new MmrpNode(role: "relay" | "client" | "both", cfg: any, clusterId: string): MmrpNode
  • Parameters

    • role: "relay" | "client" | "both"
    • cfg: any
    • clusterId: string

    Returns MmrpNode

Methods

broadcast

  • broadcast(envelope: MmrpEnvelope, routingStyle?: string): number
  • Broadcasts an envelope across the entire mesh of relays and clients.

    Parameters

    Returns number

    Number of bytes sent

close

  • close(): void
  • Closes all sockets on this node and removes all event listeners as we won't be emitting anymore.

    Returns void

connect

  • connect(uri: string, clusterId: string, callback?: Function): void
  • Connects the dealer to a particular URI (if not already connected) and sends it a handshake.

    Parameters

    • uri: string
    • clusterId: string
    • Optional callback: Function

    Returns void

disconnect

  • disconnect(uri: string): void
  • Disconnects the dealer from a given URI (if connected)

    Parameters

    • uri: string

    Returns void

on

  • on(eventName: string, onEvent: function): void

once

  • once(eventName: string, onEvent: function): void

relayDown

  • relayDown(uri: string): void
  • Announce a relay as no longer available. It will disconnect from this relay if connected.

    Parameters

    • uri: string

    Returns void

relayUp

  • relayUp(uri: string, clusterId: string, callback?: Function): void
  • Announce a relay as available. It should be connected to if appropriate.

    Parameters

    • uri: string
    • clusterId: string
    • Optional callback: Function

    Returns void

removeAllListeners

  • removeAllListeners(eventName: string): void
  • Parameters

    • eventName: string

    Returns void

removeListener

  • removeListener(eventName: string, callback: Function): void
  • Parameters

    • eventName: string
    • callback: Function

    Returns void

send

  • send(envelope: MmrpEnvelope, attempts: number | null, callback: Function): number
  • Sends a message along a route of identities

    Parameters

    • envelope: MmrpEnvelope

      The envelope to send

    • attempts: number | null
    • callback: Function

    Returns number

    Number of bytes sent