class HeartbeatSweeper
Since 0.1.0

Sends heartbeats and closes idle connections on one shared interval.

Constructors

HeartbeatSweeper(
runtime: IRuntimeServices,
connections: () => Iterable<WebSocketConnection>
)

Creates the sweeper.

Parameters
runtime: IRuntimeServices

Runtime services, for timers and the monotonic clock

Heartbeat configuration

connections: () => Iterable<WebSocketConnection>

Supplies the current connections on each tick

Properties

readonly
isRunning: boolean

Whether the interval is currently running.

Methods

start(): void

Starts the interval. A no-op when heartbeats are disabled, so a plugin left at its defaults never creates a timer.

stop(): void

Stops the interval. Idempotent.

tick(): void

Runs one sweep: closes connections that have been silent too long, then sends the heartbeat payload to the rest.

Exposed so tests drive a deterministic tick rather than waiting on a timer.

Usage

import { HeartbeatSweeper } from "websocket-plugin/src/index.ts";