EDA.Gateway.Heartbeat (EDA v0.3.0)

Copy Markdown View Source

Manages heartbeat timing for the Gateway connection.

Discord requires regular heartbeats to keep the connection alive. The interval is provided by Discord in the HELLO payload.

Summary

Functions

Cancels a pending heartbeat timer.

Schedules the next heartbeat at a fixed interval.

Schedules the first heartbeat after HELLO.

Functions

cancel(ref)

@spec cancel(reference() | nil) :: :ok

Cancels a pending heartbeat timer.

start(interval)

@spec start(integer()) :: reference()

Schedules the next heartbeat at a fixed interval.

start_first(interval)

@spec start_first(integer()) :: reference()

Schedules the first heartbeat after HELLO.

Per Discord docs, the first heartbeat should be sent after interval * jitter where jitter is between 0 and 1.