WebSocketChannel class
A StreamChannel
that communicates over a WebSocket.
This is implemented by classes that use dart:io
and dart:html
.
The WebSocketChannel.new constructor can also be used on any platform to
connect to use the WebSocket protocol over a pre-existing channel.
All implementations emit WebSocketChannelExceptions. These exceptions wrap the native exception types where possible.
- Inheritance
-
- Object
- StreamChannelMixin
- WebSocketChannel
- Implementers
Constructors
-
WebSocketChannel(StreamChannel<
List< int>> channel, {String? protocol, Duration? pingInterval, bool serverSide = true}) -
Creates a new WebSocket handling messaging across an existing
channel
. -
WebSocketChannel.connect(Uri uri, {Iterable<
String>? protocols}) -
Creates a new WebSocket connection.
factory
Properties
- closeCode → int?
-
The close code set when the WebSocket connection is closed.
read-only
- closeReason → String?
-
The close reason set when the WebSocket connection is closed.
read-only
- hashCode → int
-
The hash code for this object.
read-onlyinherited
- protocol → String?
-
The subprotocol selected by the server.
read-only
-
ready
→ Future<
void> -
Future indicating if the connection has been established.
It completes on successful connection to the websocket.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
- sink → WebSocketSink
-
The sink for sending values to the other endpoint.
read-onlyoverride
- stream → Stream
-
The single-subscription stream that emits values from the other endpoint.
read-onlyoverride
Methods
-
cast<
S>( ) → StreamChannel< S> -
Returns a copy of this with the generic type coerced to
S
.inherited -
changeSink(
StreamSink change(StreamSink)) → StreamChannel -
Returns a copy of this with sink replaced by
change
's return value.inherited -
changeStream(
Stream change(Stream)) → StreamChannel -
Returns a copy of this with stream replaced by
change
's return value.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pipe(
StreamChannel other) → void -
Connects this to
other
, so that any values emitted by either are sent directly to the other.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
transform<
S>( StreamChannelTransformer< S, dynamic> transformer) → StreamChannel< S> -
Transforms this using
transformer
.inherited -
transformSink(
StreamSinkTransformer transformer) → StreamChannel -
Transforms only the sink component of this using
transformer
.inherited -
transformStream(
StreamTransformer transformer) → StreamChannel -
Transforms only the stream component of this using
transformer
.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
signKey(
String key) → String -
Signs a
Sec-WebSocket-Key
header sent by a WebSocket client as part of the initial handshake.