open method

void open({
  1. OnSocketOpen? onOpen,
  2. OnSocketClose? onClose,
})

Open a new connection to a web socket server.

Implementation

void open({OnSocketOpen? onOpen, OnSocketClose? onClose}) {
  // Connect the channel
  final wsUrl = getWebSocketUrl(
    url: url,
    protocol: protocol,
    version: version.toString(),
  );

  _socket = ReconnectingWebSocket(
    url: wsUrl,
    maxReconnectAttempts: 5,
    debug: false,
    onOpen: onOpen,
    onClose: onClose,
    onMessage: _socketReceive,
  );

  _socket?.open(false);

  // Queue subscriptions
  _queueSubscriptions();
}