本文整理汇总了Python中PyDatagram.PyDatagram.addUint16方法的典型用法代码示例。如果您正苦于以下问题:Python PyDatagram.addUint16方法的具体用法?Python PyDatagram.addUint16怎么用?Python PyDatagram.addUint16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyDatagram.PyDatagram
的用法示例。
在下文中一共展示了PyDatagram.addUint16方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _sendAddInterest
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addUint16 [as 别名]
def _sendAddInterest(self, contextId, scopeId, parentId, zoneIdList):
"""
Part of the new otp-server code.
contextId is a client-side created number that refers to
a set of interests. The same contextId number doesn't
necessarily have any relationship to the same contextId
on another client.
"""
assert self.notify.debugCall()
datagram = PyDatagram()
# Add message type
datagram.addUint16(CLIENT_ADD_INTEREST)
datagram.addUint16(contextId)
datagram.addUint32(scopeId)
datagram.addUint32(parentId)
if isinstance(zoneIdList, types.ListType):
vzl = list(zoneIdList)
vzl.sort()
PythonUtil.uniqueElements(vzl)
for zone in vzl:
datagram.addUint32(zone)
else:
datagram.addUint32(zoneIdList)
self.send(datagram)
示例2: sendSetLocation
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addUint16 [as 别名]
def sendSetLocation(self, doId, parentId, zoneId):
datagram = PyDatagram()
datagram.addUint16(CLIENT_OBJECT_LOCATION)
datagram.addUint32(doId)
datagram.addUint32(parentId)
datagram.addUint32(zoneId)
self.send(datagram)
示例3: _sendRemoveInterest
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addUint16 [as 别名]
def _sendRemoveInterest(self, handle, contextId):
datagram = PyDatagram()
datagram.addUint16(CLIENT_REMOVE_INTEREST)
datagram.addUint16(handle)
if contextId != 0:
datagram.addUint32(contextId)
self.send(datagram)
示例4: sendDeleteMsg
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addUint16 [as 别名]
def sendDeleteMsg(self, doId):
# This method is only used in conjunction with the CMU LAN
# server.
datagram = PyDatagram()
datagram.addUint16(CLIENT_OBJECT_DELETE)
datagram.addUint32(doId)
self.send(datagram)
示例5: sendSetShardMsg
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addUint16 [as 别名]
def sendSetShardMsg(self, shardId):
datagram = PyDatagram()
# Add message type
datagram.addUint16(CLIENT_SET_SHARD)
# Add shard id
datagram.addUint32(shardId)
# send the message
self.send(datagram)
示例6: _sendRemoveAIInterest
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addUint16 [as 别名]
def _sendRemoveAIInterest(self, handle):
"""
handle is a bare int, NOT an InterestHandle. Use this to
close an AI opened interest.
"""
datagram = PyDatagram()
# Add message type
datagram.addUint16(CLIENT_REMOVE_INTEREST)
datagram.addUint16((1<<15) + handle)
self.send(datagram)
示例7: sendHeartbeat
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addUint16 [as 别名]
def sendHeartbeat(self):
datagram = PyDatagram()
# Add message type
datagram.addUint16(CLIENT_HEARTBEAT)
# Send it!
self.send(datagram)
self.lastHeartbeat = globalClock.getRealTime()
# This is important enough to consider flushing immediately
# (particularly if we haven't run readerPollTask recently).
self.considerFlush()
示例8: sendDisconnect
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addUint16 [as 别名]
def sendDisconnect(self):
if self.isConnected():
# Tell the game server that we're going:
datagram = PyDatagram()
# Add message type
datagram.addUint16(CLIENT_DISCONNECT)
# Send the message
self.send(datagram)
self.notify.info("Sent disconnect message to server")
self.disconnect()
self.stopHeartbeat()
示例9: sendActivate
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addUint16 [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)
示例10: _sendRemoveInterest
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addUint16 [as 别名]
def _sendRemoveInterest(self, contextId):
"""
contextId is a client-side created number that refers to
a set of interests. The same contextId number doesn't
necessarily have any relationship to the same contextId
on another client.
"""
assert self.notify.debugCall()
datagram = PyDatagram()
# Add message type
datagram.addUint16(CLIENT_REMOVE_INTEREST)
datagram.addUint16(contextId)
self.send(datagram)
示例11: __getBarrierData
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addUint16 [as 别名]
def __getBarrierData(self):
# Returns the barrier data formatted as a blob for sending to
# the clients. This lists all of the current outstanding
# barriers and the avIds waiting for them.
dg = PyDatagram()
for context, barrier in self.__barriers.items():
toons = barrier.pendingToons
if toons:
dg.addUint16(context)
dg.addUint16(len(toons))
for avId in toons:
dg.addUint32(avId)
return dg.getMessage()
示例12: setInterestZones
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addUint16 [as 别名]
def setInterestZones(self, interestZoneIds):
""" Changes the set of zones that this particular client is
interested in hearing about. """
datagram = PyDatagram()
# Add message type
datagram.addUint16(CLIENT_SET_INTEREST_CMU)
for zoneId in interestZoneIds:
datagram.addUint32(zoneId)
# send the message
self.send(datagram)
self.interestZones = interestZoneIds[:]
示例13: _sendAddInterest
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addUint16 [as 别名]
def _sendAddInterest(self, contextId, parentId, zoneId):
"""
Part of the new otp-server code.
contextId is a client-side created number that refers to
a set of interests. The same contextId number doesn't
necessarily have any relationship to the same contextId
on another client.
"""
datagram = PyDatagram()
# Add message type
datagram.addUint16(CLIENT_ADD_INTEREST)
datagram.addUint16(contextId)
datagram.addUint32(parentId)
datagram.addUint32(zoneId)
self.send(datagram)
示例14: sendSetZoneMsg
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addUint16 [as 别名]
def sendSetZoneMsg(self, zoneId, visibleZoneList=None):
datagram = PyDatagram()
# Add message type
datagram.addUint16(CLIENT_SET_ZONE)
# Add zone id
datagram.addUint32(zoneId)
# if we have an explicit list of visible zones, add them
if visibleZoneList is not None:
vzl = list(visibleZoneList)
vzl.sort()
assert PythonUtil.uniqueElements(vzl)
for zone in vzl:
datagram.addUint32(zone)
# send the message
self.send(datagram)
示例15: _sendAddInterest
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import addUint16 [as 别名]
def _sendAddInterest(self, handle, contextId, parentId, zoneIdList, description, action = None):
if parentId == 0:
DoInterestManager.notify.error('trying to set interest to invalid parent: %s' % parentId)
datagram = PyDatagram()
datagram.addUint16(CLIENT_ADD_INTEREST)
datagram.addUint16(handle)
datagram.addUint32(contextId)
datagram.addUint32(parentId)
if isinstance(zoneIdList, types.ListType):
vzl = list(zoneIdList)
vzl.sort()
uniqueElements(vzl)
for zone in vzl:
datagram.addUint32(zone)
else:
datagram.addUint32(zoneIdList)
self.send(datagram)