From 2fa0cbf6843812b697e108e6892d2262cee322ae Mon Sep 17 00:00:00 2001 From: Jaehun You Date: Tue, 26 Nov 2024 18:06:54 +0900 Subject: [PATCH] Send initial operation status See also: #17 --- wlm_server/operation/consumers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wlm_server/operation/consumers.py b/wlm_server/operation/consumers.py index 19f3c5f..5c2bd5e 100644 --- a/wlm_server/operation/consumers.py +++ b/wlm_server/operation/consumers.py @@ -1,5 +1,9 @@ +import json + from channels.generic.websocket import AsyncWebsocketConsumer +from utils import util + class OperationConsumer(AsyncWebsocketConsumer): """Consumer for notifying the operation change of a specific channel. @@ -14,6 +18,7 @@ async def connect(self): self.group_name = f'channel_{self.ch}_operation' await self.channel_layer.group_add(self.group_name, self.channel_name) await self.accept() + await self.send(text_data=json.dumps({'on': util.is_channel_running(self.ch)})) async def disconnect(self, code): await self.channel_layer.group_discard(self.group_name, self.channel_name)