fromWebsocketUri static method

Future<PhoenixLink> fromWebsocketUri({
  1. required String uri,
  2. Map<String, String>? params,
})

create a new phoenix socket from the given websocketUri, connect to it, and create a channel, and join it

Implementation

static Future<PhoenixLink> fromWebsocketUri({
  required String uri,
  Map<String, String>? params,
}) async {
  final socket = PhoenixSocket(
    uri,
    socketOptions: PhoenixSocketOptions(params: params),
  );
  await socket.connect();

  final channel = socket.addChannel(topic: '__absinthe__:control');
  final push = channel.join();
  await push.future;

  return PhoenixLink(socket: socket, channel: channel);
}