diff --git a/wlm_server/operation/views.py b/wlm_server/operation/views.py index 4d617ce..f1894a6 100644 --- a/wlm_server/operation/views.py +++ b/wlm_server/operation/views.py @@ -31,26 +31,26 @@ def handle_info(request, ch: int): if not util.is_wlm_running(): task_handler = TaskHandler() task_handler.start() + if not util.is_channel_running(ch): + message = MessageInfo(ActionType.OPERATE, ch, {'on': True}) + message_queue.push(message) notif = {'on': True} channel_layer = get_channel_layer() async_to_sync(channel_layer.group_send)( f'channel_{ch}', {'type': 'notify', 'message': json.dumps(notif)} ) - if not util.is_channel_running(ch): - message = MessageInfo(ActionType.OPERATE, ch, {'on': True}) - message_queue.push(message) operation.save() else: operation.save() if not util.is_channel_running(ch): message = MessageInfo(ActionType.OPERATE, ch, {'on': False}) message_queue.push(message) - if not util.is_wlm_running(): - message = MessageInfo(ActionType.CLOSE, None, None) - message_queue.push(message) notif = {'on': False} channel_layer = get_channel_layer() async_to_sync(channel_layer.group_send)( f'channel_{ch}', {'type': 'notify', 'message': json.dumps(notif)} ) + if not util.is_wlm_running(): + message = MessageInfo(ActionType.CLOSE, None, None) + message_queue.push(message) return HttpResponse(status=200)