webSocketLookUps function

AtLookUpFactory webSocketLookUps({
  1. String path = '/ws',
  2. int directoryPort = 443,
  3. Future<void> onConnect(
    1. AtCommandExecutor connection
    )?,
})

The browser AtLookUpFactory: each atSign is looked up with an HttpsSecondaryAddressFinder on the root domain's host at directoryPort, and each connection is a WebSocket to wss://atServerHost:port + path.

A factory call's own secondaryAddressFinder replaces the lookup. onConnect runs on each connection before anything else is sent on it.

The atDirectory must answer the page's origin with CORS headers for the lookup to succeed.

Implementation

AtLookUpFactory webSocketLookUps({
  String path = '/ws',
  int directoryPort = 443,
  Future<void> Function(AtCommandExecutor connection)? onConnect,
}) =>
    _webSocketLookUps(
        path: path,
        finderFor: (rootDomain) => HttpsSecondaryAddressFinder(
            rootDomain.rootDomain,
            port: directoryPort),
        onConnect: onConnect);