本文整理匯總了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