Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | Private Attributes | List of all members
inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::clienthandler Class Reference

#include <RpcServer.hpp>

Public Member Functions

 clienthandler (int id_, std::unique_ptr< stream_type > &&stream_)
 
void request_read ()
 Start an asynchronous read. More...
 
const MSG_TYPE & get_read_result ()
 Get the message the last read spit out. More...
 
void write (const MSG_TYPE &msg)
 Add message to the queue of to-be-sent messages. More...
 
bool has_writes ()
 Whether or not writes are outstanding. More...
 
bool currently_writing ()
 
void request_send_one ()
 Send the next item from the queue, needs to be called only if the queue was empty in the last finished_send_one() and in case of a kick-off. More...
 
void finished_send_one ()
 Handle a completed write, send the next item if our queue isnt empty. More...
 
void request_disconnect ()
 Tell the client he gets disconnected. More...
 
void finished_disconnect ()
 Prints out any error info. More...
 

Public Attributes

int id
 The clients identifier number. More...
 

Private Attributes

std::unique_ptr< stream_typestream
 The stream we write into / receive data from (asynchronously). More...
 
MSG_TYPE read_buffer
 We read asynchronously into this and we always just read one at a time. More...
 
bool writer_busy = false
 There's always only one write allowed at a time. More...
 
std::queue< MSG_TYPE > outstanding_writes
 Keep a list of outstanding writes, since GRPC limits us to only one outstanding write per stream/client! More...
 
grpc::Status disconnect_status
 Did disconnecting work? If it didn't, why? More...
 

Constructor & Destructor Documentation

template<typename MSG_TYPE , typename ASYNC_SERVICE_TYPE >
inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::clienthandler::clienthandler ( int  id_,
std::unique_ptr< stream_type > &&  stream_ 
)
inline

Member Function Documentation

template<typename MSG_TYPE , typename ASYNC_SERVICE_TYPE >
bool inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::clienthandler::currently_writing ( )
inline
template<typename MSG_TYPE , typename ASYNC_SERVICE_TYPE >
void inexor::rpc::RpcServer< MSG_TYPE, U >::clienthandler::finished_disconnect ( )
inline

Prints out any error info.

References Log, and inexor::util::log_manager::sync.

template<typename MSG_TYPE , typename ASYNC_SERVICE_TYPE >
void inexor::rpc::RpcServer< MSG_TYPE, U >::clienthandler::finished_send_one ( )
inline

Handle a completed write, send the next item if our queue isnt empty.

Referenced by inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::handle_queue_event().

template<typename MSG_TYPE , typename ASYNC_SERVICE_TYPE >
const MSG_TYPE& inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::clienthandler::get_read_result ( )
inline
template<typename MSG_TYPE , typename ASYNC_SERVICE_TYPE >
bool inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::clienthandler::has_writes ( )
inline
template<typename MSG_TYPE , typename ASYNC_SERVICE_TYPE >
void inexor::rpc::RpcServer< MSG_TYPE, U >::clienthandler::request_disconnect ( )
inline
template<typename MSG_TYPE , typename ASYNC_SERVICE_TYPE >
void inexor::rpc::RpcServer< MSG_TYPE, U >::clienthandler::request_read ( )
inline

Start an asynchronous read.

The GRPC queue signals finished events with void* callbacks.

So we compress the needed info (EVENT_TYPE and the clients id) into one integer and cast it to void*.

References inexor::rpc::E_READ, inexor::rpc::encode_signal(), and inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::clienthandler::read_buffer.

Referenced by inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::handle_queue_event().

template<typename MSG_TYPE , typename ASYNC_SERVICE_TYPE >
void inexor::rpc::RpcServer< MSG_TYPE, U >::clienthandler::request_send_one ( )
inline

Send the next item from the queue, needs to be called only if the queue was empty in the last finished_send_one() and in case of a kick-off.

References inexor::rpc::E_WRITE, and inexor::rpc::encode_signal().

template<typename MSG_TYPE , typename ASYNC_SERVICE_TYPE >
void inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::clienthandler::write ( const MSG_TYPE &  msg)
inline

Add message to the queue of to-be-sent messages.

References inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::clienthandler::outstanding_writes.

Member Data Documentation

template<typename MSG_TYPE , typename ASYNC_SERVICE_TYPE >
grpc::Status inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::clienthandler::disconnect_status
private

Did disconnecting work? If it didn't, why?

template<typename MSG_TYPE , typename ASYNC_SERVICE_TYPE >
int inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::clienthandler::id
template<typename MSG_TYPE , typename ASYNC_SERVICE_TYPE >
std::queue<MSG_TYPE> inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::clienthandler::outstanding_writes
private

Keep a list of outstanding writes, since GRPC limits us to only one outstanding write per stream/client!

Referenced by inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::clienthandler::has_writes(), and inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::clienthandler::write().

template<typename MSG_TYPE , typename ASYNC_SERVICE_TYPE >
MSG_TYPE inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::clienthandler::read_buffer
private
template<typename MSG_TYPE , typename ASYNC_SERVICE_TYPE >
std::unique_ptr<stream_type> inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::clienthandler::stream
private

The stream we write into / receive data from (asynchronously).

template<typename MSG_TYPE , typename ASYNC_SERVICE_TYPE >
bool inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::clienthandler::writer_busy = false
private

There's always only one write allowed at a time.

Referenced by inexor::rpc::RpcServer< MSG_TYPE, ASYNC_SERVICE_TYPE >::clienthandler::currently_writing().


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