You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

consumers.py 680B

123456789101112131415161718192021222324252627282930313233
  1. # chat/consumers.py
  2. import json
  3. from channels.generic.websocket import WebsocketConsumer
  4. import wsps.tasks_loop
  5. class ChatConsumer(WebsocketConsumer):
  6. def connect(self):
  7. p("!!!!!!!!!!!!!!!!!!!!")
  8. self.accept()
  9. def disconnect(self, close_code):
  10. pass
  11. def receive(self, text_data):
  12. text_data_json = json.loads(text_data)
  13. message = text_data_json['message']
  14. self.send(text_data=json.dumps({
  15. 'message': message
  16. }))
  17. self.send(text_data=json.dumps({
  18. 'message': {"abc":123}
  19. }))
  20. print(">>>>>>>>>>>>>")
  21. print("++..",end="\n",flush=True)
  22. # print("++",end="\n",flush=True)