2019-03-01 21:59:49 +02:00
|
|
|
import tornado.websocket
|
2019-03-23 23:42:24 +02:00
|
|
|
import json
|
2019-03-01 21:59:49 +02:00
|
|
|
|
|
|
|
|
class ChameleonWebSocket(tornado.websocket.WebSocketHandler):
|
2019-03-23 23:42:24 +02:00
|
|
|
def check_origin(self, origin):
|
|
|
|
|
return True
|
2019-03-01 21:59:49 +02:00
|
|
|
def open(self):
|
2019-03-24 21:01:25 +03:00
|
|
|
self.write_message(json.dumps(
|
|
|
|
|
{
|
|
|
|
|
'cam1':{
|
|
|
|
|
'pipeline':1,
|
|
|
|
|
'exposure':12
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
))
|
2019-03-02 00:12:41 +02:00
|
|
|
print("WebSocket opened")
|
2019-03-01 21:59:49 +02:00
|
|
|
|
|
|
|
|
def on_message(self, message):
|
2019-03-23 23:42:24 +02:00
|
|
|
print(json.loads(message))
|
|
|
|
|
# print(message)
|
|
|
|
|
self.write_message(message)
|
2019-03-02 00:12:41 +02:00
|
|
|
|
2019-03-01 21:59:49 +02:00
|
|
|
def on_close(self):
|
2019-03-02 00:12:41 +02:00
|
|
|
print("WebSocket closed")
|