我有一个遥感器,它通过长时间的websocket会话连接到我的Tornado服务器:
class WSHandler(tornado.websocket.WebSocketHandler):
def open(self):
puts('New connection was opened.')
self.write_message('Connection open.')
def on_message(self, message):
print 'Incoming message:', message
self.write_message(message)
def on_close(self):
print 'Connection was closed...'
sensor_application = Application([ (r'/ws', WSHandler)])
然后,我有另一个基于web的gui的应用程序:
^{pr2}$这两个应用程序都运行在不同的端口上。在
ws_server = tornado.httpserver.HTTPServer(sensor_application)
ws_server.listen(8889)
http_server = tornado.httpserver.HTTPServer(client_application)
http_server.listen(8888)
tornado.ioloop.IOLoop.instance().start()
假设我的传感器测量温度。我如何在HelloHandler中实现一个页面,它可以调用WSHandler中的websocket方法并向基于web的客户端显示温度。在
目前没有回答
相关问题 更多 >
编程相关推荐