Panda3D
Public Member Functions | Static Public Member Functions
CConnectionRepository Class Reference

This class implements the C++ side of the ConnectionRepository object. More...

#include "cConnectionRepository.h"

List of all members.

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
void bundle_msg (const Datagram &dg)
bool check_datagram ()
 Returns true if a new datagram is available, false otherwise.
bool consider_flush ()
 Sends the most recently queued data if enough time has elapsed.
void disconnect ()
 Closes the connection to the server.
bool flush ()
 Sends the most recently queued data now.
bool get_client_datagram () const
 Returns the client_datagram flag.
void get_datagram (Datagram &dg)
 Fills the datagram object with the datagram most recently retrieved by check_datagram().
void get_datagram_iterator (DatagramIterator &di)
 Fills the DatagramIterator object with the iterator for the datagram most recently retrieved by check_datagram().
DCFileget_dc_file ()
 Returns the DCFile object associated with this repository.
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.
bool get_handle_datagrams_internally () const
 Returns the handle_datagrams_internally flag.
bool get_in_quiet_zone () const
 Returns true if repository is in quiet zone mode.
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.
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.
unsigned int get_msg_type () const
 Returns the security code associated with the current message, according to the datagram headers.
bool get_simulated_disconnect () const
 Returns the simulated disconnect flag.
int get_tcp_header_size () const
 Returns the current setting of TCP header size.
float get_time_warning () const
 Returns the current setting of the time_warning field.
bool get_verbose () const
 Returns the current setting of the verbose flag.
bool get_want_message_bundling () const
 Returns true if message bundling enabled.
bool has_owner_view () const
 Returns true if this repository can have 'owner' views of distributed objects.
bool is_bundling_messages () const
 Returns true if repository is queueing outgoing messages into a message bundle.
bool is_connected ()
 Returns true if the connection to the gameserver is established and still good, false if we are not connected.
bool send_datagram (const Datagram &dg)
 Queues the indicated datagram for sending to the server.
void send_message_bundle (unsigned int channel, unsigned int sender_channel)
 Send network messages queued up since startMessageBundle was called.
void set_client_datagram (bool client_datagram)
 Sets the client_datagram flag.
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.
void set_handle_datagrams_internally (bool handle_datagrams_internally)
 Sets the handle_datagrams_internally flag.
void set_in_quiet_zone (bool flag)
 Enables/disables quiet zone mode.
void set_simulated_disconnect (bool simulated_disconnect)
 Sets the simulated disconnect flag.
void set_tcp_header_size (int tcp_header_size)
 Sets the header size of TCP packets.
void set_time_warning (float time_warning)
 Directly sets the time_warning field.
void set_verbose (bool verbose)
 Directly sets the verbose flag.
void set_want_message_bundling (bool flag)
 Enable/disable outbound message bundling.
void shutdown ()
 May be called at application shutdown to ensure all threads are cleaned up.
void start_message_bundle ()
 Send a set of messages to the state server that will be processed atomically.
void toggle_verbose ()
 Toggles the current setting of the verbose flag.

Static Public Member Functions

static const string & get_overflow_event_name ()
 Returns event string that will be thrown if the datagram reader queue overflows.

Detailed Description

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 61 of file cConnectionRepository.h.


Member Function Documentation

throw out any msgs that have been queued up for message bundles

Definition at line 554 of file cConnectionRepository.cxx.

References is_bundling_messages().

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 290 of file cConnectionRepository.cxx.

References DatagramIterator::get_uint16(), DatagramIterator::get_uint64(), DatagramIterator::get_uint8(), and get_verbose().

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 583 of file cConnectionRepository.cxx.

Closes the connection to the server.

Definition at line 650 of file cConnectionRepository.cxx.

Referenced by shutdown().

Sends the most recently queued data now.

This only has meaning if set_collect_tcp() has been set to true.

Definition at line 618 of file cConnectionRepository.cxx.

Returns the client_datagram flag.

Definition at line 83 of file cConnectionRepository.I.

Fills the datagram object with the datagram most recently retrieved by check_datagram().

Definition at line 202 of file cConnectionRepository.I.

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 217 of file cConnectionRepository.I.

Returns the DCFile object associated with this repository.

Definition at line 23 of file cConnectionRepository.I.

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 58 of file cConnectionRepository.I.

Returns the handle_datagrams_internally flag.

Definition at line 110 of file cConnectionRepository.I.

Returns true if repository is in quiet zone mode.

Definition at line 343 of file cConnectionRepository.I.

CHANNEL_TYPE CConnectionRepository::get_msg_channel ( int  offset = 0) const [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 230 of file cConnectionRepository.I.

CHANNEL_TYPE CConnectionRepository::get_msg_sender ( ) const [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 250 of file cConnectionRepository.I.

unsigned int CConnectionRepository::get_msg_type ( ) const [inline]

Returns the security code associated with the current message, according to the datagram headers.

This information is not available to the client. Returns the type ID of the current message, according to the datagram headers.

Definition at line 274 of file cConnectionRepository.I.

const string & CConnectionRepository::get_overflow_event_name ( ) [inline, static]

Returns event string that will be thrown if the datagram reader queue overflows.

Definition at line 286 of file cConnectionRepository.I.

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 370 of file cConnectionRepository.I.

Returns the current setting of TCP header size.

See set_tcp_header_size().

Definition at line 121 of file cConnectionRepository.I.

float CConnectionRepository::get_time_warning ( ) const [inline]

Returns the current setting of the time_warning field.

Definition at line 428 of file cConnectionRepository.I.

bool CConnectionRepository::get_verbose ( ) const [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 406 of file cConnectionRepository.I.

Referenced by check_datagram(), send_datagram(), send_message_bundle(), and start_message_bundle().

Returns true if message bundling enabled.

Definition at line 321 of file cConnectionRepository.I.

Referenced by send_datagram(), and send_message_bundle().

bool CConnectionRepository::has_owner_view ( ) const [inline]

Returns true if this repository can have 'owner' views of distributed objects.

Definition at line 34 of file cConnectionRepository.I.

Returns true if repository is queueing outgoing messages into a message bundle.

Definition at line 297 of file cConnectionRepository.I.

Referenced by abandon_message_bundles(), and send_datagram().

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 389 of file cConnectionRepository.cxx.

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 438 of file cConnectionRepository.cxx.

References get_verbose(), get_want_message_bundling(), and is_bundling_messages().

Referenced by send_message_bundle().

void CConnectionRepository::send_message_bundle ( unsigned int  channel,
unsigned int  sender_channel 
)

Send network messages queued up since startMessageBundle was called.

Definition at line 519 of file cConnectionRepository.cxx.

References Datagram::add_int8(), Datagram::add_string(), Datagram::add_uint16(), Datagram::add_uint64(), get_verbose(), get_want_message_bundling(), and send_datagram().

void CConnectionRepository::set_client_datagram ( bool  client_datagram) [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 73 of file cConnectionRepository.I.

void CConnectionRepository::set_handle_c_updates ( bool  handle_c_updates) [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 46 of file cConnectionRepository.I.

void CConnectionRepository::set_handle_datagrams_internally ( bool  handle_datagrams_internally) [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 100 of file cConnectionRepository.I.

void CConnectionRepository::set_in_quiet_zone ( bool  flag) [inline]

Enables/disables quiet zone mode.

Definition at line 332 of file cConnectionRepository.I.

void CConnectionRepository::set_simulated_disconnect ( bool  simulated_disconnect) [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 357 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 114 of file cConnectionRepository.cxx.

void CConnectionRepository::set_time_warning ( float  time_warning) [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 418 of file cConnectionRepository.I.

void CConnectionRepository::set_verbose ( bool  verbose) [inline]

Directly sets the verbose flag.

When true, this describes every message going back and forth on the wire.

Definition at line 394 of file cConnectionRepository.I.

Enable/disable outbound message bundling.

Definition at line 308 of file cConnectionRepository.I.

May be called at application shutdown to ensure all threads are cleaned up.

Definition at line 684 of file cConnectionRepository.cxx.

References disconnect().

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 496 of file cConnectionRepository.cxx.

References get_verbose().

Toggles the current setting of the verbose flag.

When true, this describes every message going back and forth on the wire.

Definition at line 382 of file cConnectionRepository.I.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations