aether::replication::client Class Reference

Repclication client. More...

#include <repclient.hh>

Public Types

using stream_id = protocol::stream_id
 
using duration_type = std::chrono::duration< double >
 

Public Member Functions

 client ()=default
 
 client (const char *host, const char *port)
 
 client (const char *host, const char *port, const char *path)
 
 client (const char *path)
 
 client (const client &)=delete
 
clientoperator= (const client &)=delete
 
int connect (const char *host, const char *port)
 connects to a given host/port. More...
 
int connect_record (const char *host, const char *port, const char *path)
 connects to a given host/port, and stores the messages received to a recording file. More...
 
int connect_playback (const char *path)
 connects and replays the connection from a file. More...
 
void * tick (size_t *msg_size)
 Attempt to return a message from the incoming message buffer. More...
 
bool send (const void *data, size_t length, bool blocking=true)
 Send an event to the simulation. More...
 
void authenticate_player_id (const uint64_t id)
 Authenticate as a player with an ID. More...
 
void authenticate_player_id_with_token (const uint64_t id, const std::array< unsigned char, 32 > &token)
 Authenticate as a player with an ID - verification with a 32 character token on the muxer side. More...
 
void send_authentication_payload (const void *data, size_t len)
 authentication function that can take an arbitrary authentication token More...
 
bool is_connected () const
 Returns true if connection is still valid. More...
 
duration_type last_packet_time () const
 time the last packet was received More...
 
 ~client ()
 

Detailed Description

Repclication client.

Responsible for authentication and communication with the Aether simulation.

Member Typedef Documentation

using aether::replication::client::duration_type = std::chrono::duration<double>

Constructor & Destructor Documentation

aether::replication::client::client ( )
default
aether::replication::client::client ( const char *  host,
const char *  port 
)
aether::replication::client::client ( const char *  host,
const char *  port,
const char *  path 
)
aether::replication::client::client ( const char *  path)
aether::replication::client::client ( const client )
delete
aether::replication::client::~client ( )

Member Function Documentation

void aether::replication::client::authenticate_player_id ( const uint64_t  id)

Authenticate as a player with an ID.

Authentication is asynchronyous, authentication failure will disconnect this client (it might take time to propagate the disconnect).

Parameters
[in]idplayer's id
void aether::replication::client::authenticate_player_id_with_token ( const uint64_t  id,
const std::array< unsigned char, 32 > &  token 
)

Authenticate as a player with an ID - verification with a 32 character token on the muxer side.

Authentication is asynchronyous, authentication failure will disconnect this client (it might take time to propagate the disconnect).

Parameters
[in]idid of the player
[in]token32-char long token
int aether::replication::client::connect ( const char *  host,
const char *  port 
)

connects to a given host/port.

Blocks until a connection is established or a timeout reached.

Parameters
[in]hostmuxer hostname to connect to; not null
[in]portmuxer port to connect to (usually 8881); not null
Returns
0 if success, non zero otherwise
int aether::replication::client::connect_playback ( const char *  path)

connects and replays the connection from a file.

Parameters
[in]pathpath to a recording file; not null
Returns
0 if success, non zero otherwise
int aether::replication::client::connect_record ( const char *  host,
const char *  port,
const char *  path 
)

connects to a given host/port, and stores the messages received to a recording file.

Blocks until a connection is established or a timeout reached.

Parameters
[in]hostmuxer hostname to connect to; not null
Parameters
[in]portmuxer port to connect to (usually 8881); not null
Parameters
[in]pathpath to a recording file; not null
Returns
0 if success, non zero otherwise
bool aether::replication::client::is_connected ( ) const

Returns true if connection is still valid.

duration_type aether::replication::client::last_packet_time ( ) const

time the last packet was received

client& aether::replication::client::operator= ( const client )
delete
bool aether::replication::client::send ( const void *  data,
size_t  length,
bool  blocking = true 
)

Send an event to the simulation.

Parameters
[in]datapointer to start of event data; not null
[in]lengthsize in bytes of the data to be sent
[in]blockingwhether the send is allowed to block. In the blocking case, the function will wait until the event is queued or an error occurs. In the non-blocking case the event may not be queued (likely due to lack of space in the send buffer).
Returns
true if the event has been successfully queued for sending
void aether::replication::client::send_authentication_payload ( const void *  data,
size_t  len 
)

authentication function that can take an arbitrary authentication token

Parameters
[in]dataauthentication data; not null
[in]lensize of the data in bytes
void* aether::replication::client::tick ( size_t *  msg_size)

Attempt to return a message from the incoming message buffer.

The buffer is populated asynchronyously in a native background thread. If connect was used to connect to the muxer, the message will come from the simulation. If connect_record was used the message comes from the simulation and it is also going to be also saved in to the file. If connect_replay was used, the message will come from the recorded file

Parameters
[out]msg_sizeis going to contain the size in bytes of the received messages
Returns
pointer to the next available update message, or null if no messages have been received
See also
connect()
connect_record()
connect_playback()