from channels.generic.websocket import AsyncJsonWebsocketConsumer class RoomConsumer(AsyncJsonWebsocketConsumer): async def connect(self): self.room_slug = self.scope["url_route"]["kwargs"]["room_slug"] self.group_name = f"room_{self.room_slug}" await self.channel_layer.group_add(self.group_name, self.channel_name) await self.accept() async def disconnect(self, close_code): await self.channel_layer.group_discard(self.group_name, self.channel_name) async def receive_json(self, content): pass # handlers added as events introduced async def gate_update(self, event): await self.send_json(event)