本文整理汇总了Python中Packet.packetize方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.packetize方法的具体用法?Python Packet.packetize怎么用?Python Packet.packetize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.packetize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dataReceived
# 需要导入模块: import Packet [as 别名]
# 或者: from Packet import packetize [as 别名]
def dataReceived(self, data):
"""parse received data into packets."""
log.debug(hexdump(data))
self.resetTimeout()
self.data += data
try:
packet = Packet.packetize(self.data)
except Packet.NeedMoreData:
return
except Packet.UnknownPacketType as err:
log.debug(str(err))
self.data = self.data[2:]
else:
self.handle_packet(packet)
db.save_packet(packet)
self.data = self.data[len(packet):]
示例2: keyframeReceived
# 需要导入模块: import Packet [as 别名]
# 或者: from Packet import packetize [as 别名]
def keyframeReceived(self, keyframe, key_frame_id):
"""parse received key frame into packets; a key frame represents
the current state."""
db.save_key_frame(keyframe, key_frame_id)
offset = 0
totlen = len(keyframe)
while offset < totlen:
try:
packet = Packet.packetize(keyframe[offset:])
except Packet.UnknownPacketType as err:
log.debug(str(err))
offset += 2
else:
if type(packet) == Packet.SystemEvent:
try:
self.factory.create_firebase_ref(
packet.get_event_type())
except Packet.UnknownEventType as err:
log.info(str(err))
self.update_state(packet)
db.save_packet(packet)
offset += len(packet)