onHeartbeat method
- Connect heartbeat,
- SocketInfo source
inherited
Handles incoming heartbeats.
- If the heartbeat was meant for another device, log it and ignore it.
- If it came from our dashboard, respond to it with sendHeartbeatResponse.
- If it came from another dashboard, log it and ignore it.
- If we are not connected to any dashboard, call onConnect and respond to it.
Implementation
@override
void onHeartbeat(Connect heartbeat, SocketInfo source) {
if (heartbeat.receiver != device) { // (1)
logger.warning("Received a misaddressed heartbeat for ${heartbeat.receiver}");
} else if (isConnected) {
if (destination == source) { // (2)
sendHeartbeatResponse();
} else { // (3)
logger.warning("Port $port is connected to $destination but received a heartbeat from $source");
}
} else { // (4)
onConnect(source);
sendHeartbeatResponse();
}
}