FramedWebSocket class final
A RelicWebSocket framed in Dart over a raw byte channel, for an adapter that can hand a connection over but has no framer of its own.
The opening handshake is done before this is created. Whoever closes first sends a close frame and waits up to closeTimeout for the other side's, then closes the channel's sink, which ends the connection. Pings go out every pingInterval when one is set. A peer that does not answer one before the next is due is gone, and the socket closes with 1001.
- Inheritance
-
- Object
- RelicWebSocketBase
- FramedWebSocket
Constructors
-
FramedWebSocket(StreamChannel<
Uint8List> _channel, {int maxMessageSize = defaultMaxMessageSize})
Properties
- closeSent → bool
-
Whether a close frame of this side's is on its way or went out.
no setterinherited
-
done
→ Future<
void> -
Completes once the connection is closed, whoever closed it.
no setterinherited
-
events
→ Stream<
WebSocketEvent> -
A Stream of
WebSocketEventreceived from the peer.no setterinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- isClosed → bool
-
Whether the web-socket is closed.
no setterinherited
- pingInterval ↔ Duration?
-
The interval at which ping frames are sent to keep the web-socket
connection alive.
getter/setter pairinherited
- protocol → String
-
The WebSocket subprotocol negotiated with the peer.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addError(
Object error, [StackTrace? stackTrace]) → void -
Hands the handler an error, unless its events ended.
inherited
-
addEvent(
WebSocketEvent event) → void -
Hands the handler an event, unless its events ended.
inherited
-
close(
[int? code, String? reason]) → Future< void> -
Closes the WebSocket connection and the events
Stream.inherited -
closeEvents(
[CloseReceived? close]) → void -
Ends the handler's events, after
closewhen it should hear how the connection closed.inherited -
completeDone(
) → void -
Completes done and stops the ping timer, once the connection is over.
inherited
-
goAway(
int code, String reason) → void -
Closes from this side with
code, and the handler sees that close.inherited -
markCloseSent(
) → void -
Records a close the transport sent on this side's behalf, such as
the echo of the peer's close frame.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onCloseSent(
) → void -
Called once a close frame of this side's went out.
override
-
onPeerUnresponsive(
) → void -
A peer that let a ping go unanswered will not answer the close frame
either, so the channel closes behind it at once rather than after
closeTimeout.
override
-
onPing(
) → void -
Called when a ping goes out.
inherited
-
pingAnswered(
) → bool -
Whether the peer answered the last ping, asked when the next is due.
inherited
-
pongReceived(
) → void -
Records that the peer answered a ping.
inherited
-
sendBytes(
Uint8List b) → void -
Sends binary data to the connected peer.
inherited
-
sendClose(
int? code, String reason) → void -
Sends a close frame once.
inherited
-
sendFrame(
WebSocketOpcode opcode, Uint8List payload) → void -
Sends one frame to the peer.
override
-
sendText(
String s) → void -
Sends text data to the connected peer.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
tryClose(
[int? code, String? reason]) → Future< bool> -
Try to close the WebSocket connection and the events
Stream.inherited -
trySendBytes(
Uint8List b) → bool -
Sends binary data to the peer, unless connection is already
closed (either through close or by the peer). Returns
falseif connection is known to be closed, otherwisetrue.inherited -
trySendText(
String s) → bool -
Sends text data to the peer, unless connection is already
closed (either through close or by the peer). Returns
falseif connection is known to be closed, otherwisetrue.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- closeTimeout → const Duration
- How long a close waits for the peer's close frame, and then for the channel to flush.
- defaultMaxMessageSize → const int
- The largest message a peer may send unless the socket is given another limit.