WebSocketSession class final
One accepted WebSocket connection.
The upgrade already happened, so everything a handler needs about the request that opened it, path parameters and state included, is still here.
Constructors
- WebSocketSession(WebSocketChannel channel, Request request, {String? negotiatedProtocol})
-
Wraps
channel, opened byrequest.
Properties
-
binaryMessages
→ Stream<
Uint8List> -
Binary messages only.
no setter
- channel → WebSocketChannel
-
The channel underneath, for anything this class does not wrap.
final
- closeCode → int?
-
The close code the peer sent, once done completes.
no setter
- closeReason → String?
-
The close reason the peer sent, once done completes.
no setter
-
done
→ Future<
void> -
Resolves when the connection is finished, however it ended.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
messages
→ Stream<
Object?> -
Everything the peer sends, as
StringorUint8List.no setter -
pathParameters
→ Map<
String, String> -
Path parameters captured by the route that accepted the upgrade.
no setter
- protocol → String?
-
The subprotocol agreed during the handshake, or
nullwhen the client offered none the route accepts.no setter - request → Request
-
The request that upgraded, kept so extractors still work.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
textMessages
→ Stream<
String> -
Text messages only, which is what most applications want.
no setter
Methods
-
close(
[int code = WebSocketClose.normal, String? reason]) → Future< void> - Closes the connection.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
send(
String message) → void -
Sends
messageto the peer. -
sendBytes(
List< int> bytes) → void - Sends bytes to the peer.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited