#include <Pt/Http/WebSocketService.h>
WebSocket service for one session type.
Inherits WebSocketService.
Public Member Functions | |
| BasicWebSocketService () | |
| Default constructor. | |
| ~BasicWebSocketService () | |
| Destructor. | |
| const std::vector< std::string > & | protocols () const |
| Returns accepted Sec-WebSocket-Protocol names in preference order. | |
| void | addProtocol (const std::string &name) |
| Adds one accepted Sec-WebSocket-Protocol name. | |
| void | clearProtocols () |
| Drops every accepted protocol name. | |
| std::size_t | maxSockets () const |
| Returns the maximum number of live sessions. | |
| void | setMaxSockets (std::size_t n) |
| Sets the maximum number of live sessions. | |
| std::size_t | idleTimeout () const |
| Returns the idle timeout in milliseconds. | |
| void | setIdleTimeout (std::size_t ms) |
| Sets the idle timeout in milliseconds. | |
| std::size_t | pingInterval () const |
| Returns the ping interval in milliseconds. | |
| void | setPingInterval (std::size_t ms) |
| Sets the ping interval in milliseconds. | |
| std::size_t | pingTimeout () const |
| Returns the ping timeout in milliseconds. | |
| void | setPingTimeout (std::size_t ms) |
| Sets the ping timeout in milliseconds. | |
| std::size_t | closeTimeout () const |
| Returns the close timeout in milliseconds. | |
| void | setCloseTimeout (std::size_t ms) |
| Sets the close timeout in milliseconds. | |
| std::size_t | maxMessageSize () const |
| Returns the maximum data message size in bytes. | |
| void | setMaxMessageSize (std::size_t n) |
| Sets the maximum data message size in bytes. | |
| bool | hasServlet () const |
| True when a servlet is attached. | |
| std::size_t | socketCount () const |
| Returns the number of counted sessions. | |
| WebSocketSession * | getSession (Stream &stream, const Request &request, const Reply &reply) |
| Creates a session and counts a non-null result. | |
| void | releaseSession (WebSocketSession *session) |
| Releases a session created by getSession(). | |
| Responder * | getResponder (const Request &) |
| Creates a responder to handle request received by a server. | |
| void | releaseResponder (Responder *) |
| Destroys a responder created by a server. | |
Protected Member Functions | |
| virtual WebSocketSession * | onGetSession (Stream &stream, const Request &, const Reply &reply) |
| Creates the session for stream. | |
| virtual void | onReleaseSession (WebSocketSession *session) |
| Destroys a session created by onGetSession(). | |
| virtual Responder * | onGetResponder (const Request &) |
| Creates the handshake responder. | |
| virtual void | onReleaseResponder (Responder *responder) |
| Destroys the handshake responder. | |
| virtual void | onUpgrade (Stream &stream, const Request &request, const Reply &reply) final |
| Accepts or declines the upgraded stream. | |
|
protectedvirtual |
Called by getSession(). The active WebSocketServlet owns a non-null result. request is the opening request and reply is the opening reply. Both are valid for this call. Copy any header the session must keep. Return null to decline the upgrade. A null return is not counted.
Implements WebSocketService.
|
protectedvirtual |
Called by releaseSession() while this service is still fully constructed. The servlet has already removed the session from its list.
Implements WebSocketService.
|
inherited |
Names are matched in the order they were added. An empty list accepts the upgrade and selects no name.
| %std::invalid_argument | if name is empty or is not a single protocol token. |
|
inherited |
Zero means no limit. This is endpoint policy of this service. It applies before a servlet is constructed.
|
inherited |
A handshake above this limit is answered with 503. Zero means no limit. A missing servlet is still 503 when this limit is zero. This is endpoint policy of this service. It applies before a servlet is constructed.
|
inherited |
Zero means the idle timeout is disabled. This is endpoint policy of this service. It applies before a servlet is constructed.
|
inherited |
An accepted socket is closed after ms without an incoming frame. Incoming data, a received ping, and a received pong restart it. Sending does not. Zero disables it. This is endpoint policy of this service. It applies before a servlet is constructed.
|
inherited |
Zero means the engine does not write keepalive pings. This is endpoint policy of this service. It applies before a servlet is constructed.
|
inherited |
An accepted socket writes a keepalive ping after ms without an incoming frame. Incoming data, a received ping, and a received pong restart it. Sending does not. Zero disables it. This is endpoint policy of this service. It applies before a servlet is constructed.
|
inherited |
Zero means an unanswered ping has no deadline. This is endpoint policy of this service. It applies before a servlet is constructed.
|
inherited |
An accepted socket is closed if a ping is unanswered for ms. The wait starts at beginPing() and at a keepalive ping. Zero disables it. This is endpoint policy of this service. It applies before a servlet is constructed.
|
inherited |
Zero leaves a close handshake unbounded. The default is ten seconds. This is endpoint policy of this service. It applies before a servlet is constructed.
|
inherited |
An accepted socket is closed if a close handshake is unanswered for ms. Zero leaves the wait unbounded. The default is ten seconds. This is endpoint policy of this service. It applies before a servlet is constructed.
|
inherited |
Zero means the limit is disabled. This is endpoint policy of this service. It applies before a servlet is constructed.
|
inherited |
A larger data message closes the socket. Zero disables the limit. The count is the declared payload from the first data opcode to FIN. This is endpoint policy of this service. It applies before a servlet is constructed.
|
inherited |
A missing servlet is a separate state from a zero maxSockets().
|
inherited |
A session is counted when getSession() returns it, and dropped when releaseSession() releases it. A null return is not counted. Zero is not a reached limit. A missing servlet is a separate state, read with hasServlet().
|
inherited |
Calls onGetSession(). request is the opening request and reply is the opening reply. Both are valid until this call returns. A null return declines the upgrade and is not counted.
|
inherited |
Calls onReleaseSession() and drops the count. A null session is ignored. Called while this service is still fully constructed.