Basestructure Chat App

This commit is contained in:
2025-03-15 12:35:32 +01:00
parent ab6e27f80e
commit 889134784a
6 changed files with 93 additions and 3 deletions

18
core/chat/consumers.py Normal file
View File

@@ -0,0 +1,18 @@
# chat/consumers.py
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}))