Exemple #1
0
 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")
Exemple #2
0
 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
Exemple #3
0
 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))