From db9ec144be99fe758dd6df3c77fa480805de23ea Mon Sep 17 00:00:00 2001 From: Jaehun You Date: Fri, 22 Nov 2024 11:18:20 +0900 Subject: [PATCH] Rename group name for notifying operation change See also: #17 --- wlm_server/operation/consumers.py | 2 +- wlm_server/operation/views.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wlm_server/operation/consumers.py b/wlm_server/operation/consumers.py index 6b746dd..19f3c5f 100644 --- a/wlm_server/operation/consumers.py +++ b/wlm_server/operation/consumers.py @@ -11,7 +11,7 @@ class OperationConsumer(AsyncWebsocketConsumer): # pylint: disable=attribute-defined-outside-init async def connect(self): self.ch = self.scope['url_route']['kwargs']['ch'] - self.group_name = f'channel_{self.ch}' + self.group_name = f'channel_{self.ch}_operation' await self.channel_layer.group_add(self.group_name, self.channel_name) await self.accept() diff --git a/wlm_server/operation/views.py b/wlm_server/operation/views.py index 9fade59..f0649ad 100644 --- a/wlm_server/operation/views.py +++ b/wlm_server/operation/views.py @@ -54,7 +54,7 @@ def handle_info(request, ch: int): notif = {'on': True} channel_layer = get_channel_layer() async_to_sync(channel_layer.group_send)( - f'channel_{ch}', {'type': 'notify', 'message': json.dumps(notif)} + f'channel_{ch}_operation', {'type': 'notify', 'message': json.dumps(notif)} ) operation.save() else: @@ -66,7 +66,7 @@ def handle_info(request, ch: int): notif = {'on': False} channel_layer = get_channel_layer() async_to_sync(channel_layer.group_send)( - f'channel_{ch}', {'type': 'notify', 'message': json.dumps(notif)} + f'channel_{ch}_operation', {'type': 'notify', 'message': json.dumps(notif)} ) if not is_wlm_running: message = MessageInfo(ActionType.CLOSE, None, None)