packio
Public Types | Public Member Functions | Static Public Attributes | List of all members
packio::client< Rpc, Socket, Map > Class Template Reference

The client class. More...

#include <packio/client.h>

Public Types

using rpc_type = Rpc
 The RPC protocol type.
 
using id_type = typename rpc_type::id_type
 The call ID type.
 
using response_type = typename rpc_type::response_type
 The response of a RPC call.
 
using socket_type = Socket
 The socket type.
 
using protocol_type = typename socket_type::protocol_type
 The protocol type.
 
using executor_type = typename socket_type::executor_type
 The executor type.
 

Public Member Functions

 client (socket_type socket)
 The constructor. More...
 
socket_typesocket () noexcept
 Get the underlying socket.
 
const socket_typesocket () const noexcept
 Get the underlying socket, const.
 
void set_buffer_reserve_size (std::size_t size) noexcept
 Set the size reserved by the reception buffer.
 
std::size_t get_buffer_reserve_size () const noexcept
 Get the size reserved by the reception buffer.
 
executor_type get_executor ()
 Get the executor associated with the object.
 
void cancel (id_type id)
 Cancel a pending call. More...
 
void cancel ()
 Cancel all pending calls. More...
 
template<typename NotifyHandler PACKIO_DEFAULT_COMPLETION_TOKEN_TYPE, typename ArgsTuple , typename = std::enable_if_t<internal::is_tuple_v<ArgsTuple>>>
auto async_notify (std::string_view name, ArgsTuple &&args, NotifyHandler &&handler=typename net::default_completion_token< executor_type >::type())
 Send a notify request to the server with argument. More...
 
template<typename NotifyHandler PACKIO_DEFAULT_COMPLETION_TOKEN_TYPE, typename = std::enable_if_t<!internal::is_tuple_v<NotifyHandler>>>
auto async_notify (std::string_view name, NotifyHandler &&handler=typename net::default_completion_token< executor_type >::type())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename CallHandler PACKIO_DEFAULT_COMPLETION_TOKEN_TYPE, typename ArgsTuple , typename = std::enable_if_t<internal::is_tuple_v<ArgsTuple>>>
auto async_call (std::string_view name, ArgsTuple &&args, CallHandler &&handler=typename net::default_completion_token< executor_type >::type(), std::optional< std::reference_wrapper< id_type >> call_id=std::nullopt)
 Call a remote procedure. More...
 
template<typename CallHandler PACKIO_DEFAULT_COMPLETION_TOKEN_TYPE, typename = std::enable_if_t<!internal::is_tuple_v<CallHandler>>>
auto async_call (std::string_view name, CallHandler &&handler=typename net::default_completion_token< executor_type >::type(), std::optional< std::reference_wrapper< id_type >> call_id=std::nullopt)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 

Static Public Attributes

static constexpr size_t kDefaultBufferReserveSize = 4096
 The default size reserved by the reception buffer.
 

Detailed Description

template<typename Rpc, typename Socket, template< class... > class Map = default_map>
class packio::client< Rpc, Socket, Map >

The client class.

Template Parameters
RpcRPC protocol implementation
SocketSocket type to use for this client
MapContainer used to associate call IDs and handlers

Constructor & Destructor Documentation

◆ client()

template<typename Rpc , typename Socket , template< class... > class Map = default_map>
packio::client< Rpc, Socket, Map >::client ( socket_type  socket)
inlineexplicit

The constructor.

Parameters
socketThe socket which the client will use. Can be connected or not

Member Function Documentation

◆ async_call()

template<typename Rpc , typename Socket , template< class... > class Map = default_map>
template<typename CallHandler PACKIO_DEFAULT_COMPLETION_TOKEN_TYPE, typename ArgsTuple , typename = std::enable_if_t<internal::is_tuple_v<ArgsTuple>>>
auto packio::client< Rpc, Socket, Map >::async_call ( std::string_view  name,
ArgsTuple &&  args,
CallHandler &&  handler = typename net::default_completion_token< executor_type >::type(),
std::optional< std::reference_wrapper< id_type >>  call_id = std::nullopt 
)
inline

Call a remote procedure.

Parameters
nameRemote procedure name to call
argsTuple of arguments to pass to the remote procedure
handlerHandler called with the return value Must satisfy the traits::CallHandler trait
call_idOutput parameter that will receive the call ID

◆ async_notify()

template<typename Rpc , typename Socket , template< class... > class Map = default_map>
template<typename NotifyHandler PACKIO_DEFAULT_COMPLETION_TOKEN_TYPE, typename ArgsTuple , typename = std::enable_if_t<internal::is_tuple_v<ArgsTuple>>>
auto packio::client< Rpc, Socket, Map >::async_notify ( std::string_view  name,
ArgsTuple &&  args,
NotifyHandler &&  handler = typename net::default_completion_token< executor_type >::type() 
)
inline

Send a notify request to the server with argument.

A notify request will call the remote procedure but does not expect a response

Parameters
nameRemote procedure name to call
argsTuple of arguments to pass to the remote procedure
handlerHandler called after the notify request is sent. Must satisfy the traits::NotifyHandler trait

◆ cancel() [1/2]

template<typename Rpc , typename Socket , template< class... > class Map = default_map>
void packio::client< Rpc, Socket, Map >::cancel ( )
inline

Cancel all pending calls.

The associated handlers will be called with net::error::operation_aborted

◆ cancel() [2/2]

template<typename Rpc , typename Socket , template< class... > class Map = default_map>
void packio::client< Rpc, Socket, Map >::cancel ( id_type  id)
inline

Cancel a pending call.

The associated handler will be called with net::error::operation_aborted

Parameters
idThe call ID of the call to cancel

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