Panda3D
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
ClientRepository Class Reference
Inheritance diagram for ClientRepository:
ClientRepositoryBase ConnectionRepository DoInterestManager DoCollectionManager CConnectionRepository

Public Member Functions

def __init__ (self, dcFileNames=None, dcSuffix='', connectMethod=None, threadedNet=None)
 
def allocateDoId (self)
 
def createDistributedObject (self, className=None, distObj=None, zoneId=0, optionalFields=None, doId=None, reserveDoId=False)
 
def createReady (self)
 
def deleteObject (self, doId)
 
def formatGenerate (self, distObj, extraFields)
 
def freeDoId (self, doId)
 
def getAvatarIdFromSender (self)
 
def handleDatagram (self, di)
 
def handleDelete (self, di)
 
def handleDisable (self, di)
 
def handleGenerate (self, di)
 
def handleMessageType (self, msgType, di)
 
def handleRequestGenerates (self, di)
 
def handleSetDoIdrange (self, di)
 
def handleUpdateField (self, di)
 
def haveCreateAuthority (self)
 
def isLocalId (self, doId)
 
def resendGenerate (self, obj)
 
def reserveDoId (self, doId)
 
def sendDeleteMsg (self, doId)
 
def sendDisconnect (self)
 
def sendHeartbeat (self)
 
def sendSetLocation (self, doId, parentId, zoneId)
 
def sendUpdate (self, distObj, fieldName, args)
 
def sendUpdateToChannel (self, distObj, channelId, fieldName, args)
 
def setInterestZones (self, interestZoneIds)
 
def setObjectZone (self, distObj, zoneId)
 
def stopTrackRequestDeletedDO (self, *args)
 
def storeObjectLocation (self, object, parentId, zoneId)
 
- Public Member Functions inherited from ClientRepositoryBase
def allocateContext (self)
 
def considerHeartbeat (self)
 
def disableDoId (self, doId, ownerView=False)
 
def doDeferredGenerate (self, task)
 
def doGenerate (self, parentId, zoneId, classId, doId, di)
 
def flushGenerates (self)
 
def generateWithRequiredFields (self, dclass, doId, di, parentId, zoneId)
 
def generateWithRequiredOtherFields (self, dclass, doId, di, parentId=None, zoneId=None)
 
def generateWithRequiredOtherFieldsOwner (self, dclass, doId, di)
 
def getObjectsOfClass (self, objClass)
 
def getObjectsOfExactClass (self, objClass)
 
def getServerDelta (self)
 
def getServerTimeOfDay (self)
 
def getTables (self, ownerView)
 
def getWorld (self, doId)
 
def handleGoGetLost (self, di)
 
def handleServerHeartbeat (self, di)
 
def handleSystemMessage (self, di)
 
def handleSystemMessageAknowledge (self, di)
 
def isLive (self)
 
def printDelayDeletes (self)
 
def replaceMethod (self, oldMethod, newFunction)
 
def replayDeferredGenerate (self, msgType, extra)
 
def sendHeartbeatTask (self, task)
 
def setDeferInterval (self, deferInterval)
 
def setServerDelta (self, delta)
 
def specialName (self, label)
 def queryObjectAll(self, doID, context=0): """ Get a one-time snapshot look at the object. More...
 
def startHeartbeat (self)
 
def stopHeartbeat (self)
 
def waitForNextHeartBeat (self)
 
- Public Member Functions inherited from ConnectionRepository
def checkHttp (self)
 
def connect (self, serverList, successCallback=None, successArgs=[], failureCallback=None, failureArgs=[])
 
def disconnect (self)
 
def generateGlobalObject (self, doId, dcname, values=None)
 
def getServerAddress (self)
 
def handleReaderOverflow (self)
 
def httpConnectCallback (self, ch, serverList, serverIndex, successCallback, successArgs, failureCallback, failureArgs)
 
def importModule (self, dcImports, moduleName, importSymbols)
 
def lostConnection (self)
 
def readDCFile (self, dcFileNames=None)
 
def readerPollOnce (self)
 
def readerPollUntilEmpty (self, task)
 
def send (self, datagram)
 
def shutdown (self)
 
def startReaderPollTask (self)
 
def stopReaderPollTask (self)
 
- Public Member Functions inherited from DoInterestManager
def __init__ (self)
 
def addAutoInterest (self, parentId, zoneIdList, description)
 
def addInterest (self, parentId, zoneIdList, description, event=None)
 
def alterInterest (self, handle, parentId, zoneIdList, description=None, event=None)
 
def cleanupWaitAllInterestsComplete (self)
 
def closeAutoInterests (self, obj)
 
def getAllInterestsCompleteEvent (self)
 
def handleInterestDoneMessage (self, di)
 
def isValidInterestHandle (self, handle)
 
def noNewInterests (self)
 
def openAutoInterests (self, obj)
 
def printInterestHistory (self)
 
def printInterests (self)
 
def printInterestSets (self)
 
def printInterestsIfDebug (self)
 
def queueAllInterestsCompleteEvent (self, frames=5)
 
def removeAIInterest (self, handle)
 
def removeAutoInterest (self, handle)
 
def removeInterest (self, handle, event=None)
 
def resetInterestStateForConnectionLoss (self)
 
def setAllInterestsCompleteCallback (self, callback)
 
def setNoNewInterests (self, flag)
 
def updateInterestDescription (self, handle, desc)
 
- Public Member Functions inherited from DoCollectionManager
def __init__ (self)
 
def addDOToTables (self, do, location=None, ownerView=False)
 
def callbackWithDo (self, doId, callback)
 
def callbackWithOwnerView (self, doId, callback)
 
def countObjects (self, classType)
 
def deleteDistributedObjects (self)
 
def deleteObjectLocation (self, object, parentId, zoneId)
 
def doByDistance (self)
 
def doFind (self, str)
 
def doFindAll (self, str)
 
def doFindAllInstances (self, cls)
 
def doFindAllMatching (self, str)
 
def doFindAllOfType (self, query)
 
def dosByDistance (self)
 
def findAnyOfType (self, type)
 
def getAllOfType (self, type)
 
def getDo (self, doId)
 
def getDoIdList (self, parentId, zoneId=None, classType=None)
 
def getDoList (self, parentId, zoneId=None, classType=None)
 
def getDoTable (self, ownerView)
 
def getGameDoId (self)
 
def getObjectsInZone (self, parentId, zoneId)
 def changeDOZoneInTables(self, do, newParentId, newZoneId, oldParentId, oldZoneId): if 1: self.storeObjectLocation(do.doId, newParentId, newZoneId) else: #assert not hasattr(do, "isQueryAllResponse") or not do.isQueryAllResponse oldLocation = (oldParentId, oldZoneId) newLocation = (newParentId, newZoneId) More...
 
def getObjectsOfClassInZone (self, parentId, zoneId, objClass)
 
def getOwnerView (self, doId)
 
def getOwnerViewDoIdList (self, classType)
 
def getOwnerViewDoList (self, classType)
 
def handleObjectLocation (self, di)
 
def handleSetLocation (self, di)
 
def hasOwnerViewDoId (self, doId)
 
def isInDoTables (self, doId)
 
def isValidLocationTuple (self, location)
 
def printObjectCount (self)
 
def printObjects (self)
 
def removeDOFromTables (self, do)
 
def webPrintObjectCount (self)
 
- Public Member Functions inherited from CConnectionRepository
 __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...
 

Public Attributes

 currentSenderId
 
 doIdAllocator
 
 doIdBase
 
 doIdLast
 
 interestZones
 
 lastHeartbeat
 
 ourChannel
 
- Public Attributes inherited from ClientRepositoryBase
 bootedIndex
 
 bootedText
 
 cache
 
 cacheOwner
 
 context
 
 dcSuffix
 
 deferInterval
 
 deferredDoIds
 
 deferredGenerates
 
 doDataCache
 
 heartbeatInterval
 
 heartbeatStarted
 
 lastGenerate
 
 lastHeartbeat
 
 noDefer
 
 parentMgr
 
 recorder
 
 relatedObjectMgr
 
 serverDelta
 
 specialNameNumber
 
 timeManager
 
- Public Attributes inherited from ConnectionRepository
 bootedIndex
 if self.recorder and self.recorder.isPlaying(): More...
 
 bootedText
 
 config
 
 connectHttp
 
 connectMethod
 
 dclassesByName
 
 dclassesByNumber
 
 dcSuffix
 
 hashVal
 
 http
 
 private__di
 
 readerPollTaskObj
 
 recorder
 
 uniqueId
 
- Public Attributes inherited from DoCollectionManager
 doId2do
 
 doId2ownerView
 self.zoneId2doIds={} More...
 

Static Public Attributes

bool doNotDeallocateChannel = True
 
int GameGlobalsId = 0
 
 notify = DirectNotifyGlobal.directNotify.newCategory("ClientRepository")
 
- Static Public Attributes inherited from ClientRepositoryBase
 notify = DirectNotifyGlobal.directNotify.newCategory("ClientRepositoryBase")
 
- Static Public Attributes inherited from ConnectionRepository
int CM_HTTP = 0
 
int CM_NATIVE = 2
 
int CM_NET = 1
 
string GarbageCollectTaskName = "allowGarbageCollect"
 
string GarbageThresholdTaskName = "adjustGarbageCollectThreshold"
 
 gcNotify = directNotify.newCategory("GarbageCollect")
 
 notify = directNotify.newCategory("ConnectionRepository")
 
 taskChain = None
 
int taskPriority = -30
 
- Static Public Attributes inherited from DoInterestManager
 dConfigParam
 
 InterestDebug = ConfigVariableBool('interest-debug', False)
 
 notify = directNotify.newCategory("DoInterestManager")
 
 types
 

Additional Inherited Members

- Static Public Member Functions inherited from CConnectionRepository
static str getOverflowEventName ()
 Returns event string that will be thrown if the datagram reader queue overflows. More...
 

Detailed Description

This is the open-source ClientRepository as provided by CMU.  It
communicates with the ServerRepository in this same directory.

If you are looking for the VR Studio's implementation of the
client repository, look to OTPClientRepository (elsewhere).

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  dcFileNames = None,
  dcSuffix = '',
  connectMethod = None,
  threadedNet = None 
)

Reimplemented from ClientRepositoryBase.

Member Function Documentation

◆ allocateDoId()

def allocateDoId (   self)
Returns a newly-allocated doId.  Call freeDoId() when the
object has been deleted. 

◆ createDistributedObject()

def createDistributedObject (   self,
  className = None,
  distObj = None,
  zoneId = 0,
  optionalFields = None,
  doId = None,
  reserveDoId = False 
)
To create a DistributedObject, you must pass in either the
name of the object's class, or an already-created instance of
the class (or both).  If you pass in just a class name (to the
className parameter), then a default instance of the object
will be created, with whatever parameters the default
constructor supplies.  Alternatively, if you wish to create
some initial values different from the default, you can create
the instance yourself and supply it to the distObj parameter,
then that instance will be used instead.  (It should be a
newly-created object, not one that has already been manifested
on the network or previously passed through
createDistributedObject.)  In either case, the new
DistributedObject is returned from this method.

This method will issue the appropriate network commands to
make this object appear on all of the other clients.

You should supply an initial zoneId in which to manifest the
object.  The fields marked "required" or "ram" will be
broadcast to all of the other clients; if you wish to
broadcast additional field values at this time as well, pass a
list of field names in the optionalFields parameters.

Normally, doId is None, to mean allocate a new doId for the
object.  If you wish to use a particular doId, pass it in
here.  If you also pass reserveDoId = True, this doId will be
reserved from the allocation pool using self.reserveDoId().
You are responsible for ensuring this doId falls within the
client's allowable doId range and has not already been
assigned to another object.  

◆ createReady()

def createReady (   self)

◆ deleteObject()

def deleteObject (   self,
  doId 
)
Removes the object from the client's view of the world.  This
should normally not be called directly except in the case of
error recovery, since the server will normally be responsible
for deleting and disabling objects as they go out of scope.

After this is called, future updates by server on this object
will be ignored (with a warning message).  The object will
become valid again the next time the server sends a generate
message for this doId.

This is not a distributed message and does not delete the
object on the server or on any other client.

◆ formatGenerate()

def formatGenerate (   self,
  distObj,
  extraFields 
)
Returns a datagram formatted for sending the generate message for the indicated object. 

◆ freeDoId()

def freeDoId (   self,
  doId 
)
Returns a doId back into the free pool for re-use. 

◆ getAvatarIdFromSender()

def getAvatarIdFromSender (   self)
Returns the doIdBase of the client that originally sent
the current update message.  This is only defined when
processing an update message or a generate message. 

◆ handleDatagram()

def handleDatagram (   self,
  di 
)

Reimplemented from ConnectionRepository.

◆ handleDelete()

def handleDelete (   self,
  di 
)

Reimplemented from ClientRepositoryBase.

◆ handleDisable()

def handleDisable (   self,
  di 
)

◆ handleGenerate()

def handleGenerate (   self,
  di 
)

◆ handleMessageType()

def handleMessageType (   self,
  msgType,
  di 
)

◆ handleRequestGenerates()

def handleRequestGenerates (   self,
  di 
)

◆ handleSetDoIdrange()

def handleSetDoIdrange (   self,
  di 
)

◆ 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.

Reimplemented from ClientRepositoryBase.

◆ haveCreateAuthority()

def haveCreateAuthority (   self)
Returns true if this client has been assigned a range of
doId's it may use to create objects, false otherwise. 

◆ isLocalId()

def isLocalId (   self,
  doId 
)
Returns true if this doId is one that we're the owner of,
false otherwise. 

Reimplemented from ClientRepositoryBase.

◆ resendGenerate()

def resendGenerate (   self,
  obj 
)
Sends the generate message again for an already-generated
object, presumably to inform any newly-arrived clients of this
object's current state. 

◆ reserveDoId()

def reserveDoId (   self,
  doId 
)
Removes the indicate doId from the available pool, as if
it had been explicitly allocated.  You may pass it to
freeDoId() later if you wish. 

◆ sendDeleteMsg()

def sendDeleteMsg (   self,
  doId 
)

◆ sendDisconnect()

def sendDisconnect (   self)

◆ sendHeartbeat()

def sendHeartbeat (   self)

◆ sendSetLocation()

def sendSetLocation (   self,
  doId,
  parentId,
  zoneId 
)

◆ sendUpdate()

def sendUpdate (   self,
  distObj,
  fieldName,
  args 
)
Sends a normal update for a single field. 

◆ sendUpdateToChannel()

def sendUpdateToChannel (   self,
  distObj,
  channelId,
  fieldName,
  args 
)
Sends a targeted update of a single field to a particular
client.  The top 32 bits of channelId is ignored; the lower 32
bits should be the client Id of the recipient (i.e. the
client's doIdbase).  The field update will be sent to the
indicated client only.  The field must be marked clsend or
p2p, and may not be marked broadcast. 

◆ setInterestZones()

def setInterestZones (   self,
  interestZoneIds 
)
Changes the set of zones that this particular client is
interested in hearing about. 

◆ setObjectZone()

def setObjectZone (   self,
  distObj,
  zoneId 
)
Moves the object into the indicated zone. 

◆ stopTrackRequestDeletedDO()

def stopTrackRequestDeletedDO (   self,
args 
)

◆ storeObjectLocation()

def storeObjectLocation (   self,
  object,
  parentId,
  zoneId 
)

Reimplemented from DoCollectionManager.

Member Data Documentation

◆ currentSenderId

currentSenderId

◆ doIdAllocator

doIdAllocator

◆ doIdBase

doIdBase

◆ doIdLast

doIdLast

◆ doNotDeallocateChannel

bool doNotDeallocateChannel = True
static

◆ GameGlobalsId

int GameGlobalsId = 0
static

◆ interestZones

interestZones

◆ lastHeartbeat

lastHeartbeat

◆ notify

notify = DirectNotifyGlobal.directNotify.newCategory("ClientRepository")
static

◆ ourChannel

ourChannel