Options
All
  • Public
  • Public/Protected
  • All
Menu

Actively handles the heartbeat ping/pong mechanism respecting the specified parameters.

Hierarchy

  • HeartbeatHandler

Index

Constructors

constructor

  • new HeartbeatHandler(websocket: WebSocket, pingInterval: number, onDeath?: function): HeartbeatHandler
  • Parameters

    • websocket: WebSocket
    • pingInterval: number
    • Optional onDeath: function
        • (): any
        • Returns any

    Returns HeartbeatHandler

Properties

Private STATE_OPEN

STATE_OPEN: number = 1

Private alive

alive: boolean

Private onDeath

onDeath: function

Type declaration

    • (): any
    • Returns any

Private pingInterval

pingInterval: number

Private websocket

websocket: WebSocket

Methods

handle

  • handle(): void
  • Does some basic checks about the web socket state and starts the actual heartbeat monitoring.

    Returns void

Private handleHeartbeat

  • handleHeartbeat(): void
  • Implements the business logic required for the heartbeat detection to work. If the heartbeat stops respecting the previously-set timeout, the client/server connection is considered dead and the eventually passed in callback is called. The web socket is also closed with code 1008 (policy violation) and message "Heartbeat stopped".

    Returns void

Generated using TypeDoc