HTTP module
ws::ConnectionAdapter
WebSocket class which belongs to an HTTP connection.
ConnectionAdapter
#include <icy/http/websocket.h>
class ConnectionAdapterDefined in src/http/include/icy/http/websocket.h:396
- Inherits
WebSocketAdapter
List of all members
Inherited from WebSocketAdapter
| Kind | Name | Description |
|---|---|---|
friend | WebSocketFramer | |
variable | socket | Pointer to the underlying socket. Sent data will be proxied to this socket. |
function | WebSocketAdapter | Creates a WebSocketAdapter using the given socket, mode and HTTP message objects. |
function | send virtual override | Frames and sends data to the peer's address. |
function | send virtual override | Frames and sends data to a specific peer address (for UDP-backed sockets). |
function | sendOwned virtual override | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual override | |
function | shutdown virtual | Sends a WebSocket CLOSE frame with the given status code and message, then closes the underlying socket. |
function | sendClientRequest virtual | Client side. |
function | handleClientResponse virtual | Parses the server's HTTP upgrade response and completes the handshake. Any data remaining in the buffer after the HTTP response is re-fed as WebSocket frames. |
function | handleServerRequest virtual | Server side. |
function | onHandshakeComplete virtual | Called when the WebSocket handshake completes. Emits the connect event to downstream handlers. |
variable | framer | |
variable | _request | |
variable | _response | |
variable | _closeState | |
function | ~WebSocketAdapter virtual | |
function | sendControlFrame | |
function | resetFrameState | |
function | onSocketConnect virtual override | Called by the socket on connect; initiates the client handshake. |
function | onSocketRecv virtual override | Called by the socket on each received buffer; handles handshake or frame parsing depending on state. |
function | onSocketClose virtual override | Called by the socket on close; resets framer state. |
Inherited from SocketEmitter
| Kind | Name | Description |
|---|---|---|
variable | Connect | Signals that the socket is connected. |
variable | Recv | Signals when data is received by the socket. |
variable | Error | Signals that the socket is closed in error. This signal will be sent just before the Closed signal. |
variable | Close | Signals that the underlying socket is closed. |
variable | impl | Pointer to the underlying socket. Sent data will be proxied to this socket. |
function | SocketEmitter | Creates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver. |
function | SocketEmitter | Copy constructor; copies all signal connections and attaches to the same socket. |
function | ~SocketEmitter virtual noexcept | Destroys the SocketAdapter. |
function | addReceiver virtual override | Attaches a SocketAdapter as a receiver; wires it to all four socket signals. |
function | removeReceiver virtual override | Detaches a SocketAdapter from all four socket signals. |
function | swap virtual | Replaces the underlying socket with socket. |
function | as inline | Returns the underlying socket cast to type T, or nullptr if the cast fails. |
function | operator-> const inline | Returns a raw pointer to the underlying socket for direct method access. Follows shared_ptr semantics; the caller must not delete the returned pointer. |
function | onSocketConnect virtual override | Forwards the connect event to chained adapters, then fires the Connect signal. |
function | onSocketRecv virtual override | Forwards the recv event to chained adapters, then fires the Recv signal. |
function | onSocketError virtual override | Forwards the error event to chained adapters, then fires the Error signal. |
function | onSocketClose virtual override | Forwards the close event to chained adapters, then fires the Close signal. |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual | |
function | sendOwned virtual | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
variable | _dispatchDepth | |
function | cleanupReceivers virtual |
Public Methods
| Return | Name | Description |
|---|---|---|
ConnectionAdapter | Creates a ConnectionAdapter for upgrading an existing HTTP connection to WebSocket. Disables automatic header sending on the underlying connection. | |
~ConnectionAdapter virtual | ||
void | onHandshakeComplete virtual | Called when the WebSocket handshake completes. Emits the connect event via the socket emitter chain. |
ConnectionAdapter
ConnectionAdapter(Connection * connection, ws::Mode mode)Defined in src/http/include/icy/http/websocket.h:403
Creates a ConnectionAdapter for upgrading an existing HTTP connection to WebSocket. Disables automatic header sending on the underlying connection.
Parameters
| Parameter | Type | Description |
|---|---|---|
connection | Connection * | The HTTP connection to upgrade. |
mode | ws::Mode | ServerSide or ClientSide. |
~ConnectionAdapter
virtual
virtual ~ConnectionAdapter()Defined in src/http/include/icy/http/websocket.h:404
onHandshakeComplete
virtual
virtual void onHandshakeComplete()Defined in src/http/include/icy/http/websocket.h:408
Called when the WebSocket handshake completes. Emits the connect event via the socket emitter chain.
Reimplements
Protected Attributes
| Return | Name | Description |
|---|---|---|
Connection * | _connection |
_connection
Connection * _connectionType: Connection *
