This commit is contained in:
2025-07-15 19:54:59 +08:00
parent 31cacb776f
commit 8701c60a17
11 changed files with 43 additions and 21 deletions

17
chat/consumers.py Normal file
View File

@@ -0,0 +1,17 @@
import json
from channels.generic.websocket import WebsocketConsumer
class ChatConsumer(WebsocketConsumer):
def connect(self):
self.accept()
def disconnect(self, close_code):
pass
def receive(self, text_data):
text_data_json = json.loads(text_data)
message = text_data_json["message"]
self.send(text_data=json.dumps({"message": message}))