#include <connection.hpp>
Public Types | |
typedef connection< config > | type |
Type of this connection transport component. More... | |
typedef lib::shared_ptr< type > | ptr |
Type of a shared pointer to this connection transport component. More... | |
typedef config::concurrency_type | concurrency_type |
transport concurrency policy More... | |
typedef config::alog_type | alog_type |
Type of this transport's access logging policy. More... | |
typedef config::elog_type | elog_type |
Type of this transport's error logging policy. More... | |
typedef concurrency_type::scoped_lock_type | scoped_lock_type |
typedef concurrency_type::mutex_type | mutex_type |
typedef lib::shared_ptr< timer > | timer_ptr |
Public Member Functions | |
connection (bool is_server, const lib::shared_ptr< alog_type > &alog, const lib::shared_ptr< elog_type > &elog) | |
ptr | get_shared () |
Get a shared pointer to this component. More... | |
void | set_secure (bool) |
Set whether or not this connection is secure. More... | |
bool | is_secure () const |
Tests whether or not the underlying transport is secure. More... | |
void | set_uri (uri_ptr) |
Set uri hook. More... | |
void | set_remote_endpoint (std::string) |
Set human readable remote endpoint address. More... | |
std::string | get_remote_endpoint () const |
Get human readable remote endpoint address. More... | |
connection_hdl | get_handle () const |
Get the connection handle. More... | |
timer_ptr | set_timer (long, timer_handler handler) |
Call back a function after a period of time. More... | |
size_t | read_all (char const *buf, size_t len) |
Manual input supply (read all) More... | |
void | expire_timer (lib::error_code const &ec) |
void | fullfil_write () |
Protected Member Functions | |
void | init (init_handler handler) |
Initialize the connection transport. More... | |
void | async_read_at_least (size_t num_bytes, char *buf, size_t len, read_handler handler) |
Initiate an async_read for at least num_bytes bytes into buf. More... | |
void | async_write (char const *, size_t, write_handler handler) |
Asyncronous Transport Write. More... | |
void | async_write (std::vector< buffer > const &, write_handler handler) |
Asyncronous Transport Write (scatter-gather) More... | |
void | set_handle (connection_hdl) |
Set Connection Handle. More... | |
lib::error_code | dispatch (dispatch_handler handler) |
Call given handler back within the transport's event system (if present) More... | |
void | async_shutdown (shutdown_handler handler) |
Perform cleanup on socket shutdown_handler. More... | |
size_t | read_some_impl (char const *buf, size_t len) |
void | complete_read (lib::error_code const &ec) |
Signal that a requested read is complete. More... | |
Definition at line 56 of file connection.hpp.
typedef connection<config> websocketpp::transport::debug::connection< config >::type |
Type of this connection transport component.
Definition at line 59 of file connection.hpp.
typedef lib::shared_ptr<type> websocketpp::transport::debug::connection< config >::ptr |
Type of a shared pointer to this connection transport component.
Definition at line 61 of file connection.hpp.
typedef config::concurrency_type websocketpp::transport::debug::connection< config >::concurrency_type |
transport concurrency policy
Definition at line 64 of file connection.hpp.
typedef config::alog_type websocketpp::transport::debug::connection< config >::alog_type |
Type of this transport's access logging policy.
Definition at line 66 of file connection.hpp.
typedef config::elog_type websocketpp::transport::debug::connection< config >::elog_type |
Type of this transport's error logging policy.
Definition at line 68 of file connection.hpp.
typedef concurrency_type::scoped_lock_type websocketpp::transport::debug::connection< config >::scoped_lock_type |
Definition at line 71 of file connection.hpp.
typedef concurrency_type::mutex_type websocketpp::transport::debug::connection< config >::mutex_type |
Definition at line 72 of file connection.hpp.
typedef lib::shared_ptr<timer> websocketpp::transport::debug::connection< config >::timer_ptr |
Definition at line 74 of file connection.hpp.
|
inlineexplicit |
Definition at line 76 of file connection.hpp.
References websocketpp::log::alevel::devel.
|
inline |
Get a shared pointer to this component.
Definition at line 83 of file connection.hpp.
|
inline |
Set whether or not this connection is secure.
Todo: docs
value | Whether or not this connection is secure. |
Definition at line 95 of file connection.hpp.
|
inline |
Tests whether or not the underlying transport is secure.
TODO: docs
Definition at line 103 of file connection.hpp.
|
inline |
Set uri hook.
Called by the endpoint as a connection is being established to provide the uri being connected to to the transport layer.
Implementation is optional and can be ignored if the transport has no need for this information.
u | The uri to set |
Definition at line 119 of file connection.hpp.
|
inline |
Set human readable remote endpoint address.
Sets the remote endpoint address returned by get_remote_endpoint
. This value should be a human readable string that describes the remote endpoint. Typically an IP address or hostname, perhaps with a port. But may be something else depending on the nature of the underlying transport.
If none is set a default is returned.
value | The remote endpoint address to set. |
Definition at line 135 of file connection.hpp.
|
inline |
Get human readable remote endpoint address.
TODO: docs
This value is used in access and error logs and is available to the end application for including in user facing interfaces and messages.
Definition at line 146 of file connection.hpp.
|
inline |
Get the connection handle.
Definition at line 154 of file connection.hpp.
|
inline |
Call back a function after a period of time.
Timers are not implemented in this transport. The timer pointer will always be empty. The handler will never be called.
duration | Length of time to wait in milliseconds |
callback | The function to call back when the timer has expired |
Definition at line 168 of file connection.hpp.
References websocketpp::log::alevel::devel.
|
inline |
Manual input supply (read all)
Similar to read_some, but continues to read until all bytes in the supplied buffer have been read or the connection runs out of read requests.
This method still may not read all of the bytes in the input buffer. if it doesn't it indicates that the connection was most likely closed or is in an error state where it is no longer accepting new input.
buf | Char buffer to read into the websocket |
len | Length of buf |
Definition at line 190 of file connection.hpp.
|
inline |
Definition at line 203 of file connection.hpp.
|
inline |
Definition at line 207 of file connection.hpp.
|
inlineprotected |
Initialize the connection transport.
Initialize the connection's transport component.
handler | The init_handler to call when initialization is done |
Definition at line 217 of file connection.hpp.
References websocketpp::log::alevel::devel.
|
inlineprotected |
Initiate an async_read for at least num_bytes bytes into buf.
Initiates an async_read request for at least num_bytes bytes. The input will be read into buf. A maximum of len bytes will be input. When the operation is complete, handler will be called with the status and number of bytes read.
This method may or may not call handler from within the initial call. The application should be prepared to accept either.
The application should never call this method a second time before it has been called back for the first read. If this is done, the second read will be called back immediately with a double_read error.
If num_bytes or len are zero handler will be called back immediately indicating success.
num_bytes | Don't call handler until at least this many bytes have been read. |
buf | The buffer to read bytes into |
len | The size of buf. At maximum, this many bytes will be read. |
handler | The callback to invoke when the operation is complete or ends in an error |
Definition at line 246 of file connection.hpp.
References websocketpp::log::alevel::devel, websocketpp::transport::debug::error::double_read, websocketpp::transport::debug::error::invalid_num_bytes, and websocketpp::transport::error::make_error_code().
|
inlineprotected |
Asyncronous Transport Write.
Write len bytes in buf to the output stream. Call handler to report success or failure. handler may or may not be called during async_write, but it must be safe for this to happen.
Will return 0 on success.
buf | buffer to read bytes from |
len | number of bytes to write |
handler | Callback to invoke with operation status. |
Definition at line 288 of file connection.hpp.
References websocketpp::log::alevel::devel.
|
inlineprotected |
Asyncronous Transport Write (scatter-gather)
Write a sequence of buffers to the output stream. Call handler to report success or failure. handler may or may not be called during async_write, but it must be safe for this to happen.
Will return 0 on success.
bufs | vector of buffers to write |
handler | Callback to invoke with operation status. |
Definition at line 304 of file connection.hpp.
References websocketpp::log::alevel::devel.
|
inlineprotected |
|
inlineprotected |
Call given handler back within the transport's event system (if present)
Invoke a callback within the transport's event system if it has one. If it doesn't, the handler will be invoked immediately before this function returns.
handler | The callback to invoke |
Definition at line 326 of file connection.hpp.
|
inlineprotected |
Perform cleanup on socket shutdown_handler.
h | The shutdown_handler to call back when complete |
Definition at line 335 of file connection.hpp.
|
inlineprotected |
Definition at line 339 of file connection.hpp.
References websocketpp::log::elevel::devel, and websocketpp::log::alevel::devel.
|
inlineprotected |
Signal that a requested read is complete.
Sets the reading flag to false and returns the handler that should be called back with the result of the read. The cursor position that is sent is whatever the value of m_cursor is.
It MUST NOT be called when m_reading is false. it MUST be called while holding the read lock
It is important to use this method rather than directly setting/calling m_read_handler back because this function makes sure to delete the locally stored handler which contains shared pointers that will otherwise cause circular reference based memory leaks.
ec | The error code to forward to the read handler |
Definition at line 376 of file connection.hpp.