Panda3D
Loading...
Searching...
No Matches
ClientRepository Class Reference
Inheritance diagram for ClientRepository:
ClientRepositoryBase ConnectionRepository DoInterestManager DoCollectionManager DirectObject

Public Member Functions

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

Public Attributes

 currentSenderId = None
 
 doIdAllocator = None
 
int doIdBase = 0
 
int doIdLast = 0
 
list interestZones = []
 
int ourChannel = self.doIdBase
 
- Public Attributes inherited from ClientRepositoryBase
 cache = CRCache.CRCache()
 
 cacheOwner = CRCache.CRCache()
 
int context = 100000
 
int deferInterval = deferInterval
 
dict deferredDoIds = {}
 
list deferredGenerates = []
 
 doDataCache = CRDataCache()
 
 doDeferredGenerate
 
 heartbeatInterval = base.config.GetDouble('heartbeat-interval', 10)
 
int heartbeatStarted = 0
 
int lastGenerate = 0
 
int lastHeartbeat = 0
 
bool noDefer = False
 
 parentMgr = ParentMgr.ParentMgr()
 
 relatedObjectMgr = RelatedObjectMgr.RelatedObjectMgr(self)
 
 sendHeartbeatTask
 
int serverDelta = 0
 
int specialNameNumber = 0
 
 timeManager = None
 
- Public Attributes inherited from ConnectionRepository
 bootedIndex = None
 
 bootedText = None
 
 config = config
 
 connectHttp = None
 
int connectMethod = connectMethod
 
dict dclassesByName = {}
 
dict dclassesByNumber = {}
 
str dcSuffix = ''
 
 handleReaderOverflow
 
int hashVal = 0
 
 http = None
 
 lostConnection
 
 private__di = PyDatagramIterator()
 
 readerPollTaskObj = None
 
 recorder = None
 
 uniqueId = hash(self)
 
- Public Attributes inherited from DoCollectionManager
dict doId2do = {}
 location = do.getLocation() if location is not None: if location not in self.zoneId2doIds: self.notify.warning( 'dobj s (s) has invalid location: s' % (do, do.doId, location)) else: assert do.doId in self.zoneId2doIds[location] del self.zoneId2doIds[location][do.doId] if len(self.zoneId2doIds[location]) == 0: del self.zoneId2doIds[location]
 
dict doId2ownerView = {}
 self.zoneId2doIds={}
 
 getDo
 

Static Public Attributes

bool doNotDeallocateChannel = True
 
int GameGlobalsId = 0
 
- Static Public Attributes inherited from ConnectionRepository
int CM_HTTP = 0
 
int CM_NATIVE = 2
 
int CM_NET = 1
 
str GarbageCollectTaskName = "allowGarbageCollect"
 
str GarbageThresholdTaskName = "adjustGarbageCollectThreshold"
 
 gcNotify = directNotify.newCategory("GarbageCollect")
 
 taskChain = None
 
int taskPriority = -30
 
- Static Public Attributes inherited from DoInterestManager
 InterestDebug = ConfigVariableBool('interest-debug', False)
 
 notify = directNotify.newCategory("DoInterestManager")
 
- Static Public Attributes inherited from DirectObject
 accept_once = acceptOnce
 
 add_task = addTask
 
 detect_leaks = detectLeaks
 
 do_method_later = doMethodLater
 
 get_all_accepting = getAllAccepting
 
 ignore_all = ignoreAll
 
 is_accepting = isAccepting
 
 is_ignoring = isIgnoring
 
 remove_all_tasks = removeAllTasks
 
 remove_task = removeTask
 

Additional Inherited Members

- Protected Member Functions inherited from ClientRepositoryBase
 _addDelayDeletedDO (self, do)
 
 _getMsgName (self, msgId)
 
 _logFailedDisable (self, doId, ownerView)
 
 _removeDelayDeletedDO (self, do)
 
- Protected Member Functions inherited from ConnectionRepository
 _adjustGcThreshold (self, task)
 
 _garbageCollect (self, task=None)
 
 _getLostConnectionEvent (self)
 
- Protected Member Functions inherited from DoInterestManager
 _addDebugInterestHistory (self, action, description, handle, contextId, parentId, zoneIdList)
 
 _considerRemoveInterest (self, handle)
 
 _getAddInterestEvent (self)
 
 _getAnonymousEvent (self, desc)
 
 _getInterestState (self, handle)
 
 _getNextContextId (self)
 
 _getNextHandle (self)
 
 _getRemoveInterestEvent (self)
 
 _sendAddInterest (self, handle, contextId, parentId, zoneIdList, description, action=None)
 
 _sendRemoveAIInterest (self, handle)
 
 _sendRemoveInterest (self, handle, contextId)
 
- Protected Member Functions inherited from DirectObject
 _addTask (self, task)
 
 _clearTask (self, task)
 
- Protected Member Functions inherited from DoCollectionManager
 _compareDistance (self, do1, do2)
 
 _getDistanceFromLA (self, do)
 
 _printObjects (self, table)
 
 _returnObjects (self, table)
 
- Protected Attributes inherited from ClientRepositoryBase
dict _delayDeletedDOs = {}
 
- Protected Attributes inherited from ConnectionRepository
 _adjustGcThreshold
 
 _garbageCollect
 
 _gcDefaultThreshold = gc.get_threshold()
 
str _serverAddress = ''
 
- Protected Attributes inherited from DoInterestManager
 _addInterestEvent = uniqueName('DoInterestManager-Add')
 
list _allInterestsCompleteCallbacks = []
 
 _completeDelayedCallback = None
 
 _completeEventCount = ScratchPad(num=0)
 
bool _noNewInterests = False
 
 _removeInterestEvent = uniqueName('DoInterestManager-Remove')
 
- Protected Attributes inherited from DirectObject
dict _taskList = {}
 
- Protected Attributes inherited from DoCollectionManager
 _doHierarchy = DoHierarchy.DoHierarchy()
 
- Static Protected Attributes inherited from DoInterestManager
int _ContextIdMask = 0x3FFFFFFF
 
int _ContextIdSerialNum = 100
 
list _debug_interestHistory = []
 
int _debug_maxDescriptionLen = 40
 
int _HandleMask = 0x7FFF
 
int _HandleSerialNum = 0
 
dict _interests = {}
 
 _SerialGen = SerialNumGen()
 
 _SerialNum = serialNum()
 

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

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

Member Function Documentation

◆ allocateDoId()

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

◆ createDistributedObject()

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

createReady ( self)

◆ deleteObject()

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

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

◆ freeDoId()

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

◆ getAvatarIdFromSender()

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

handleDatagram ( self,
di )

Reimplemented from ConnectionRepository.

◆ handleDelete()

handleDelete ( self,
di )

Reimplemented from ClientRepositoryBase.

◆ handleDisable()

handleDisable ( self,
di )

◆ handleGenerate()

handleGenerate ( self,
di )

◆ handleMessageType()

handleMessageType ( self,
msgType,
di )

◆ handleRequestGenerates()

handleRequestGenerates ( self,
di )

◆ handleSetDoIdrange()

handleSetDoIdrange ( self,
di )

◆ handleUpdateField()

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

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

◆ isLocalId()

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

Reimplemented from ClientRepositoryBase.

◆ resendGenerate()

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

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

sendDeleteMsg ( self,
doId )

◆ sendDisconnect()

sendDisconnect ( self)

◆ sendHeartbeat()

sendHeartbeat ( self)

◆ sendSetLocation()

sendSetLocation ( self,
doId,
parentId,
zoneId )

◆ sendUpdate()

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

◆ sendUpdateToChannel()

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

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

◆ setObjectZone()

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

◆ stopTrackRequestDeletedDO()

stopTrackRequestDeletedDO ( self,
* args )

◆ storeObjectLocation()

storeObjectLocation ( self,
object,
parentId,
zoneId )

Reimplemented from DoCollectionManager.

Member Data Documentation

◆ currentSenderId

currentSenderId = None

◆ doIdAllocator

doIdAllocator = None

◆ doIdBase

doIdBase = 0

◆ doIdLast

int doIdLast = 0

◆ doNotDeallocateChannel

bool doNotDeallocateChannel = True
static

◆ GameGlobalsId

int GameGlobalsId = 0
static

◆ interestZones

list interestZones = []

◆ ourChannel

int ourChannel = self.doIdBase