WebSocketHeartbeatConfig
Heartbeat ping and acknowledgement settings for a live WebSocket session.
@defjs/core · Type
Signature
interface WebSocketHeartbeatConfig< TIncoming = unknown, TOutgoing = unknown, > { intervalMs: number; isAck?: (message: TIncoming) => boolean; message?: () => TOutgoing; timeoutMs?: number; }
-
intervalMsis the delay between heartbeat messages. -
message()builds the payload. It is sent through theoutgoingstruct. Nothing is sent when it is omitted or returnsundefined. -
After struct encoding, non-JSON values fail with
TypeErrorthrough the same serializer assession.send; that heartbeat failure ends the logical session without reconnecting. -
isAck(message)receives each decoded incoming message. When it returnstrue, the message is treated as the acknowledgement and is not delivered toreceive. -
timeoutMsis how long to wait for an acknowledgement after a heartbeat. Missing it fails the session. -
intervalMsandtimeoutMsmust be positive, finite, and at most2_147_483_647.
Set it with withWebSocketHeartbeat or the heartbeat request option.
Members
Prop
Type
intervalMs numberisAck? ((message: TIncoming) => boolean) | undefinedmessage? (() => TOutgoing) | undefinedtimeoutMs? number | undefined