betabugs::networking::thrift_asio_connection_management_mixin< ClientType > Class Template Reference
#include <thrift_asio_connection_management_mixin.hpp>
Public Member Functions | |
| virtual void | on_client_connected (boost::shared_ptr< apache::thrift::protocol::TProtocol > output_protocol) |
| creates a ClientType objects and inserts it into clients_ | |
| virtual void | on_client_disconnected (const boost::shared_ptr< apache::thrift::protocol::TProtocol > &output_protocol, const boost::system::error_code &ec) |
| erases the client associated with output_protocol from clients_ | |
| virtual void | before_process (boost::shared_ptr< apache::thrift::protocol::TProtocol > output_protocol) |
| sets client associated with output_protocol as the current_client_ | |
| virtual void | after_process () |
| sets the current_client_ to zero | |
Protected Types | |
|
typedef boost::shared_ptr < apache::thrift::protocol::TProtocol > | protocol_ptr |
| used as key_type in the client_map | |
|
typedef std::shared_ptr < ClientType > | client_ptr |
| used as mapped_type in the client_map | |
|
typedef std::map< protocol_ptr, client_ptr > | client_map |
| maps protocol instances to clients | |
Protected Attributes | |
| client_map | clients_ |
| All connected clients. | |
| client_ptr | current_client_ |
| Only valid while a request is processed. | |
Detailed Description
template<typename ClientType>
class betabugs::networking::thrift_asio_connection_management_mixin< ClientType >
This class provides management of connected clients. This is the easiest way to get access to all connected clients.
inherit your server side handler from this class to get access to the connected clients and the current client
- Template Parameters
-
ClientType the client to create out of the output_protocol. If you want other session data, you can wrap the auto-generted client into your own custom class that takes a boost::shared_ptr<apache::thrift::protocol::TProtocol> as the first and only argument
to respond to the current client:
current_client_->on_fancy_result_computed(42);
to broadcast a message to all clients:
- Examples:
- example_server.cpp.
The documentation for this class was generated from the following file:
