Home
HTTP module

ws::ConnectionAdapter

WebSocket class which belongs to an HTTP connection.

ConnectionAdapter

#include <icy/http/websocket.h>
class ConnectionAdapter

Defined in src/http/include/icy/http/websocket.h:395

Inherits: WebSocketAdapter

WebSocket class which belongs to an HTTP connection.

List of all members

NameKindOwner
ConnectionAdapterfunctionDeclared here
~ConnectionAdapterfunctionDeclared here
onHandshakeCompletefunctionDeclared here
_connectionvariableDeclared here
WebSocketFramerfriendInherited from WebSocketAdapter
socketvariableInherited from WebSocketAdapter
WebSocketAdapterfunctionInherited from WebSocketAdapter
sendfunctionInherited from WebSocketAdapter
sendfunctionInherited from WebSocketAdapter
sendOwnedfunctionInherited from WebSocketAdapter
sendOwnedfunctionInherited from WebSocketAdapter
shutdownfunctionInherited from WebSocketAdapter
sendClientRequestfunctionInherited from WebSocketAdapter
handleClientResponsefunctionInherited from WebSocketAdapter
handleServerRequestfunctionInherited from WebSocketAdapter
onHandshakeCompletefunctionInherited from WebSocketAdapter
framervariableInherited from WebSocketAdapter
_requestvariableInherited from WebSocketAdapter
_responsevariableInherited from WebSocketAdapter
_closeStatevariableInherited from WebSocketAdapter
~WebSocketAdapterfunctionInherited from WebSocketAdapter
sendControlFramefunctionInherited from WebSocketAdapter
resetFrameStatefunctionInherited from WebSocketAdapter
onSocketConnectfunctionInherited from WebSocketAdapter
onSocketRecvfunctionInherited from WebSocketAdapter
onSocketClosefunctionInherited from WebSocketAdapter
ConnectvariableInherited from SocketEmitter
RecvvariableInherited from SocketEmitter
ErrorvariableInherited from SocketEmitter
ClosevariableInherited from SocketEmitter
implvariableInherited from SocketEmitter
SocketEmitterfunctionInherited from SocketEmitter
SocketEmitterfunctionInherited from SocketEmitter
~SocketEmitterfunctionInherited from SocketEmitter
addReceiverfunctionInherited from SocketEmitter
removeReceiverfunctionInherited from SocketEmitter
swapfunctionInherited from SocketEmitter
asfunctionInherited from SocketEmitter
operator->functionInherited from SocketEmitter
onSocketConnectfunctionInherited from SocketEmitter
onSocketRecvfunctionInherited from SocketEmitter
onSocketErrorfunctionInherited from SocketEmitter
onSocketClosefunctionInherited from SocketEmitter
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from WebSocketAdapter

KindNameDescription
friendWebSocketFramer
variablesocketPointer to the underlying socket. Sent data will be proxied to this socket.
functionWebSocketAdapterCreates a WebSocketAdapter using the given socket, mode and HTTP message objects.
functionsend virtual overrideFrames and sends data to the peer's address.
functionsend virtual overrideFrames and sends data to a specific peer address (for UDP-backed sockets).
functionsendOwned virtual overrideSends an owned payload buffer to the connected peer.
functionsendOwned virtual override
functionshutdown virtualSends a WebSocket CLOSE frame with the given status code and message, then closes the underlying socket.
functionsendClientRequest virtualClient side.
functionhandleClientResponse virtualParses 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.
functionhandleServerRequest virtualServer side.
functiononHandshakeComplete virtualCalled when the WebSocket handshake completes. Emits the connect event to downstream handlers.
variableframer
variable_request
variable_response
variable_closeState
function~WebSocketAdapter virtual
functionsendControlFrame
functionresetFrameState
functiononSocketConnect virtual overrideCalled by the socket on connect; initiates the client handshake.
functiononSocketRecv virtual overrideCalled by the socket on each received buffer; handles handshake or frame parsing depending on state.
functiononSocketClose virtual overrideCalled by the socket on close; resets framer state.

Inherited from SocketEmitter

KindNameDescription
variableConnectSignals that the socket is connected.
variableRecvSignals when data is received by the socket.
variableErrorSignals that the socket is closed in error. This signal will be sent just before the Closed signal.
variableCloseSignals that the underlying socket is closed.
variableimplPointer to the underlying socket. Sent data will be proxied to this socket.
functionSocketEmitterCreates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver.
functionSocketEmitterCopy constructor; copies all signal connections and attaches to the same socket.
function~SocketEmitter virtual noexceptDestroys the SocketAdapter.
functionaddReceiver virtual overrideAttaches a SocketAdapter as a receiver; wires it to all four socket signals.
functionremoveReceiver virtual overrideDetaches a SocketAdapter from all four socket signals.
functionswap virtualReplaces the underlying socket with socket.
functionas inlineReturns the underlying socket cast to type T, or nullptr if the cast fails.
functionoperator-> const inlineReturns a raw pointer to the underlying socket for direct method access. Follows shared_ptr semantics; the caller must not delete the returned pointer.
functiononSocketConnect virtual overrideForwards the connect event to chained adapters, then fires the Connect signal.
functiononSocketRecv virtual overrideForwards the recv event to chained adapters, then fires the Recv signal.
functiononSocketError virtual overrideForwards the error event to chained adapters, then fires the Error signal.
functiononSocketClose virtual overrideForwards the close event to chained adapters, then fires the Close signal.

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtualSends 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.
functionsend virtual
functionsendOwned virtualSends an owned payload buffer to the connected peer.
functionsendOwned virtual
functionsendPacket virtualSends 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.
functionsendPacket virtual
functionsendPacket virtualSends 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.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled 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.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Public Methods

ReturnNameDescription
ConnectionAdapterCreates a ConnectionAdapter for upgrading an existing HTTP connection to WebSocket. Disables automatic header sending on the underlying connection.
voidonHandshakeComplete virtualCalled 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:402

Creates a ConnectionAdapter for upgrading an existing HTTP connection to WebSocket. Disables automatic header sending on the underlying connection.

Parameters

  • connection The HTTP connection to upgrade.

  • mode ServerSide or ClientSide.


onHandshakeComplete

virtual

virtual void onHandshakeComplete()

Defined in src/http/include/icy/http/websocket.h:407

Called when the WebSocket handshake completes. Emits the connect event via the socket emitter chain.

Reimplements

Protected Attributes

ReturnNameDescription
Connection *_connection

_connection

Connection * _connection

Defined in src/http/include/icy/http/websocket.h:410