aether::netcode::connection_state< Traits > Class Template Reference

State associated with a connection to a client. More...

#include <generic_netcode.hh>

Public Member Functions

 connection_state (void *_conn_ctx, const interest_policy_type &policy, entity_store< entity_type > &global_store)
 
 connection_state (connection_state &&)=default
 
bool is_scheduled (const entity_handle &handle) const
 Returns true if the entity is scheduled to be sent at some point in the future. More...
 
void * get_context () const
 Returns the opaque context used to identify this connection to the muxer. More...
 
void schedule_entity (const entity_store< entity_type > &store, const entity_handle &handle, const std::optional< time_point > &time, bool update_last_sent=false)
 Schedules an entity to be sent in some future tick. More...
 
std::optional< uint64_t > last_sent_tick (const entity_handle &handle) const
 Returns the version of the entity (identified by tick) that was last sent to the client. More...
 
void new_simulation_message (void *muxer, const spatial_index< entity_store< entity_type >> &spatial_index, const controlled_entity_map &controlled)
 This is called by the generic netcode to inform the client state that a new message has been received from the simulation. More...
 
void notify_writable (void *muxer, const std::unordered_map< uint64_t, worker_state< marshalling_type >> &worker_states, const spatial_index< entity_store< entity_type >> &spatial_index, const controlled_entity_map &controlled, const marshalling_type &marshalling_factory)
 This is called by the generic netcode to inform the client state that more data may be written to the client connection. More...
 
void new_worker (void *muxer, uint64_t worker_id)
 Notifies the client state that a new worker has been registered with the muxer. More...
 
void new_per_worker_data (void *muxer, uint64_t worker_id, const container::span< const per_worker_data_type > &data)
 Inform the client state of new headers received from a specified worker. More...
 

Detailed Description

template<typename Traits>
class aether::netcode::connection_state< Traits >

State associated with a connection to a client.

Constructor & Destructor Documentation

template<typename Traits >
aether::netcode::connection_state< Traits >::connection_state ( void *  _conn_ctx,
const interest_policy_type &  policy,
entity_store< entity_type > &  global_store 
)
template<typename Traits>
aether::netcode::connection_state< Traits >::connection_state ( connection_state< Traits > &&  )
default

Member Function Documentation

template<typename Traits >
void * aether::netcode::connection_state< Traits >::get_context ( ) const

Returns the opaque context used to identify this connection to the muxer.

template<typename Traits >
bool aether::netcode::connection_state< Traits >::is_scheduled ( const entity_handle &  handle) const

Returns true if the entity is scheduled to be sent at some point in the future.

template<typename Traits >
std::optional< uint64_t > aether::netcode::connection_state< Traits >::last_sent_tick ( const entity_handle &  handle) const

Returns the version of the entity (identified by tick) that was last sent to the client.

std::nullopt is returned if the entity has not been recently scheduled.

template<typename Traits >
void aether::netcode::connection_state< Traits >::new_per_worker_data ( void *  muxer,
uint64_t  worker_id,
const container::span< const per_worker_data_type > &  data 
)

Inform the client state of new headers received from a specified worker.

template<typename Traits >
void aether::netcode::connection_state< Traits >::new_simulation_message ( void *  muxer,
const spatial_index< entity_store< entity_type >> &  spatial_index,
const controlled_entity_map controlled 
)

This is called by the generic netcode to inform the client state that a new message has been received from the simulation.

queries agents in the proximity of the player and schedules them to be sent if they have not already been.

Parameters
muxerthe muxer context
spatial_indexall entities in the simulation indexed spatially
controlleda map of entities controlled by external clients
See also
interest_policy
template<typename Traits >
void aether::netcode::connection_state< Traits >::new_worker ( void *  muxer,
uint64_t  worker_id 
)

Notifies the client state that a new worker has been registered with the muxer.

template<typename Traits >
void aether::netcode::connection_state< Traits >::notify_writable ( void *  muxer,
const std::unordered_map< uint64_t, worker_state< marshalling_type >> &  worker_states,
const spatial_index< entity_store< entity_type >> &  spatial_index,
const controlled_entity_map controlled,
const marshalling_type &  marshalling_factory 
)

This is called by the generic netcode to inform the client state that more data may be written to the client connection.

Parameters
muxerthe muxer context
worker_statesstate information about all simulation workers
spatial_indexall entities in the simulation indexed spatially
controlleda map of entities controlled by external clients
marshalling_factorya factory that be used to produce a marshaller which will construct data in the right format to be sent to a client
template<typename Traits >
void aether::netcode::connection_state< Traits >::schedule_entity ( const entity_store< entity_type > &  store,
const entity_handle &  handle,
const std::optional< time_point > &  time,
bool  update_last_sent = false 
)

Schedules an entity to be sent in some future tick.

Parameters
storethe entity store
handlethe entity
timethe optional time this entity will be sent. If empty, the entity will be descheduled
update_last_sentIf true, the current tick of the entity will be recorded in scheduled_entities. This enables entity versioning so that a non-updated entity is not sent multiple times.