# -*- coding: utf-8 -*-
# @Time : 2022/2/18 14:46
# @Author : wangyinghao
# @File : socket.py
# @Software: PyCharm
from channels.generic.websocket import WebsocketConsumer


# Create your views here.
class ChatConsumer(WebsocketConsumer):
    def connect(self):
        self.accept()

    def disconnect(self, close_code):
        pass

    def receive(self, text_data):
        """
        接收消息
        :param text_data: 客户端发送的消息
        :return:
        """
        print(text_data)

        # path = "D:/log/test_log/all.log"
        # with open(path, 'r', encoding='utf-8') as file:
        #     message = file.read()
        #     time.sleep(0.5)
        #     self.send(message)

        # for i in poetryList:
        #     time.sleep(0.5)
        #     self.send(i)

        self.send(str(text_data))
