This commit is contained in:
aqu415
2022-02-12 18:53:37 +08:00
parent 94d436fa3b
commit dbb53469a9
24 changed files with 5185 additions and 12 deletions
View File
+19
View File
@@ -0,0 +1,19 @@
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
}))
+7
View File
@@ -0,0 +1,7 @@
from django.urls import re_path
from . import consumers
websocket_urlpatterns = [
re_path(r'ws/jsmind/$', consumers.ChatConsumer.as_asgi()),
]