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.

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