connect method
Function to define another connection without call directly the connection function
If getHeaders is set, it is re-evaluated here on every connection and reconnection attempt.
Headers are not applied when connectFn is set: a custom connect function is responsible for supplying its own headers.
Implementation
Future<WebSocketChannel> connect(
{required Uri uri,
Iterable<String>? protocols,
Map<String, dynamic>? headers}) async {
if (connectFn != null) {
return connectFn!(uri, protocols);
}
return defaultConnectPlatform(
uri,
protocols,
headers: headers ?? await resolvedHeaders,
);
}