示例#1
0
    def send_process (self, sock_c: socket.socket, addr: str) -> None:
        while True:
            letter = input()

            date = 'XXX'
            unique_id = 'XXX'
            user_name = 'SERVER'
            title = 'XXX'
            letter = letter
            user_ip = 'XXX'
            password = '******'
            
            message = Message(
                message_json=json.dumps({
                    'unique_id': unique_id,
                    'user_name': user_name,
                    'date': date,
                    'title': title,
                    'letter': letter,
                    'user_ip': user_ip,
                    'password': password
                })
            )
 
            sock_c.send(message.to_json(is_have_secret=False).encode('utf-8'))

            if letter == 'bye':
                print(f'OK, bye {message.user_name}')
                break

        return
示例#2
0
 def post(self, message: Message) -> None:
     self.sock.send(message.to_json(is_have_secret=True).encode('utf-8'))
 def post(self, message: Message) -> None:
     req = {
         'mode': 'post',
         'json': message.to_json(is_have_secret=True).encode('utf-8')
     }
     self.sock.send(json.dumps(req).encode('utf-8'))