WebSocketChannel.connect constructor

WebSocketChannel.connect(
  1. Uri uri,
  2. {Iterable<String>? protocols}
)

Creates a new WebSocket connection.

Connects to uri using and returns a channel that can be used to communicate over the resulting socket.

The optional protocols parameter is the same as WebSocket.connect.

A WebSocketChannel is returned synchronously, however the connection is not established synchronously. The ready future will complete after the channel is connected. If there are errors creating the connection the ready future will complete with an error.

Implementation

factory WebSocketChannel.connect(Uri uri, {Iterable<String>? protocols}) =>
    platform.connect(uri, protocols: protocols);