connectionFactory method

Future<ConnectionTask<Socket>> connectionFactory(
  1. dynamic uri,
  2. String? proxyHost,
  3. int? proxyPort,
  4. SecurityContext? context,
)

Custom connection factory for creating socket connections.

Resolves and connects to the specified uri. Optionally supports proxies and secure connections.

Returns a Future that completes with a ConnectionTask for a Socket.

Implementation

Future<ConnectionTask<Socket>> connectionFactory(
    uri, String? proxyHost, int? proxyPort, SecurityContext? context) {
  var socketAsync = _socketConnector.openSocket(
    uri.host,
    uri.port,
    secure: uri.scheme == 'https',
    context: context,
  );

  return Future.value(ConnectionTask.fromSocket(socketAsync, () {}));
}