1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- # 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 DispConsumer():
- async def ws_rec_once(self, text_data):
- # print("WS~~ 12")
- msg_data = json.loads(text_data)
- if "key" in msg_data:
- key = "jm_" + msg_data["key"]
- mthd = getattr(self,key,None)
- if mthd:
- await mthd(msg_data)
- else:
- p("METHOD " + key + " NOT FOUND!")
- print("",end="",flush=True)
-
-
-
-
-
- class ChatConsumer(
- DispConsumer,
- Mixins.DevMixin,
- Mixins.LoneMixinA,
- Mixins.AclTaskMixin,
- Mixins.AconMixin,
- Mixins.LoneMixinB,
- Mixins.DevMroMixin,
- AsyncWebsocketConsumer,
- ):
- async def ws_conn0(self):
- print("",end="",flush=True)
- self.accept()
- async def ws_disconn(self, close_code):
- pass
-
-
- Mixins.ChatConsumer = ChatConsumer
|