12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- # chat/consumers.py
- import json
- from channels.generic.websocket import WebsocketConsumer,AsyncWebsocketConsumer
- import wsps.tasks_loop
- import time
- p=print
-
- Mixins = wsps.tasks_loop.Mixins
-
-
- # class ChatConsumer(WebsocketConsumer,wsps.tasks_loop.AclTaskMixin,wsps.tasks_loop.AconMixin):
- class ChatConsumer(
- Mixins.DevMixin,
- Mixins.LoneMixinA,
- Mixins.AclTaskMixin,
- Mixins.AconMixin,
- AsyncWebsocketConsumer,
- Mixins.LoneMixinB,
- Mixins.DevMroMixin,
- ):
- # def connect(self):
- async def ws_conn(self):
- p("!!!!!!!!!!!!!!!!!!!!?")
- print("",end="",flush=True)
- # time.sleep(1.5)
-
- # p("!!!!!!!!!!!!!!!!!!!!")
- # print("",end="",flush=True)
- self.accept()
-
- async def ws_disconn(self, close_code):
- pass
-
- async def ws_disconn_z(self, close_code):
- pass
-
- async def ws_rec(self, text_data):
- p("text_data:",text_data)
- print("",end="",flush=True)
- text_data_json = json.loads(text_data)
- message = text_data_json['message']
-
- self.send(text_data=json.dumps({
- 'message': message
- }))
-
-
- self.send(text_data=json.dumps({
- 'zzz': {"abc":123}
- }))
-
-
- # print(">>>>>>>>>>>>>")
- Mixins.ChatConsumer = ChatConsumer
-
- print("++?",end="\n",flush=True)
- # print("++2?",end="\n",flush=True)
- # print("++",end="\n",flush=True)
|