本文整理汇总了Python中pandac.PandaModules.NetDatagram.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Python NetDatagram.getMessage方法的具体用法?Python NetDatagram.getMessage怎么用?Python NetDatagram.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandac.PandaModules.NetDatagram
的用法示例。
在下文中一共展示了NetDatagram.getMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reader_polling
# 需要导入模块: from pandac.PandaModules import NetDatagram [as 别名]
# 或者: from pandac.PandaModules.NetDatagram import getMessage [as 别名]
def reader_polling(self, taskdata):
if self.cReader.dataAvailable():
datagram = NetDatagram() # catch the incoming data in this instance
# Check the return value; if we were threaded, someone else could have
# snagged this data before we did
if self.cReader.getData(datagram):
self.read_buffer = self.read_buffer + datagram.getMessage()
while (True):
if self.read_state == 0:
if len(self.read_buffer) >= self.packet.header_length:
bytes_consumed = self.packet.header_length
self.packet.header = self.read_buffer[:bytes_consumed]
self.read_body_length = self.packet.decode_header()
self.read_buffer = self.read_buffer[bytes_consumed:]
self.read_state = 1
else:
break
if self.read_state == 1:
if len(self.read_buffer) >= self.read_body_length:
bytes_consumed = self.read_body_length
self.packet.data = self.read_buffer[:bytes_consumed]
self.packet.offset = 0
self.read_body_length = 0
self.read_buffer = self.read_buffer[bytes_consumed:]
self.read_state = 0
self.new_data_callback(self.packet)
else:
break
return Task.cont