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)
 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))
 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)
 def pingd(self, conn, data):
     reply = format_reply('{}\n{}'.format('pongd', data))
     conn.sendall(reply)
 def ping(self, conn):
     reply = format_reply('pong')
     conn.sendall(reply)