from direct.distributed.ClientRepository import ClientRepository
ClientRepository module: contains the ClientRepository class
- class ClientRepository(dcFileNames=None, dcSuffix='', connectMethod=None, threadedNet=None)[source]
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).
- GameGlobalsId = 0
Returns a newly-allocated doId. Call freeDoId() when the object has been deleted.
- createDistributedObject(self, className=None, distObj=None, zoneId=0, optionalFields=None, doId=None, reserveDoId=False)[source]
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.
- deleteObject(self, doId)[source]
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.
- doNotDeallocateChannel = True
- formatGenerate(self, distObj, extraFields)[source]
Returns a datagram formatted for sending the generate message for the indicated object.
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.
Returns true if this client has been assigned a range of doId’s it may use to create objects, false otherwise.
- isLocalId(self, doId)[source]
Returns true if this doId is one that we’re the owner of, false otherwise.
- notify = <direct.directnotify.Notifier.Notifier object>
- resendGenerate(self, obj)[source]
Sends the generate message again for an already-generated object, presumably to inform any newly-arrived clients of this object’s current state.
- reserveDoId(self, doId)[source]
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.
- sendUpdateToChannel(self, distObj, channelId, fieldName, args)[source]
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(self, interestZoneIds)[source]
Changes the set of zones that this particular client is interested in hearing about.