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 718B

1234567891011121314151617181920212223242526272829303132333435
  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. print("",end="",flush=True)
  9. self.accept()
  10. def disconnect(self, close_code):
  11. pass
  12. def receive(self, text_data):
  13. text_data_json = json.loads(text_data)
  14. message = text_data_json['message']
  15. self.send(text_data=json.dumps({
  16. 'message': message
  17. }))
  18. self.send(text_data=json.dumps({
  19. 'message': {"abc":123}
  20. }))
  21. # print(">>>>>>>>>>>>>")
  22. print("++?",end="\n",flush=True)
  23. # print("++",end="\n",flush=True)