onConnectionHealthChanged method
Event-driven connection health change handler
Implementation
void onConnectionHealthChanged(SwarmConn conn, ConnectionHealthState newState) {
final peerIdStr = conn.remotePeer.toString();
final oldState = _connectionHealthStates[peerIdStr];
_connectionHealthStates[peerIdStr] = newState;
_logger.info('Swarm: Connection health changed for ${conn.remotePeer} (${conn.id}): $oldState -> $newState');
// Handle failed connections immediately
if (newState == ConnectionHealthState.failed) {
_logger.warning('Swarm: Connection ${conn.id} to ${conn.remotePeer} has failed - scheduling immediate removal');
_removeFailedConnection(conn);
}
}