You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
788 B
25 lines
788 B
import json |
|
from channels.generic.websocket import AsyncWebsocketConsumer |
|
|
|
class ArriveeConsumer(AsyncWebsocketConsumer): |
|
async def connect(self): |
|
self.course_id = self.scope['url_route']['kwargs']['course_id'] |
|
self.group_name = f'course_{self.course_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(self, text_data): |
|
# Optionnel : traiter les messages entrants |
|
pass |
|
|
|
async def send_arrivee(self, event): |
|
await self.send(text_data=json.dumps(event['data']))
|
|
|