connect static method
- String url, {
- Iterable<
String> ? protocols, - Map<
String, dynamic> ? headers, - CompressionOptions compression = CompressionOptions.compressionDefault,
- HttpClient? customClient,
Create a new WebSocket connection. The URL supplied in url
must use the scheme ws or wss.
The protocols argument is specifying the subprotocols the
client is willing to speak.
The headers argument is specifying additional HTTP headers for
setting up the connection. This would typically be the Origin
header and potentially cookies. The keys of the map are the header
fields and the values are either String or List
If headers is provided, there are a number of headers
which are controlled by the WebSocket connection process. These
headers are:
connectionsec-websocket-keysec-websocket-protocolsec-websocket-versionupgrade
If any of these are passed in the headers map they will be ignored.
If the url contains user information this will be passed as basic
authentication when setting up the connection.
Implementation
static Future<WebSocket> connect(
String url, {
Iterable<String>? protocols,
Map<String, dynamic>? headers,
CompressionOptions compression = CompressionOptions.compressionDefault,
HttpClient? customClient,
}) => _WebSocketImpl.connect(
url,
protocols,
headers,
compression: compression,
customClient: customClient,
);