This class implements the C++ side of the ConnectionRepository object. More...
#include "cConnectionRepository.h"
Public Member Functions | |
CConnectionRepository (bool has_owner_view=false, bool threaded_net=false) | |
void | abandon_message_bundles () |
throw out any msgs that have been queued up for message bundles More... | |
void | bundle_msg (const Datagram &dg) |
bool | check_datagram () |
Returns true if a new datagram is available, false otherwise. More... | |
bool | consider_flush () |
Sends the most recently queued data if enough time has elapsed. More... | |
void | disconnect () |
Closes the connection to the server. More... | |
bool | flush () |
Sends the most recently queued data now. More... | |
bool | get_client_datagram () const |
Returns the client_datagram flag. More... | |
void | get_datagram (Datagram &dg) |
Fills the datagram object with the datagram most recently retrieved by check_datagram(). More... | |
void | get_datagram_iterator (DatagramIterator &di) |
Fills the DatagramIterator object with the iterator for the datagram most recently retrieved by check_datagram(). More... | |
DCFile & | get_dc_file () |
Returns the DCFile object associated with this repository. More... | |
bool | get_handle_c_updates () const |
Returns true if this repository will process distributed updates internally in C++ code, or false if it will return them to Python. More... | |
bool | get_handle_datagrams_internally () const |
Returns the handle_datagrams_internally flag. More... | |
bool | get_in_quiet_zone () const |
Returns true if repository is in quiet zone mode. More... | |
CHANNEL_TYPE | get_msg_channel (int offset=0) const |
Returns the channel(s) to which the current message was sent, according to the datagram headers. More... | |
int | get_msg_channel_count () const |
CHANNEL_TYPE | get_msg_sender () const |
Returns the sender ID of the current message, according to the datagram headers. More... | |
unsigned int | get_msg_type () const |
Returns the security code associated with the current message, according to the datagram headers. More... | |
bool | get_simulated_disconnect () const |
Returns the simulated disconnect flag. More... | |
int | get_tcp_header_size () const |
Returns the current setting of TCP header size. More... | |
float | get_time_warning () const |
Returns the current setting of the time_warning field. More... | |
bool | get_verbose () const |
Returns the current setting of the verbose flag. More... | |
bool | get_want_message_bundling () const |
Returns true if message bundling enabled. More... | |
bool | has_owner_view () const |
Returns true if this repository can have 'owner' views of distributed objects. More... | |
bool | is_bundling_messages () const |
Returns true if repository is queueing outgoing messages into a message bundle. More... | |
bool | is_connected () |
Returns true if the connection to the gameserver is established and still good, false if we are not connected. More... | |
bool | send_datagram (const Datagram &dg) |
Queues the indicated datagram for sending to the server. More... | |
void | send_message_bundle (unsigned int channel, unsigned int sender_channel) |
Send network messages queued up since startMessageBundle was called. More... | |
void | set_client_datagram (bool client_datagram) |
Sets the client_datagram flag. More... | |
void | set_handle_c_updates (bool handle_c_updates) |
Set true to specify this repository should process distributed updates internally in C++ code, or false if it should return them to Python. More... | |
void | set_handle_datagrams_internally (bool handle_datagrams_internally) |
Sets the handle_datagrams_internally flag. More... | |
void | set_in_quiet_zone (bool flag) |
Enables/disables quiet zone mode. More... | |
void | set_simulated_disconnect (bool simulated_disconnect) |
Sets the simulated disconnect flag. More... | |
void | set_tcp_header_size (int tcp_header_size) |
Sets the header size of TCP packets. More... | |
void | set_time_warning (float time_warning) |
Directly sets the time_warning field. More... | |
void | set_verbose (bool verbose) |
Directly sets the verbose flag. More... | |
void | set_want_message_bundling (bool flag) |
Enable/disable outbound message bundling. More... | |
void | shutdown () |
May be called at application shutdown to ensure all threads are cleaned up. More... | |
void | start_message_bundle () |
Send a set of messages to the state server that will be processed atomically. More... | |
void | toggle_verbose () |
Toggles the current setting of the verbose flag. More... | |
Static Public Member Functions | |
static const std::string & | get_overflow_event_name () |
Returns event string that will be thrown if the datagram reader queue overflows. More... | |
This class implements the C++ side of the ConnectionRepository object.
In particular, it manages the connection to the server once it has been opened (but does not open it directly). It manages reading and writing datagrams on the connection and monitoring for unexpected disconnects as well as handling intentional disconnects.
Certain server messages, like field updates, are handled entirely within the C++ layer, while server messages that are not understood by the C++ layer are returned up to the Python layer for processing.
Definition at line 56 of file cConnectionRepository.h.
void CConnectionRepository::abandon_message_bundles | ( | ) |
throw out any msgs that have been queued up for message bundles
Definition at line 515 of file cConnectionRepository.cxx.
bool CConnectionRepository::check_datagram | ( | ) |
Returns true if a new datagram is available, false otherwise.
If the return value is true, the new datagram may be retrieved via get_datagram(), or preferably, with get_datagram_iterator() and get_msg_type().
Definition at line 252 of file cConnectionRepository.cxx.
References get_verbose().
bool CConnectionRepository::consider_flush | ( | ) |
Sends the most recently queued data if enough time has elapsed.
This only has meaning if set_collect_tcp() has been set to true.
Definition at line 539 of file cConnectionRepository.cxx.
void CConnectionRepository::disconnect | ( | ) |
Closes the connection to the server.
Definition at line 601 of file cConnectionRepository.cxx.
Referenced by shutdown().
bool CConnectionRepository::flush | ( | void | ) |
Sends the most recently queued data now.
This only has meaning if set_collect_tcp() has been set to true.
Definition at line 571 of file cConnectionRepository.cxx.
|
inline |
Returns the client_datagram flag.
Definition at line 64 of file cConnectionRepository.I.
|
inline |
Fills the datagram object with the datagram most recently retrieved by check_datagram().
Definition at line 158 of file cConnectionRepository.I.
|
inline |
Fills the DatagramIterator object with the iterator for the datagram most recently retrieved by check_datagram().
This iterator has already read past the datagram header and the message type, and is positioned at the beginning of data.
Definition at line 170 of file cConnectionRepository.I.
|
inline |
Returns the DCFile object associated with this repository.
Definition at line 18 of file cConnectionRepository.I.
|
inline |
Returns true if this repository will process distributed updates internally in C++ code, or false if it will return them to Python.
Definition at line 45 of file cConnectionRepository.I.
|
inline |
Returns the handle_datagrams_internally flag.
Definition at line 85 of file cConnectionRepository.I.
|
inline |
Returns true if repository is in quiet zone mode.
Definition at line 271 of file cConnectionRepository.I.
|
inline |
Returns the channel(s) to which the current message was sent, according to the datagram headers.
This information is not available to the client.
Definition at line 180 of file cConnectionRepository.I.
|
inline |
Returns the sender ID of the current message, according to the datagram headers.
This information is not available to the client.
Definition at line 197 of file cConnectionRepository.I.
|
inline |
Returns the security code associated with the current message, according to the datagram headers.
This information is not available to the client. INLINE unsigned char CConnectionRepository:: get_sec_code() const { return _sec_code; } Returns the type ID of the current message, according to the datagram headers.
Definition at line 214 of file cConnectionRepository.I.
|
inlinestatic |
Returns event string that will be thrown if the datagram reader queue overflows.
Definition at line 224 of file cConnectionRepository.I.
|
inline |
Returns the simulated disconnect flag.
While this is true, no datagrams will be retrieved from or sent to the server. The idea is to simulate a temporary network outage.
Definition at line 292 of file cConnectionRepository.I.
|
inline |
Returns the current setting of TCP header size.
Definition at line 93 of file cConnectionRepository.I.
|
inline |
Returns the current setting of the time_warning field.
Definition at line 337 of file cConnectionRepository.I.
|
inline |
Returns the current setting of the verbose flag.
When true, this describes every message going back and forth on the wire.
Definition at line 319 of file cConnectionRepository.I.
Referenced by check_datagram(), send_datagram(), and start_message_bundle().
|
inline |
Returns true if message bundling enabled.
Definition at line 253 of file cConnectionRepository.I.
|
inline |
Returns true if this repository can have 'owner' views of distributed objects.
Definition at line 27 of file cConnectionRepository.I.
|
inline |
Returns true if repository is queueing outgoing messages into a message bundle.
Definition at line 233 of file cConnectionRepository.I.
bool CConnectionRepository::is_connected | ( | ) |
Returns true if the connection to the gameserver is established and still good, false if we are not connected.
A false value means either (a) we never successfully connected, (b) we explicitly called disconnect(), or (c) we were connected, but the connection was spontaneously lost.
Definition at line 343 of file cConnectionRepository.cxx.
bool CConnectionRepository::send_datagram | ( | const Datagram & | dg | ) |
Queues the indicated datagram for sending to the server.
It may not get sent immediately if collect_tcp is in effect; call flush() to guarantee it is sent now.
Definition at line 389 of file cConnectionRepository.cxx.
References get_verbose().
void CConnectionRepository::send_message_bundle | ( | unsigned int | channel, |
unsigned int | sender_channel | ||
) |
Send network messages queued up since startMessageBundle was called.
Definition at line 483 of file cConnectionRepository.cxx.
|
inline |
Sets the client_datagram flag.
If this is true, incoming datagrams are not expected to be prefixed with the server routing information like message sender, channel number, etc.; otherwise, these server fields are parsed and removed from each incoming datagram.
Definition at line 56 of file cConnectionRepository.I.
|
inline |
Set true to specify this repository should process distributed updates internally in C++ code, or false if it should return them to Python.
Definition at line 36 of file cConnectionRepository.I.
|
inline |
Sets the handle_datagrams_internally flag.
When true, certain message types can be handled by the C++ code in in this module. When false, all datagrams, regardless of message type, are passed up to Python for processing.
The CMU distributed-object implementation requires this to be set false.
Definition at line 77 of file cConnectionRepository.I.
|
inline |
Enables/disables quiet zone mode.
Definition at line 262 of file cConnectionRepository.I.
|
inline |
Sets the simulated disconnect flag.
While this is true, no datagrams will be retrieved from or sent to the server. The idea is to simulate a temporary network outage.
Definition at line 282 of file cConnectionRepository.I.
void CConnectionRepository::set_tcp_header_size | ( | int | tcp_header_size | ) |
Sets the header size of TCP packets.
At the present, legal values for this are 0, 2, or 4; this specifies the number of bytes to use encode the datagram length at the start of each TCP datagram. Sender and receiver must independently agree on this.
Definition at line 97 of file cConnectionRepository.cxx.
|
inline |
Directly sets the time_warning field.
When non zero, this describes every message going back and forth on the wire when the msg handling time is over it
Definition at line 329 of file cConnectionRepository.I.
|
inline |
Directly sets the verbose flag.
When true, this describes every message going back and forth on the wire.
Definition at line 310 of file cConnectionRepository.I.
|
inline |
Enable/disable outbound message bundling.
Definition at line 242 of file cConnectionRepository.I.
void CConnectionRepository::shutdown | ( | ) |
May be called at application shutdown to ensure all threads are cleaned up.
Definition at line 632 of file cConnectionRepository.cxx.
References disconnect().
void CConnectionRepository::start_message_bundle | ( | ) |
Send a set of messages to the state server that will be processed atomically.
For instance, you can do a combined setLocation/setPos and prevent race conditions where clients briefly get the setLocation but not the setPos, because the state server hasn't processed the setPos yet
Definition at line 463 of file cConnectionRepository.cxx.
References get_verbose().
|
inline |
Toggles the current setting of the verbose flag.
When true, this describes every message going back and forth on the wire.
Definition at line 301 of file cConnectionRepository.I.