connect static method

Future<ServerWebsocket> connect({
  1. required PteroClient client,
  2. required String serverId,
})

Connect to the websocket for a server and return the ServerWebsocket once it's authenticated.

Throws if the connection or initial authentication fails.

Implementation

static Future<ServerWebsocket> connect({
  required PteroClient client,
  required String serverId,
}) async {
  final serverWebsocket = ServerWebsocket._noAutoConnect(
    client: client,
    serverId: serverId,
  );
  // throws if the connection or first auth fails
  await serverWebsocket._connect();
  // await serverWebsocket.ready;
  // await _sub.cancel();
  return serverWebsocket;
}