sendHeartbeat method
Implementation
@internal
void sendHeartbeat() {
if (!isConnected) {
return;
}
// If the previous heartbeat hasn't received a reply, close the connection.
if (pendingHeartbeatRef != null) {
pendingHeartbeatRef = null;
log(
'transport',
'heartbeat timeout. Attempting to re-establish connection',
);
conn?.sink.close(Constants.wsCloseNormal, 'heartbeat timeout');
return;
}
pendingHeartbeatRef = makeRef();
push(Message(
topic: 'phoenix',
event: ChannelEvents.heartbeat,
payload: {},
ref: pendingHeartbeatRef!,
));
setAuth(accessToken);
}