onNetworkLost method

void onNetworkLost()

设备网络丢失:停止心跳与重连定时器,挂起重连意图。

Implementation

void onNetworkLost() {
  networkAvailable = false;
  _reconnectTimer?.cancel();
  if (_connected || _connecting) {
    _reconnectPending = true;
    _failAllPending(
      GoChatException('网络不可用', code: -1001),
    );
    // 主动断开 socket,避免半开连接占着
    _cleanupChannel(reconnect: false);
    _connListener?.connectFailed(-1001, '网络不可用');
  } else {
    _reconnectPending = !_manualClose && _token != null;
  }
}