startWebSocketConnection method

  1. @override
void startWebSocketConnection(
  1. String contactPubsubToken, {
  2. WebSocketChannel onStartConnection(
    1. Uri
    )?,
})
override

Implementation

@override
void startWebSocketConnection(String contactPubsubToken,
    {WebSocketChannel Function(Uri)? onStartConnection}) {
  final socketUrl = Uri.parse(_baseUrl.replaceFirst("http", "ws") + "/cable");
  this.connection = onStartConnection == null
      ? WebSocketChannel.connect(socketUrl)
      : onStartConnection(socketUrl);
  connection!.sink.add(jsonEncode({
    "command": "subscribe",
    "identifier": jsonEncode(
        {"channel": "RoomChannel", "pubsub_token": contactPubsubToken})
  }));
}