コード例 #1
0
 def condition_reply(self, conn, reply_command, shared_templ="{}\n{}", reply_templ="{}\n{}"):
     addr = self.clients[conn].addr
     shared_reply = format_reply(shared_templ.format(reply_command, addr))
     session_id = self.clients[conn].session
     reply = format_reply(reply_templ.format(reply_command, session_id))
     for client in self.clients.keys():
         if client == conn:
             conn.sendall(reply)
         else:
             conn.sendall(shared_reply)
コード例 #2
0
 def run(self):
     self.thread = threading.Thread(target=self.recv_response)
     self.thread.start()
     while True:
         command = input()
         command_name = command.split()[0]
         command = command.replace(" ", "\n")
         self.socket.sendall(format_reply(command))
コード例 #3
0
 def finish(self, conn):
     addr = self.clients[conn].addr
     reply = format_reply("{}\n{} finished server.".format('ackfinish', addr))
     for client in self.clients.keys():
         client.sendall(reply)
     os.kill(os.getpid(), signal.SIGUSR1)
コード例 #4
0
 def pingd(self, conn, data):
     reply = format_reply('{}\n{}'.format('pongd', data))
     conn.sendall(reply)
コード例 #5
0
 def ping(self, conn):
     reply = format_reply('pong')
     conn.sendall(reply)