Send image type list notification to new websocket
This commit is contained in:
@@ -52,9 +52,15 @@ parser.add_argument(
|
|||||||
FLAGS = parser.parse_args()
|
FLAGS = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def GetWebSocketHandler(websockets):
|
def GetWebSocketHandler(image_types, websockets):
|
||||||
class WebSocketHandler(websocket.WebSocket):
|
class WebSocketHandler(websocket.WebSocket):
|
||||||
def opened(self):
|
def opened(self):
|
||||||
|
self.send(json.dumps({
|
||||||
|
'type': 'image_types',
|
||||||
|
'data': {
|
||||||
|
'image_types': list(image_types),
|
||||||
|
},
|
||||||
|
}), False)
|
||||||
websockets.add(self)
|
websockets.add(self)
|
||||||
|
|
||||||
def closed(self, code, reason=None):
|
def closed(self, code, reason=None):
|
||||||
@@ -91,7 +97,7 @@ class HTTPRequestHandler(object):
|
|||||||
def __init__(self, image_path, image_types, websockets):
|
def __init__(self, image_path, image_types, websockets):
|
||||||
self._image_path = image_path
|
self._image_path = image_path
|
||||||
self._image_types = image_types
|
self._image_types = image_types
|
||||||
inner_handler = GetWebSocketHandler(websockets)
|
inner_handler = GetWebSocketHandler(image_types, websockets)
|
||||||
self._websocket_handler = wsgiutils.WebSocketWSGIApplication(handler_cls=inner_handler)
|
self._websocket_handler = wsgiutils.WebSocketWSGIApplication(handler_cls=inner_handler)
|
||||||
|
|
||||||
def __call__(self, env, start_response):
|
def __call__(self, env, start_response):
|
||||||
|
|||||||
Reference in New Issue
Block a user