Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
websocketpp::server< config > Class Template Reference

Server endpoint role based on the given config. More...

#include <server_endpoint.hpp>

Inheritance diagram for websocketpp::server< config >:
Collaboration diagram for websocketpp::server< config >:

Public Types

typedef server< configtype
 Type of this endpoint.
 
typedef config::concurrency_type concurrency_type
 Type of the endpoint concurrency component.
 
typedef config::transport_type transport_type
 Type of the endpoint transport component.
 
typedef connection< configconnection_type
 Type of the connections this server will create.
 
typedef connection_type::ptr connection_ptr
 Type of a shared pointer to the connections this server will create.
 
typedef transport_type::transport_con_type transport_con_type
 Type of the connection transport component.
 
typedef transport_con_type::ptr transport_con_ptr
 Type of a shared pointer to the connection transport component.
 
typedef endpoint< connection_type, configendpoint_type
 Type of the endpoint component of this server.
 
- Public Types inherited from websocketpp::endpoint< connection< config >, config >
typedef endpoint< connection, configtype
 
typedef config::transport_type transport_type
 Type of the transport component of this endpoint.
 
typedef config::concurrency_type concurrency_type
 Type of the concurrency component of this endpoint.
 
typedef connection connection_type
 Type of the connections that this endpoint creates.
 
typedef connection_type::ptr connection_ptr
 Shared pointer to connection_type.
 
typedef connection_type::weak_ptr connection_weak_ptr
 Weak pointer to connection type.
 
typedef transport_type::transport_con_type transport_con_type
 
typedef transport_con_type::ptr transport_con_ptr
 
typedef connection_type::message_handler message_handler
 Type of message_handler.
 
typedef connection_type::message_ptr message_ptr
 Type of message pointers that this endpoint uses.
 
typedef config::elog_type elog_type
 Type of error logger.
 
typedef config::alog_type alog_type
 Type of access logger.
 
typedef concurrency_type::scoped_lock_type scoped_lock_type
 Type of our concurrency policy's scoped lock object.
 
typedef concurrency_type::mutex_type mutex_type
 Type of our concurrency policy's mutex object.
 
typedef config::rng_type rng_type
 Type of RNG.
 
typedef connection_type::termination_handler termination_handler
 

Public Member Functions

 server ()
 
 ~server ()
 Destructor.
 
connection_ptr get_connection ()
 Create and initialize a new connection.
 
void start_accept (lib::error_code &ec)
 Starts the server's async connection acceptance loop (exception free)
 
void start_accept ()
 Starts the server's async connection acceptance loop.
 
void handle_accept (connection_ptr con, lib::error_code const &ec)
 Handler callback for start_accept.
 
- Public Member Functions inherited from websocketpp::endpoint< connection< config >, config >
 endpoint (bool p_is_server)
 
 ~endpoint ()
 Destructor.
 
std::string get_user_agent () const
 Returns the user agent string that this endpoint will use.
 
void set_user_agent (std::string const &ua)
 Sets the user agent string that this endpoint will use.
 
bool is_server () const
 Returns whether or not this endpoint is a server.
 
void set_access_channels (log::level channels)
 Set Access logging channel.
 
void clear_access_channels (log::level channels)
 Clear Access logging channels.
 
void set_error_channels (log::level channels)
 Set Error logging channel.
 
void clear_error_channels (log::level channels)
 Clear Error logging channels.
 
alog_typeget_alog ()
 Get reference to access logger.
 
elog_typeget_elog ()
 Get reference to error logger.
 
void set_open_handler (open_handler h)
 
void set_close_handler (close_handler h)
 
void set_fail_handler (fail_handler h)
 
void set_ping_handler (ping_handler h)
 
void set_pong_handler (pong_handler h)
 
void set_pong_timeout_handler (pong_timeout_handler h)
 
void set_interrupt_handler (interrupt_handler h)
 
void set_http_handler (http_handler h)
 
void set_validate_handler (validate_handler h)
 
void set_message_handler (message_handler h)
 
void set_open_handshake_timeout (long dur)
 Set open handshake timeout.
 
void set_close_handshake_timeout (long dur)
 Set close handshake timeout.
 
void set_pong_timeout (long dur)
 Set pong timeout.
 
size_t get_max_message_size () const
 Get default maximum message size.
 
void set_max_message_size (size_t new_value)
 Set default maximum message size.
 
size_t get_max_http_body_size () const
 Get maximum HTTP message body size.
 
void set_max_http_body_size (size_t new_value)
 Set maximum HTTP message body size.
 
void interrupt (connection_hdl hdl, lib::error_code &ec)
 
void interrupt (connection_hdl hdl)
 
void pause_reading (connection_hdl hdl, lib::error_code &ec)
 Pause reading of new data (exception free)
 
void pause_reading (connection_hdl hdl)
 Pause reading of new data.
 
void resume_reading (connection_hdl hdl, lib::error_code &ec)
 Resume reading of new data (exception free)
 
void resume_reading (connection_hdl hdl)
 Resume reading of new data.
 
void send_http_response (connection_hdl hdl, lib::error_code &ec)
 Send deferred HTTP Response.
 
void send_http_response (connection_hdl hdl)
 Send deferred HTTP Response (exception free)
 
void send (connection_hdl hdl, std::string const &payload, frame::opcode::value op, lib::error_code &ec)
 Create a message and add it to the outgoing send queue (exception free)
 
void send (connection_hdl hdl, std::string const &payload, frame::opcode::value op)
 Create a message and add it to the outgoing send queue.
 
void send (connection_hdl hdl, void const *payload, size_t len, frame::opcode::value op, lib::error_code &ec)
 
void send (connection_hdl hdl, void const *payload, size_t len, frame::opcode::value op)
 
void send (connection_hdl hdl, message_ptr msg, lib::error_code &ec)
 
void send (connection_hdl hdl, message_ptr msg)
 
void close (connection_hdl hdl, close::status::value const code, std::string const &reason, lib::error_code &ec)
 
void close (connection_hdl hdl, close::status::value const code, std::string const &reason)
 
void ping (connection_hdl hdl, std::string const &payload, lib::error_code &ec)
 Send a ping to a specific connection.
 
void ping (connection_hdl hdl, std::string const &payload)
 Send a ping to a specific connection.
 
void pong (connection_hdl hdl, std::string const &payload, lib::error_code &ec)
 Send a pong to a specific connection.
 
void pong (connection_hdl hdl, std::string const &payload)
 Send a pong to a specific connection.
 
connection_ptr get_con_from_hdl (connection_hdl hdl, lib::error_code &ec)
 Retrieves a connection_ptr from a connection_hdl (exception free)
 
connection_ptr get_con_from_hdl (connection_hdl hdl)
 Retrieves a connection_ptr from a connection_hdl (exception version)
 

Friends

class connection< config >
 

Additional Inherited Members

- Protected Member Functions inherited from websocketpp::endpoint< connection< config >, config >
connection_ptr create_connection ()
 
- Protected Attributes inherited from websocketpp::endpoint< connection< config >, config >
alog_type m_alog
 
elog_type m_elog
 

Detailed Description

template<typename config>
class websocketpp::server< config >

Definition at line 44 of file server_endpoint.hpp.

Member Typedef Documentation

◆ concurrency_type

template<typename config >
config::concurrency_type websocketpp::server< config >::concurrency_type

Definition at line 50 of file server_endpoint.hpp.

◆ connection_ptr

◆ connection_type

template<typename config >
connection<config> websocketpp::server< config >::connection_type

Definition at line 55 of file server_endpoint.hpp.

◆ endpoint_type

template<typename config >
endpoint<connection_type,config> websocketpp::server< config >::endpoint_type

Definition at line 65 of file server_endpoint.hpp.

◆ transport_con_ptr

template<typename config >
transport_con_type::ptr websocketpp::server< config >::transport_con_ptr

Definition at line 62 of file server_endpoint.hpp.

◆ transport_con_type

template<typename config >
transport_type::transport_con_type websocketpp::server< config >::transport_con_type

Definition at line 60 of file server_endpoint.hpp.

◆ transport_type

template<typename config >
config::transport_type websocketpp::server< config >::transport_type

Definition at line 52 of file server_endpoint.hpp.

◆ type

template<typename config >
server<config> websocketpp::server< config >::type

Definition at line 47 of file server_endpoint.hpp.

Constructor & Destructor Documentation

◆ server()

template<typename config >
websocketpp::server< config >::server ( )
inlineexplicit

Definition at line 69 of file server_endpoint.hpp.

69 : endpoint_type(true)
70 {
71 endpoint_type::m_alog.write(log::alevel::devel, "server constructor");
72 }
endpoint< connection_type, config > endpoint_type
Type of the endpoint component of this server.
static level const devel
Development messages (warning: very chatty)
Definition levels.hpp:141

◆ ~server()

template<typename config >
websocketpp::server< config >::~server ( )
inline

Definition at line 69 of file server_endpoint.hpp.

75{}

Member Function Documentation

◆ get_connection()

template<typename config >
connection_ptr websocketpp::server< config >::get_connection ( )
inline

The connection will be initialized and ready to begin. Call its start() method to begin the processing loop.

Note: The connection must either be started or terminated using connection::terminate in order to avoid memory leaks.

Returns
A pointer to the new connection.

Definition at line 106 of file server_endpoint.hpp.

106 {
108 }
connection_ptr create_connection()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_accept()

template<typename config >
void websocketpp::server< config >::handle_accept ( connection_ptr con,
lib::error_code const & ec )
inline

Definition at line 161 of file server_endpoint.hpp.

161 {
162 if (ec) {
163 con->terminate(ec);
164
165 if (ec == error::operation_canceled) {
167 "handle_accept error: "+ec.message());
168 } else {
170 "handle_accept error: "+ec.message());
171 }
172 } else {
173 con->start();
174 }
175
176 lib::error_code start_ec;
177 start_accept(start_ec);
178 if (start_ec == error::async_accept_not_listening) {
180 "Stopping acceptance of new connections because the underlying transport is no longer listening.");
181 } else if (start_ec) {
183 "Restarting async_accept loop failed: "+ec.message());
184 }
185 }
void start_accept()
Starts the server's async connection acceptance loop.
@ operation_canceled
The requested operation was canceled.
Definition error.hpp:127
static level const info
Definition levels.hpp:69
static level const rerror
Definition levels.hpp:75
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_accept() [1/2]

template<typename config >
void websocketpp::server< config >::start_accept ( )
inline

Initiates the server connection acceptance loop. Must be called after listen. This method will have no effect until the underlying io_service starts running. It may be called after the io_service is already running.

Refer to documentation for the transport policy you are using for instructions on how to stop this acceptance loop.

Definition at line 152 of file server_endpoint.hpp.

152 {
153 lib::error_code ec;
154 start_accept(ec);
155 if (ec) {
156 throw exception(ec);
157 }
158 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_accept() [2/2]

template<typename config >
void websocketpp::server< config >::start_accept ( lib::error_code & ec)
inline

Initiates the server connection acceptance loop. Must be called after listen. This method will have no effect until the underlying io_service starts running. It may be called after the io_service is already running.

Refer to documentation for the transport policy you are using for instructions on how to stop this acceptance loop.

Parameters
[out]ecA status code indicating an error, if any.

Definition at line 121 of file server_endpoint.hpp.

121 {
122 if (!transport_type::is_listening()) {
124 return;
125 }
126
127 ec = lib::error_code();
129
130 transport_type::async_accept(
131 lib::static_pointer_cast<transport_con_type>(con),
132 lib::bind(&type::handle_accept,this,con,lib::placeholders::_1),
133 ec
134 );
135
136 if (ec && con) {
137 // If the connection was constructed but the accept failed,
138 // terminate the connection to prevent memory leaks
139 con->terminate(lib::error_code());
140 }
141 }
connection_ptr get_connection()
Create and initialize a new connection.
void handle_accept(connection_ptr con, lib::error_code const &ec)
Handler callback for start_accept.
client::connection_ptr connection_ptr
lib::error_code make_error_code(error::value e)
Definition error.hpp:235
Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ connection< config >

template<typename config >
friend class connection< config >
friend

Definition at line 65 of file server_endpoint.hpp.


The documentation for this class was generated from the following file: