def send_msg(self, text): try: msg = Msg( mode=Msg.TALK, data=text, ) self.sock.send(Msg.encode(msg)) except Exception as e: print("send error happens")
def start_talking(self): while True: try: text = input("> ") msg = Msg( mode=Msg.TALK, data=text, ) self.sock.send(Msg.encode(msg)) except Exception as e: print("some error happens") finally: pass
def udt_send(self, newsocket: socket.socket, msg: Msg, rate=0.95): randnum = random.randint(0, 100) if randnum < rate * 100: newsocket.send(Msg.encode(msg))