本文整理汇总了Python中PyDatagram.PyDatagram.addServerHeader方法的典型用法代码示例。如果您正苦于以下问题:Python PyDatagram.addServerHeader方法的具体用法?Python PyDatagram.addServerHeader怎么用?Python PyDatagram.addServerHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyDatagram.PyDatagram
的用法示例。
在下文中一共展示了PyDatagram.addServerHeader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getActivated
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addServerHeader [as 别名]
def getActivated(self, doId, callback):
ctx = self.getContext()
self.__callbacks[ctx] = callback
dg = PyDatagram()
dg.addServerHeader(doId, self.ourChannel, DBSS_OBJECT_GET_ACTIVATED)
dg.addUint32(ctx)
dg.addUint32(doId)
self.send(dg)
示例2: setClientState
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addServerHeader [as 别名]
def setClientState(self, clientChannel, state):
"""
Sets the state of the client on the CA.
Useful for logging in and logging out, and for little else.
"""
dg = PyDatagram()
dg.addServerHeader(clientChannel, self.ourChannel, CLIENTAGENT_SET_STATE)
dg.add_uint16(state)
self.send(dg)
示例3: eject
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addServerHeader [as 别名]
def eject(self, clientChannel, reasonCode, reason):
"""
Kicks the client residing at the specified clientChannel, using the specifed reasoning.
"""
dg = PyDatagram()
dg.addServerHeader(clientChannel, self.ourChannel, CLIENTAGENT_EJECT)
dg.add_uint16(reasonCode)
dg.addString(reason)
self.send(dg)
示例4: setOwner
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addServerHeader [as 别名]
def setOwner(self, doId, newOwner):
"""
Sets the owner of a DistributedObject. This will enable the new owner to send "ownsend" fields,
and will generate an OwnerView.
"""
dg = PyDatagram()
dg.addServerHeader(doId, self.ourChannel, STATESERVER_OBJECT_SET_OWNER)
dg.add_uint64(newOwner)
self.send(dg)
示例5: setAI
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addServerHeader [as 别名]
def setAI(self, doId, aiChannel):
"""
Sets the AI of the specified DistributedObjectAI to be the specified channel.
Generally, you should not call this method, and instead call DistributedObjectAI.setAI.
"""
dg = PyDatagram()
dg.addServerHeader(doId, aiChannel, STATESERVER_OBJECT_SET_AI)
dg.add_uint64(aiChannel)
self.send(dg)
示例6: requestDelete
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addServerHeader [as 别名]
def requestDelete(self, do):
"""
Request the deletion of an object that already exists on the State Server.
You should probably use do.requestDelete() instead.
"""
dg = PyDatagram()
dg.addServerHeader(do.doId, self.ourChannel, STATESERVER_OBJECT_DELETE_RAM)
dg.addUint32(do.doId)
self.send(dg)
示例7: clientAddSessionObject
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addServerHeader [as 别名]
def clientAddSessionObject(self, clientChannel, doId):
"""
Declares the specified DistributedObject to be a "session object",
meaning that it is destroyed when the client disconnects.
Generally used for avatars owned by the client.
"""
dg = PyDatagram()
dg.addServerHeader(clientChannel, self.ourChannel, CLIENTAGENT_ADD_SESSION_OBJECT)
dg.add_uint32(doId)
self.send(dg)
示例8: requestDelete
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addServerHeader [as 别名]
def requestDelete(self, do):
"""
Request the deletion of an object that already exists on the State Server.
You should use do.requestDelete() instead. This is not meant to be
called directly unless you really know what you are doing.
"""
dg = PyDatagram()
dg.addServerHeader(do.doId, self.ourChannel, STATESERVER_OBJECT_DELETE_RAM)
dg.addUint32(do.doId)
self.send(dg)
示例9: clientAddInterest
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addServerHeader [as 别名]
def clientAddInterest(self, clientChannel, interestId, parentId, zoneId):
"""
Opens an interest on the behalf of the client. This, used in conjunction
with add_interest: visible (or preferably, disabled altogether), will mitigate
possible security risks.
"""
dg = PyDatagram()
dg.addServerHeader(clientChannel, self.ourChannel, CLIENTAGENT_ADD_INTEREST)
dg.add_uint16(interestId)
dg.add_uint32(parentId)
dg.add_uint32(zoneId)
self.send(dg)
示例10: getNetworkAddress
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addServerHeader [as 别名]
def getNetworkAddress(self, clientId, callback):
"""
Get the endpoints of a client connection.
You should already be sure the client actually exists, otherwise the
callback will never be called.
Callback is called as: callback(remoteIp, remotePort, localIp, localPort)
"""
ctx = self.getContext()
self.__callbacks[ctx] = callback
dg = PyDatagram()
dg.addServerHeader(clientId, self.ourChannel, CLIENTAGENT_GET_NETWORK_ADDRESS)
dg.addUint32(ctx)
self.send(dg)
示例11: getLocation
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addServerHeader [as 别名]
def getLocation(self, doId, callback):
"""
Ask a DistributedObject where it is.
You should already be sure the object actually exists, otherwise the
callback will never be called.
Callback is called as: callback(doId, parentId, zoneId)
"""
ctx = self.getContext()
self.__callbacks[ctx] = callback
dg = PyDatagram()
dg.addServerHeader(doId, self.ourChannel, STATESERVER_OBJECT_GET_LOCATION)
dg.addUint32(ctx)
self.send(dg)
示例12: getObject
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addServerHeader [as 别名]
def getObject(self, doId, callback):
"""
Get the entire state of an object.
You should already be sure the object actually exists, otherwise the
callback will never be called.
Callback is called as: callback(doId, parentId, zoneId, dclass, fields)
"""
ctx = self.getContext()
self.__callbacks[ctx] = callback
dg = PyDatagram()
dg.addServerHeader(doId, self.ourChannel, STATESERVER_OBJECT_GET_ALL)
dg.addUint32(ctx)
dg.addUint32(doId)
self.send(dg)
示例13: __connected
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addServerHeader [as 别名]
def __connected(self):
self.notify.info('Connected successfully.')
# Listen to our channel...
self.registerForChannel(self.ourChannel)
# If we're configured with a State Server, register a post-remove to
# clean up whatever objects we own on this server should we unexpectedly
# fall over and die.
if self.serverId:
dg = PyDatagram()
dg.addServerHeader(self.serverId, self.ourChannel, STATESERVER_DELETE_AI_OBJECTS)
dg.addChannel(self.ourChannel)
self.addPostRemove(dg)
messenger.send('airConnected')
self.handleConnected()
示例14: queryObject
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addServerHeader [as 别名]
def queryObject(self, databaseId, doId, callback):
"""
Query object `doId` out of the database.
On success, the callback will be invoked as callback(dclass, fields)
where dclass is a DCClass instance and fields is a dict.
On failure, the callback will be invoked as callback(None, None).
"""
# Save the callback:
ctx = self.air.getContext()
self._callbacks[ctx] = callback
# Generate and send the datagram:
dg = PyDatagram()
dg.addServerHeader(databaseId, self.air.ourChannel, DBSERVER_OBJECT_GET_ALL)
dg.addUint32(ctx)
dg.addUint32(doId)
self.air.send(dg)
示例15: sendActivate
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addServerHeader [as 别名]
def sendActivate(self, doId, parentId, zoneId, dclass=None, fields=None):
"""
Activate a DBSS object, given its doId, into the specified parentId/zoneId.
If both dclass and fields are specified, an ACTIVATE_WITH_DEFAULTS_OTHER
will be sent instead. In other words, the specified fields will be
auto-applied during the activation.
"""
fieldPacker = DCPacker()
fieldCount = 0
if dclass and fields:
for k, v in fields.items():
field = dclass.getFieldByName(k)
if not field:
self.notify.error(
"Activation request for %s object contains " "invalid field named %s" % (dclass.getName(), k)
)
fieldPacker.rawPackUint16(field.getNumber())
fieldPacker.beginPack(field)
field.packArgs(fieldPacker, v)
fieldPacker.endPack()
fieldCount += 1
dg = PyDatagram()
dg.addServerHeader(doId, self.ourChannel, DBSS_OBJECT_ACTIVATE_WITH_DEFAULTS)
dg.addUint32(doId)
dg.addUint32(0)
dg.addUint32(0)
self.send(dg)
# DEFAULTS_OTHER isn't implemented yet, so we chase it with a SET_FIELDS
dg = PyDatagram()
dg.addServerHeader(doId, self.ourChannel, STATESERVER_OBJECT_SET_FIELDS)
dg.addUint32(doId)
dg.addUint16(fieldCount)
dg.appendData(fieldPacker.getString())
self.send(dg)
# Now slide it into the zone we expect to see it in (so it
# generates onto us with all of the fields in place)
dg = PyDatagram()
dg.addServerHeader(doId, self.ourChannel, STATESERVER_OBJECT_SET_LOCATION)
dg.addUint32(parentId)
dg.addUint32(zoneId)
self.send(dg)
else:
dg = PyDatagram()
dg.addServerHeader(doId, self.ourChannel, DBSS_OBJECT_ACTIVATE_WITH_DEFAULTS)
dg.addUint32(doId)
dg.addUint32(parentId)
dg.addUint32(zoneId)
self.send(dg)