Panda3D
Public Member Functions | Static Public Member Functions | List of all members
CConnectionRepository Class Reference

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

Inheritance diagram for CConnectionRepository:
ConnectionRepository ClientRepositoryBase ClientRepository

Public Member Functions

 __init__ (bool has_owner_view, bool threaded_net)
 
 abandonMessageBundles ()
 throw out any msgs that have been queued up for message bundles More...
 
 bundleMsg (const Datagram dg)
 
bool checkDatagram ()
 Returns true if a new datagram is available, false otherwise. More...
 
bool connectNative (const URLSpec url)
 Connects to the server using Panda's low-level and fast "native net" library. More...
 
bool considerFlush ()
 Sends the most recently queued data if enough time has elapsed. More...
 
 disconnect ()
 Closes the connection to the server. More...
 
bool flush ()
 Sends the most recently queued data now. More...
 
BufferedDatagramConnection getBdc ()
 Returns the Buffered_DatagramConnection object associated with the repository. More...
 
bool getClientDatagram ()
 Returns the client_datagram flag. More...
 
ConnectionWriter getCw ()
 Returns the ConnectionWriter object associated with the repository. More...
 
 getDatagram (Datagram dg)
 Fills the datagram object with the datagram most recently retrieved by check_datagram(). More...
 
 getDatagramIterator (DatagramIterator di)
 Fills the DatagramIterator object with the iterator for the datagram most recently retrieved by check_datagram(). More...
 
DCFile getDcFile ()
 Returns the DCFile object associated with this repository. More...
 
bool getHandleCUpdates ()
 Returns true if this repository will process distributed updates internally in C++ code, or false if it will return them to Python. More...
 
bool getHandleDatagramsInternally ()
 Returns the handle_datagrams_internally flag. More...
 
bool getInQuietZone ()
 Returns true if repository is in quiet zone mode. More...
 
CHANNELTYPE getMsgChannel (int offset)
 Returns the channel(s) to which the current message was sent, according to the datagram headers. More...
 
int getMsgChannelCount ()
 
CHANNELTYPE getMsgSender ()
 Returns the sender ID of the current message, according to the datagram headers. More...
 
unsigned int getMsgType ()
 Returns the type ID of the current message, according to the datagram headers. More...
 
QueuedConnectionManager getQcm ()
 Returns the QueuedConnectionManager object associated with the repository. More...
 
QueuedConnectionReader getQcr ()
 Returns the QueuedConnectionReader object associated with the repository. More...
 
bool getSimulatedDisconnect ()
 Returns the simulated disconnect flag. More...
 
SocketStream getStream ()
 Returns the SocketStream that internally represents the already-established HTTP connection. More...
 
int getTcpHeaderSize ()
 Returns the current setting of TCP header size. More...
 
float getTimeWarning ()
 Returns the current setting of the time_warning field. More...
 
bool getVerbose ()
 Returns the current setting of the verbose flag. More...
 
bool getWantMessageBundling ()
 Returns true if message bundling enabled. More...
 
bool hasOwnerView ()
 Returns true if this repository can have 'owner' views of distributed objects. More...
 
bool isBundlingMessages ()
 Returns true if repository is queueing outgoing messages into a message bundle. More...
 
bool isConnected ()
 Returns true if the connection to the gameserver is established and still good, false if we are not connected. More...
 
bool sendDatagram (const Datagram dg)
 Queues the indicated datagram for sending to the server. More...
 
 sendMessageBundle (unsigned int channel, unsigned int sender_channel)
 Send network messages queued up since startMessageBundle was called. More...
 
 setClientDatagram (bool client_datagram)
 Sets the client_datagram flag. More...
 
 setConnectionHttp (HTTPChannel channel)
 Once a connection has been established via the HTTP interface, gets the connection and uses it. More...
 
 setHandleCUpdates (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...
 
 setHandleDatagramsInternally (bool handle_datagrams_internally)
 Sets the handle_datagrams_internally flag. More...
 
 setInQuietZone (bool flag)
 Enables/disables quiet zone mode. More...
 
 setPythonRepository (object python_repository)
 Records the pointer to the Python class that derives from CConnectionRepository. More...
 
 setSimulatedDisconnect (bool simulated_disconnect)
 Sets the simulated disconnect flag. More...
 
 setTcpHeaderSize (int tcp_header_size)
 Sets the header size of TCP packets. More...
 
 setTimeWarning (float time_warning)
 Directly sets the time_warning field. More...
 
 setVerbose (bool verbose)
 Directly sets the verbose flag. More...
 
 setWantMessageBundling (bool flag)
 Enable/disable outbound message bundling. More...
 
 shutdown ()
 May be called at application shutdown to ensure all threads are cleaned up. More...
 
 startMessageBundle ()
 Send a set of messages to the state server that will be processed atomically. More...
 
 toggleVerbose ()
 Toggles the current setting of the verbose flag. More...
 
bool tryConnectNet (const URLSpec url)
 Uses Panda's "net" library to try to connect to the server and port named in the indicated URL. More...
 

Static Public Member Functions

static str getOverflowEventName ()
 Returns event string that will be thrown if the datagram reader queue overflows. More...
 

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.

Member Function Documentation

◆ __init__()

__init__ ( bool  has_owner_view,
bool  threaded_net 
)

◆ abandonMessageBundles()

abandonMessageBundles ( )

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

◆ bundleMsg()

bundleMsg ( const Datagram  dg)

◆ checkDatagram()

bool checkDatagram ( )

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().

◆ connectNative()

bool connectNative ( const URLSpec  url)

Connects to the server using Panda's low-level and fast "native net" library.

◆ considerFlush()

bool considerFlush ( )

Sends the most recently queued data if enough time has elapsed.

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

◆ disconnect()

disconnect ( )

Closes the connection to the server.

◆ flush()

bool flush ( )

Sends the most recently queued data now.

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

◆ getBdc()

Returns the Buffered_DatagramConnection object associated with the repository.

◆ getClientDatagram()

bool getClientDatagram ( )

Returns the client_datagram flag.

◆ getCw()

ConnectionWriter getCw ( )

Returns the ConnectionWriter object associated with the repository.

◆ getDatagram()

getDatagram ( Datagram  dg)

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

◆ getDatagramIterator()

getDatagramIterator ( DatagramIterator  di)

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.

◆ getDcFile()

DCFile getDcFile ( )

Returns the DCFile object associated with this repository.

◆ getHandleCUpdates()

bool getHandleCUpdates ( )

Returns true if this repository will process distributed updates internally in C++ code, or false if it will return them to Python.

◆ getHandleDatagramsInternally()

bool getHandleDatagramsInternally ( )

Returns the handle_datagrams_internally flag.

◆ getInQuietZone()

bool getInQuietZone ( )

Returns true if repository is in quiet zone mode.

◆ getMsgChannel()

CHANNELTYPE getMsgChannel ( int  offset)

Returns the channel(s) to which the current message was sent, according to the datagram headers.

This information is not available to the client.

◆ getMsgChannelCount()

int getMsgChannelCount ( )

◆ getMsgSender()

CHANNELTYPE getMsgSender ( )

Returns the sender ID of the current message, according to the datagram headers.

This information is not available to the client.

◆ getMsgType()

unsigned int getMsgType ( )

Returns the type ID of the current message, according to the datagram headers.

◆ getOverflowEventName()

static str getOverflowEventName ( )
static

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

◆ getQcm()

Returns the QueuedConnectionManager object associated with the repository.

◆ getQcr()

Returns the QueuedConnectionReader object associated with the repository.

◆ getSimulatedDisconnect()

bool getSimulatedDisconnect ( )

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.

◆ getStream()

SocketStream getStream ( )

Returns the SocketStream that internally represents the already-established HTTP connection.

Returns NULL if there is no current HTTP connection.

◆ getTcpHeaderSize()

int getTcpHeaderSize ( )

Returns the current setting of TCP header size.

See set_tcp_header_size().

◆ getTimeWarning()

float getTimeWarning ( )

Returns the current setting of the time_warning field.

◆ getVerbose()

bool getVerbose ( )

Returns the current setting of the verbose flag.

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

◆ getWantMessageBundling()

bool getWantMessageBundling ( )

Returns true if message bundling enabled.

◆ hasOwnerView()

bool hasOwnerView ( )

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

◆ isBundlingMessages()

bool isBundlingMessages ( )

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

◆ isConnected()

bool isConnected ( )

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.

◆ sendDatagram()

bool sendDatagram ( 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.

◆ sendMessageBundle()

sendMessageBundle ( unsigned int  channel,
unsigned int  sender_channel 
)

Send network messages queued up since startMessageBundle was called.

◆ setClientDatagram()

setClientDatagram ( bool  client_datagram)

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.

◆ setConnectionHttp()

setConnectionHttp ( HTTPChannel  channel)

Once a connection has been established via the HTTP interface, gets the connection and uses it.

The supplied HTTPChannel object must have a connection available via get_connection().

◆ setHandleCUpdates()

setHandleCUpdates ( 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.

◆ setHandleDatagramsInternally()

setHandleDatagramsInternally ( bool  handle_datagrams_internally)

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.

◆ setInQuietZone()

setInQuietZone ( bool  flag)

Enables/disables quiet zone mode.

◆ setPythonRepository()

setPythonRepository ( object  python_repository)

Records the pointer to the Python class that derives from CConnectionRepository.

This allows the C++ implementation to directly manipulation some python structures on the repository.

◆ setSimulatedDisconnect()

setSimulatedDisconnect ( bool  simulated_disconnect)

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.

◆ setTcpHeaderSize()

setTcpHeaderSize ( 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.

◆ setTimeWarning()

setTimeWarning ( float  time_warning)

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

◆ setVerbose()

setVerbose ( bool  verbose)

Directly sets the verbose flag.

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

◆ setWantMessageBundling()

setWantMessageBundling ( bool  flag)

Enable/disable outbound message bundling.

◆ shutdown()

shutdown ( )

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

◆ startMessageBundle()

startMessageBundle ( )

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

◆ toggleVerbose()

toggleVerbose ( )

Toggles the current setting of the verbose flag.

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

◆ tryConnectNet()

bool tryConnectNet ( const URLSpec  url)

Uses Panda's "net" library to try to connect to the server and port named in the indicated URL.

Returns true if successful, false otherwise.