com.Tivadar.Best.WebSockets
Interface for websocket-extension implementations.
This is the first pass: here we can add headers to the request to initiate an extension negotiation.
If the websocket upgrade succeded it will call this function to be able to parse the server's negotiation
response. Inside this function the IsEnabled should be set.
This function should return a new header flag based on the inFlag parameter. The extension should set only the
Rsv1-3 bits in the header.
This function will be called to be able to transform the data that will be sent to the server.
This function can be used the decode the server-sent data.
Compression Extensions for WebSocket implementation.
http://tools.ietf.org/html/rfc7692
By including this extension parameter in an extension negotiation offer, a client informs the peer server
of a hint that even if the server doesn't include the "client_no_context_takeover" extension parameter in
the corresponding extension negotiation response to the offer, the client is not going to use context takeover.
By including this extension parameter in an extension negotiation offer, a client prevents the peer server from using context takeover.
This parameter indicates the base-2 logarithm of the LZ77 sliding window size of the client context.
This parameter indicates the base-2 logarithm of the LZ77 sliding window size of the server context.
The compression level that the client will use to compress the frames.
What minimum data length will trigger the compression.
Cached object to support context takeover.
Cached object to support context takeover.
This will start the permessage-deflate negotiation process.
IExtension implementation to set the Rsv1 flag in the header if we are we will want to compress the data
in the writer.
IExtension implementation to be able to compress the data hold in the writer.
IExtension implementation to possible decompress the data.
A function to compress and return the data parameter with possible context takeover support (reusing the DeflateStream).
A function to decompress and return the data parameter with possible context takeover support (reusing the DeflateStream).
Denotes a binary frame. The "Payload data" is arbitrary binary data whose interpretation is solely up to the application layer.
This is the base class of all other frame writers, as all frame can be represented as a byte array.
Represents an incoming WebSocket Frame.
True if it's a final Frame in a sequence, or the only one.
The type of the Frame.
The decoded array of bytes.
Textual representation of the received Data.
Assembles all fragments into a final frame. Call this on the last fragment of a frame.
The list of previously downloaded and parsed fragments of the frame
This function will decode the received data incrementally with the associated websocket's extensions.
Enumeration for possible WebSocket frame types.
A fragmented message's first frame's contain the type of the message(binary or text), all consecutive frame of that message must be a Continuation frame.
Last of these frame's Fin bit must be 1.
For a text message sent as three fragments, the first fragment would have an opcode of 0x1 (text) and a FIN bit clear,
the second fragment would have an opcode of 0x0 (Continuation) and a FIN bit clear,
and the third fragment would have an opcode of 0x0 (Continuation) and a FIN bit that is set.
The Close frame MAY contain a body (the "Application data" portion of the frame) that indicates a reason for closing,
such as an endpoint shutting down, an endpoint having received a frame too large, or an endpoint having received a frame that
does not conform to the format expected by the endpoint.
As the data is not guaranteed to be human readable, clients MUST NOT show it to end users.
The Ping frame contains an opcode of 0x9. A Ping frame MAY include "Application data".
A Pong frame sent in response to a Ping frame must have identical "Application data" as found in the message body of the Ping frame being replied to.
Implements WebSocket communication through an HTTP/1 connection.
Indicates whether we sent out the connection request to the server.
Implements RFC 8441 (https://tools.ietf.org/html/rfc8441) to use Websocket over HTTP/2
Next interaction relative to *now*.
States of the underlying implementation's state.
Abstract class for concrete websocket communication implementations.
Capacity of the RTT buffer where the latencies are kept.
A circular buffer to store the last N rtt times calculated by the pong messages.
When we sent out the last ping.
True if we sent out a Close message to the server
It will send the given frame to the server.
Implements the WebSocket standard for duplex, two-way communications.
Maximum payload size of a websocket frame. Its default value is 32 KiB.
The connection to the WebSocket server is open.
Data waiting to be written to the wire.
Set to true to start sending Ping frames to the WebSocket server.
The delay between two Pings in milliseconds. Minimum value is 100ms, default is 10 seconds.
If set to true, the plugin will close the connection and emit an event if no
message is received from the server in the given time. Its default value is 2 sec.
The internal object.
implementations the plugin will negotiate with the server to use.
Latency calculated from ping-pong message round-trip times.
When the WebSocket instance received the last message from the server.
When the Websocket Over HTTP/2 implementation fails to connect and . is true, the plugin tries to fall back to the HTTP/1 implementation.
When this happens a new is created and all previous custom modifications (like added headers) are lost. With OnInternalRequestCreated these modifications can be reapplied.
Called when the connection to the WebSocket server is established.
Called when a new textual message is received from the server.
Called when a Binary message received.
The content of the must be used or copied to a new array in the callbacks because the plugin reuses the memory immediately after the callback by placing it back to the !
Note that the memory will be reused when this event returns. Either process it in this call or make a copy from the received data.
Called when the WebSocket connection is closed.
Logging context of this websocket instance.
The underlying, real implementation.
Creates a WebSocket instance from the given uri.
The uri of the WebSocket server
Creates a WebSocket instance from the given uri.
Uri of the WebSocket endpoint.
Where the WebSocket originating from.
The application-level protocol that the client want to use(eg. "chat", "leaderboard", etc.). Can be null or empty string if not used.
Creates a WebSocket instance from the given uri, protocol and origin.
The uri of the WebSocket server
Servers that are not intended to process input from any web page but only for certain sites SHOULD verify the |Origin| field is an origin they expect.
If the origin indicated is unacceptable to the server, then it SHOULD respond to the WebSocket handshake with a reply containing HTTP 403 Forbidden status code.
The application-level protocol that the client want to use(eg. "chat", "leaderboard", etc.). Can be null or empty string if not used.
Optional implementations
Start the opening process.
It's a non-blocking call. To get notified when the WebSocket instance is considered open and can send/receive, use the event.
It will send the given textual message to the remote server.
It will send the given binary message to the remote server.
It will send the given binary message to the remote server.
Will send the data in one or more binary frame and takes ownership over it calling BufferPool.Release when the data sent.
Will send data as a text frame and takes owenership over the memory region releasing it to the BufferPool as soon as possible.
It will initiate the closing of the connection to the server.
It will initiate the closing of the connection to the server sending the given code and message.
Indicates a normal closure, meaning that the purpose for which the connection was established has been fulfilled.
Indicates that an endpoint is "going away", such as a server going down or a browser having navigated away from a page.
Indicates that an endpoint is terminating the connection due to a protocol error.
Indicates that an endpoint is terminating the connection because it has received a type of data it cannot accept
(e.g., an endpoint that understands only text data MAY send this if it receives a binary message).
Reserved. The specific meaning might be defined in the future.
A reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint.
It is designated for use in applications expecting a status code to indicate that no status code was actually present.
A reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint.
It is designated for use in applications expecting a status code to indicate that the connection was closed abnormally, e.g., without sending or receiving a Close control frame.
Indicates that an endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [RFC3629] data within a text message).
Indicates that an endpoint is terminating the connection because it has received a message that violates its policy.
This is a generic status code that can be returned when there is no other more suitable status code (e.g., 1003 or 1009) or if there is a need to hide specific details about the policy.
Indicates that an endpoint is terminating the connection because it has received a message that is too big for it to process.
Indicates that an endpoint (client) is terminating the connection because it has expected the server to negotiate one or more extension,
but the server didn't return them in the response message of the WebSocket handshake.
The list of extensions that are needed SHOULD appear in the /reason/ part of the Close frame. Note that this status code is not used by the server, because it can fail the WebSocket handshake instead.
Indicates that a server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.
A reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint. It is designated for use in applications expecting a status code to indicate that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified).
Data is UTF-8 encoded strings