選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

consumers.py 761B

1234567891011121314151617181920212223242526272829303132333435363738
  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. p("text_data:",text_data)
  15. text_data_json = json.loads(text_data)
  16. message = text_data_json['message']
  17. self.send(text_data=json.dumps({
  18. 'message': message
  19. }))
  20. self.send(text_data=json.dumps({
  21. 'message': {"abc":123}
  22. }))
  23. # print(">>>>>>>>>>>>>")
  24. print("++?",end="\n",flush=True)
  25. # print("++",end="\n",flush=True)