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.
17 lines
456 B
17 lines
456 B
from channels.generic.websocket import AsyncWebsocketConsumer |
|
import json |
|
|
|
class ChatConsumer(AsyncWebsocketConsumer): |
|
async def connect(self): |
|
await self.accept() |
|
|
|
async def disconnect(self, close_code): |
|
pass |
|
|
|
async def receive(self, text_data): |
|
text_data_json = json.loads(text_data) |
|
message = text_data_json['message'] |
|
|
|
await self.send(text_data=json.dumps({ |
|
'message': message |
|
})) |