Files
python-tdd/src/apps/epic/consumers.py

28 lines
910 B
Python
Raw Normal View History

from channels.generic.websocket import AsyncJsonWebsocketConsumer
class RoomConsumer(AsyncJsonWebsocketConsumer):
async def connect(self):
self.room_id = self.scope["url_route"]["kwargs"]["room_id"]
self.group_name = f"room_{self.room_id}"
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)
async def role_select_start(self, event):
await self.send_json(event)
async def turn_changed(self, event):
await self.send_json(event)
async def roles_revealed(self, event):
await self.send_json(event)