# ClientRepositoryBase

from direct.distributed.ClientRepositoryBase import ClientRepositoryBase

This maintains a client-side connection with a Panda server.
This base class exists to collect the common code between ClientRepository, which is the CMU-provided, open-source version of the client repository code, and OTPClientRepository, which is the VR Studio's implementation of the same.

## Inheritance:

ClientRepositoryBase: ConnectionRepository
ConnectionRepository: CConnectionRepository DoInterestManager DoCollectionManager
CConnectionRepository:
DoInterestManager:
DoCollectionManager:

## Methods of ClientRepositoryBase:

__init__
_logFailedDisable
allocateContext
considerHeartbeat
disableDoId
generateWithRequiredFields
generateWithRequiredOtherFields
generateWithRequiredOtherFieldsOwner
getObjectsOfClass
getObjectsOfExactClass
getServerDelta
getServerTimeOfDay
getTables
getWorld
handleDelete
handleDisable
handleGenerateWithRequired
handleGenerateWithRequiredOther
handleGenerateWithRequiredOtherOwner
handleGoGetLost
handleQuietZoneGenerateWithRequired
handleQuietZoneGenerateWithRequiredOther
handleServerHeartbeat
handleSystemMessage
handleUpdateField
isLocalId
replaceMethod
sendDisconnect
sendHeartbeat
sendHeartbeatTask
sendSetLocation
setServerDelta
startHeartbeat
stopHeartbeat
uniqueName
waitForNextHeartBeat

## Methods of ConnectionRepository:

__init__
checkHttp
connect
disconnect
generateGlobalObject
handleDatagram
handleReaderOverflow
httpConnectCallback
importModule
lostConnection
networkPlugPulled
pullNetworkPlug
readDCFile
readerPollOnce
readerPollUntilEmpty
restoreNetworkPlug
send
startReaderPollTask
stopReaderPollTask

## Methods of CConnectionRepository:

checkDatagram
considerFlush
disconnect
flush
getClientDatagram
getCw
getDatagram
getDatagramIterator
getDcFile
getMsgChannel
getMsgChannelCount
getMsgSender
getMsgType
getOverflowEventName
getQcm
getQcr
getSimulatedDisconnect
getStream
getVerbose
hasOwnerView
isConnected
sendDatagram
setClientDatagram
setConnectionHttp
setPythonRepository
setSimulatedDisconnect
setVerbose
toggleVerbose
tryConnectNspr

## Methods of DoInterestManager:

__init__
_considerRemoveInterest
_getAddInterestEvent
_getAnonymousEvent
_getInterestState
_getNextHandle
_getNextScopeId
_getRemoveInterestEvent
_sendAddInterest
_sendRemoveInterest
addInterest
alterInterest
closeAutoInterests
getAllInterestsCompleteEvent
handleInterestDoneMessage
noNewInterests
openAutoInterests
removeInterest
setNoNewInterests

## Methods of DoCollectionManager:

__init__
addDOToTables
callbackWithDo
callbackWithOwnerView
countObjects
deleteDistributedObjects
deleteObjectLocation
doFind
doFindAll
findAnyOfType
getAllOfType
getDo
getDoIdList
getDoList
getDoTable
getObjectsInZone
getObjectsOfClassInZone
getOwnerView
getOwnerViewDoIdList
getOwnerViewDoList
handleObjectLocation
handleSetLocation
isValidLocationTuple
removeDOFromTables
storeObjectLocation

__init__ def __init__(self, dcFileNames=None) Undocumented function.

_logFailedDisable def _logFailedDisable(self, doId, ownerView) Undocumented function.

allocateContext def allocateContext(self) Undocumented function.

considerHeartbeat def considerHeartbeat(self) Send a heartbeat message if we haven't sent one recently.

disableDoId def disableDoId(self, doId, ownerView=False) Undocumented function.

generateWithRequiredFields def generateWithRequiredFields(self, dclass, doId, di, parentId, zoneId) Undocumented function.

generateWithRequiredOtherFields def generateWithRequiredOtherFields(self, dclass, doId, di, parentId=None, zoneId=None) Undocumented function.

generateWithRequiredOtherFieldsOwner def generateWithRequiredOtherFieldsOwner(self, dclass, doId, di) Undocumented function.

getObjectsOfClass def getObjectsOfClass(self, objClass) returns dict of doId:object, containing all objects that inherit from 'class'. returned dict is safely mutable.

getObjectsOfExactClass def getObjectsOfExactClass(self, objClass) returns dict of doId:object, containing all objects that are exactly of type 'class' (neglecting inheritance). returned dict is safely mutable.

getServerDelta def getServerDelta(self) Undocumented function.

getServerTimeOfDay def getServerTimeOfDay(self) Returns the current time of day (seconds elapsed since the 1972 epoch) according to the server's clock. This is in GMT, and hence is irrespective of timezones. The value is computed based on the client's clock and the known delta from the server's clock, which is not terribly precisely measured and may drift slightly after startup, but it should be accurate plus or minus a couple of seconds.

getTables def getTables(self, ownerView) Undocumented function.

getWorld def getWorld(self, doId) Undocumented function.

handleDelete def handleDelete(self, di) Undocumented function.

handleDisable def handleDisable(self, di, ownerView=False) Undocumented function.

handleGenerateWithRequired def handleGenerateWithRequired(self, di) Undocumented function.

handleGenerateWithRequiredOther def handleGenerateWithRequiredOther(self, di) Undocumented function.

handleGenerateWithRequiredOtherOwner def handleGenerateWithRequiredOtherOwner(self, di) Undocumented function.

handleGoGetLost def handleGoGetLost(self, di) Undocumented function.

handleQuietZoneGenerateWithRequired def handleQuietZoneGenerateWithRequired(self, di) Undocumented function.

handleQuietZoneGenerateWithRequiredOther def handleQuietZoneGenerateWithRequiredOther(self, di) Undocumented function.

handleServerHeartbeat def handleServerHeartbeat(self, di) Undocumented function.

handleSystemMessage def handleSystemMessage(self, di) Undocumented function.

handleUpdateField def handleUpdateField(self, di) This method is called when a CLIENT_OBJECT_UPDATE_FIELD message is received; it decodes the update, unpacks the arguments, and calls the corresponding method on the indicated DistributedObject. In fact, this method is exactly duplicated by the C++ method cConnectionRepository::handle_update_field(), which was written to optimize the message loop by handling all of the CLIENT_OBJECT_UPDATE_FIELD messages in C++. That means that nowadays, this Python method will probably never be called, since UPDATE_FIELD messages will not even be passed to the Python message handlers. But this method remains for documentation purposes, and also as a "just in case" handler in case we ever do come across a situation in the future in which python might handle the UPDATE_FIELD message.

isLocalId def isLocalId(self, id) Undocumented function.

replaceMethod def replaceMethod(self, oldMethod, newFunction) Undocumented function.

sendDisconnect def sendDisconnect(self) Undocumented function.

sendHeartbeat def sendHeartbeat(self) Undocumented function.

sendHeartbeatTask def sendHeartbeatTask(self, task) Undocumented function.

sendSetLocation def sendSetLocation(self, doId, parentId, zoneId) Undocumented function.

setServerDelta def setServerDelta(self, delta) Indicates the approximate difference in seconds between the client's clock and the server's clock, in universal time (not including timezone shifts). This is mainly useful for reporting synchronization information to the logs; don't depend on it for any precise timing requirements. Also see Notify.setServerDelta(), which also accounts for a timezone shift.

startHeartbeat def startHeartbeat(self) Undocumented function.

stopHeartbeat def stopHeartbeat(self) Undocumented function.

uniqueName def uniqueName(self, desc) Undocumented function.

waitForNextHeartBeat def waitForNextHeartBeat(self) Undocumented function.

__init__ def __init__(self, config, hasOwnerView=False) Undocumented function.

checkHttp def checkHttp(self) Undocumented function.

connect def connect(self, serverList, successCallback=None, successArgs=[], failureCallback=None, failureArgs=[]) Attempts to establish a connection to the server. May return before the connection is established. The two callbacks represent the two functions to call (and their arguments) on success or failure, respectively. The failure callback also gets one additional parameter, which will be passed in first: the return status code giving reason for failure, if it is known.

disconnect def disconnect(self) Closes the previously-established connection.

generateGlobalObject def generateGlobalObject(self, doId, dcname, values=None) Undocumented function.

handleDatagram def handleDatagram(self, di) Undocumented function.

handleReaderOverflow def handleReaderOverflow(self) Undocumented function.

httpConnectCallback def httpConnectCallback(self, ch, serverList, serverIndex, successCallback, successArgs, failureCallback, failureArgs) Undocumented function.

importModule def importModule(self, dcImports, moduleName, importSymbols) Imports the indicated moduleName and all of its symbols into the current namespace. This more-or-less reimplements the Python import command.

lostConnection def lostConnection(self) Undocumented function.

networkPlugPulled def networkPlugPulled(self) Undocumented function.

pullNetworkPlug def pullNetworkPlug(self) Undocumented function.

readDCFile def readDCFile(self, dcFileNames=None) Reads in the dc files listed in dcFileNames, or if dcFileNames is None, reads in all of the dc files listed in the Configrc file.

readerPollOnce def readerPollOnce(self) Undocumented function.

readerPollUntilEmpty def readerPollUntilEmpty(self, task) Undocumented function.

restoreNetworkPlug def restoreNetworkPlug(self) Undocumented function.

send def send(self, datagram) Undocumented function.

startReaderPollTask def startReaderPollTask(self) Undocumented function.

stopReaderPollTask def stopReaderPollTask(self) Undocumented function.

checkDatagram bool CConnectionRepository::check_datagram(void); SIMULATE_NETWORK_DELAY Description: 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().

considerFlush bool CConnectionRepository::consider_flush(void); Description: 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 void CConnectionRepository::disconnect(void); Description: Closes the connection to the server.

flush bool CConnectionRepository::flush(void); Description: Sends the most recently queued data now. This only has meaning if set_collect_tcp() has been set to true.

getClientDatagram bool CConnectionRepository::get_client_datagram(void) const; Description: Returns the client_datagram flag.

getCw ConnectionWriter &CConnectionRepository::get_cw(void); Description: Returns the ConnectionWriter object associated with the repository.

getDatagram void CConnectionRepository::get_datagram(Datagram &dg); HAVE_NSPR Description: Fills the datagram object with the datagram most recently retrieved by check_datagram().

getDatagramIterator void CConnectionRepository::get_datagram_iterator(DatagramIterator &di); Description: 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 &CConnectionRepository::get_dc_file(void); Filename: cConnectionRepository.I Created by: drose (17May04) PANDA 3D SOFTWARE Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved All use of this software is subject to the terms of the Panda 3d Software license. You should have received a copy of this license along with this source code; you will also find a current copy of the license at http://etc.cmu.edu/panda3d/docs/license/ . To contact the maintainers of this program write to panda3d-general@lists.sourceforge.net . Description: Returns the DCFile object associated with this repository.

getMsgChannel unsigned __int64 CConnectionRepository::get_msg_channel(int offset = (0)) const; Description: Returns the channel from which the current message was sent, according to the datagram headers. This information is not available to the client.

getMsgChannelCount int CConnectionRepository::get_msg_channel_count(void) const; Undocumented function.

getMsgSender unsigned __int64 CConnectionRepository::get_msg_sender(void) const; Description: Returns the sender ID of the current message, according to the datagram headers. This information is not available to the client.

getMsgType unsigned int CConnectionRepository::get_msg_type(void) const; INLINE unsigned char get_sec_code() const; Description: 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; } Description: Returns the type ID of the current message, according to the datagram headers.

getOverflowEventName static string const &CConnectionRepository::get_overflow_event_name(void); Description: Returns event string that will be thrown if the datagram reader queue overflows.

getQcm QueuedConnectionManager &CConnectionRepository::get_qcm(void); Description: Returns the QueuedConnectionManager object associated with the repository.

getQcr QueuedConnectionReader &CConnectionRepository::get_qcr(void); Description: Returns the QueuedConnectionReader object associated with the repository.

getSimulatedDisconnect bool CConnectionRepository::get_simulated_disconnect(void) const; Description: 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 *CConnectionRepository::get_stream(void); Description: Returns the SocketStream that internally represents the already-established HTTP connection. Returns NULL if there is no current HTTP connection.

getVerbose bool CConnectionRepository::get_verbose(void) const; Description: Returns the current setting of the verbose flag. When true, this describes every message going back and forth on the wire.

hasOwnerView bool CConnectionRepository::has_owner_view(void) const; Description: Returns true if this repository can have 'owner' views of distributed objects.

isConnected bool CConnectionRepository::is_connected(void); Description: 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 CConnectionRepository::send_datagram(Datagram const &dg); Description: Queues the indicated datagram for sending to the server. It may not get send immediately if collect_tcp is in effect; call flush() to guarantee it is sent now.

setClientDatagram void CConnectionRepository::set_client_datagram(bool client_datagram); Description: 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 void CConnectionRepository::set_connection_http(HTTPChannel *channel); Description: 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().

setPythonRepository void CConnectionRepository::set_python_repository(PyObject *python_repository); Description: 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 void CConnectionRepository::set_simulated_disconnect(bool simulated_disconnect); Description: 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.

setVerbose void CConnectionRepository::set_verbose(bool verbose); Description: Directly sets the verbose flag. When true, this describes every message going back and forth on the wire.

toggleVerbose void CConnectionRepository::toggle_verbose(void); Description: Toggles the current setting of the verbose flag. When true, this describes every message going back and forth on the wire.

tryConnectNspr bool CConnectionRepository::try_connect_nspr(URLSpec const &url); Description: Uses NSPR to try to connect to the server and port named in the indicated URL. Returns true if successful, false otherwise.

__init__ def __init__(self) Undocumented function.

_considerRemoveInterest def _considerRemoveInterest(self, handle) Consider whether we should cull the interest set.

_getAddInterestEvent def _getAddInterestEvent(self) Undocumented function.

_getAnonymousEvent def _getAnonymousEvent(self, desc) Undocumented function.

_getInterestState def _getInterestState(self, handle) Undocumented function.

_getNextHandle def _getNextHandle(self) Undocumented function.

_getNextScopeId def _getNextScopeId(self) Undocumented function.

_getRemoveInterestEvent def _getRemoveInterestEvent(self) Undocumented function.

_sendAddInterest def _sendAddInterest(self, handle, scopeId, parentId, zoneIdList, description, action=None) Part of the new otp-server code. handle is a client-side created number that refers to a set of interests. The same handle number doesn't necessarily have any relationship to the same handle on another client.

_sendRemoveInterest def _sendRemoveInterest(self, handle, scopeId) handle is a client-side created number that refers to a set of interests. The same handle number doesn't necessarily have any relationship to the same handle on another client.

addInterest def addInterest(self, parentId, zoneIdList, description, event=None, auto=False) Look into a (set of) zone(s).

alterInterest def alterInterest(self, handle, parentId, zoneIdList, description=None, event=None) Removes old interests and adds new interests. Note that when an interest is changed, only the most recent change's event will be triggered. Previous events are abandoned. If this is a problem, consider opening multiple interests.

closeAutoInterests def closeAutoInterests(self, obj) Undocumented function.

getAllInterestsCompleteEvent def getAllInterestsCompleteEvent(self) Undocumented function.

handleInterestDoneMessage def handleInterestDoneMessage(self, di) This handles the interest done messages and may dispatch an event

noNewInterests def noNewInterests(self) Undocumented function.

openAutoInterests def openAutoInterests(self, obj) Undocumented function.

removeInterest def removeInterest(self, handle, event=None, auto=False) Stop looking in a (set of) zone(s)

setNoNewInterests def setNoNewInterests(self, flag) Undocumented function.

__init__ def __init__(self) Undocumented function.

addDOToTables def addDOToTables(self, do, location=None, ownerView=False) Undocumented function.

callbackWithDo def callbackWithDo(self, doId, callback) Undocumented function.

callbackWithOwnerView def callbackWithOwnerView(self, doId, callback) Undocumented function.

countObjects def countObjects(self, classType) Counts the number of objects of the given type in the repository (for testing purposes)

deleteDistributedObjects def deleteDistributedObjects(self) Undocumented function.

deleteObjectLocation def deleteObjectLocation(self, object, parentId, zoneId) Undocumented function.

doFind def doFind(self, str) Returns list of distributed objects with matching str in value.

doFindAll def doFindAll(self, str) Returns list of distributed objects with matching str in value.

findAnyOfType def findAnyOfType(self, type) Undocumented function.

getAllOfType def getAllOfType(self, type) Undocumented function.

getDo def getDo(self, doId) Undocumented function.

getDoIdList def getDoIdList(self, parentId, zoneId=None, classType=None) Undocumented function.

getDoList def getDoList(self, parentId, zoneId=None, classType=None) parentId is any distributed object id. zoneId is a uint32, defaults to None (all zones). Try zone 2 if you're not sure which zone to use (0 is a bad/null zone and 1 has had reserved use in the past as a no messages zone, while 2 has traditionally been a global, uber, misc stuff zone). dclassType is a distributed class type filter, defaults to None (no filter). If dclassName is None then all objects in the zone are returned; otherwise the list is filtered to only include objects of that type.

getDoTable def getDoTable(self, ownerView) Undocumented function.

getObjectsInZone def getObjectsInZone(self, parentId, zoneId) returns dict of doId:distObj for a zone. returned dict is safely mutable.

getObjectsOfClassInZone def getObjectsOfClassInZone(self, parentId, zoneId, objClass) returns dict of doId:object for a zone, containing all objects that inherit from 'class'. returned dict is safely mutable.

getOwnerView def getOwnerView(self, doId) Undocumented function.

getOwnerViewDoIdList def getOwnerViewDoIdList(self, classType) Undocumented function.

getOwnerViewDoList def getOwnerViewDoList(self, classType) Undocumented function.

handleObjectLocation def handleObjectLocation(self, di) Undocumented function.

handleSetLocation def handleSetLocation(self, di) Undocumented function.

isValidLocationTuple def isValidLocationTuple(self, location) Undocumented function.

removeDOFromTables def removeDOFromTables(self, do) Undocumented function.

storeObjectLocation def storeObjectLocation(self, object, parentId, zoneId) Undocumented function.