本文整理汇总了Python中autobahn.twisted.websocket.WebSocketClientFactory.sNodeProtocol方法的典型用法代码示例。如果您正苦于以下问题:Python WebSocketClientFactory.sNodeProtocol方法的具体用法?Python WebSocketClientFactory.sNodeProtocol怎么用?Python WebSocketClientFactory.sNodeProtocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autobahn.twisted.websocket.WebSocketClientFactory
的用法示例。
在下文中一共展示了WebSocketClientFactory.sNodeProtocol方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from autobahn.twisted.websocket import WebSocketClientFactory [as 别名]
# 或者: from autobahn.twisted.websocket.WebSocketClientFactory import sNodeProtocol [as 别名]
packet[startAppData:self.length]).split(',')])
sensorId = sensorData.get('id')
print("sensorData: ")
print(repr(sensorData))
if sensorId != None:
msg = dumps(sensorData)
# print(msg)
self.ws.sendMessage(msg)
if sensorId not in self.nodes:
self.nodes[sensorId] = {'longAddr': packet[
4:12], 'shortAddr': packet[12:14]}
# print(repr(self.nodes))
except ValueError:
print("Dictionary error: " + repr(packet))
else:
# print("Bad packet: " + repr(packet))
self.badPacketCount += 1
self.state = GET_START
else:
print("UNKNOWN STATE")
# print("Bad Packet Count : {:d}\n".format(self.badPacketCount))
if __name__ == '__main__':
factory = WebSocketClientFactory("ws://hesabu.net:9000/ws/sensors/rw",
debug=False)
factory.protocol = WSProtocol
factory.sNodeProtocol = SNodeProtocol
reactor.connectTCP("hesabu.net", 9000, factory)
reactor.run()