本文整理汇总了Python中PyDatagram.PyDatagram.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Python PyDatagram.getMessage方法的具体用法?Python PyDatagram.getMessage怎么用?Python PyDatagram.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyDatagram.PyDatagram
的用法示例。
在下文中一共展示了PyDatagram.getMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: writeServerEvent
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import getMessage [as 别名]
def writeServerEvent(self, logtype, *args, **kwargs):
"""
Write an event to the central Event Logger, if one is configured.
The purpose of the Event Logger is to keep a game-wide record of all
interesting in-game events that take place. Therefore, this function
should be used whenever such an interesting in-game event occurs.
"""
if self.eventSocket is None:
return # No event logger configured!
log = collections.OrderedDict()
log['type'] = logtype
log['sender'] = self.eventLogId
for i,v in enumerate(args):
# +1 because the logtype was _0, so we start at _1
log['_%d' % (i+1)] = v
log.update(kwargs)
dg = PyDatagram()
msgpack_encode(dg, log)
self.eventSocket.Send(dg.getMessage())
示例2: __getBarrierData
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import getMessage [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()
示例3: writeServerEvent
# 需要导入模块: from PyDatagram import PyDatagram [as 别名]
# 或者: from PyDatagram.PyDatagram import getMessage [as 别名]
def writeServerEvent(self, logtype, *args):
"""
Write an event to the central Event Logger, if one is configured.
The purpose of the Event Logger is to keep a game-wide record of all
interesting in-game events that take place. Therefore, this function
should be used whenever such an interesting in-game event occurs.
"""
if self.eventSocket is None:
return # No event logger configured!
dg = PyDatagram()
dg.addString(self.eventLogId)
dg.addString(logtype)
for arg in args:
dg.addString(str(arg))
self.eventSocket.Send(dg.getMessage())