def reject_connection(self, new_conn: ServerSideClientConn) -> None: res = RespondsePackage( "ERROR", "cant allow more that {} clients".format(conf.MAX_CLIENT_COUNT)) new_conn.enqueue(res.serialize()) new_conn.send() logger.info("max connections: {} rejected".format(new_conn.peername())) new_conn.close()
def handle(self): self.data = self.recv() logger.debug("registering recieved: {}".format(self.data)) self.pass_to_handler.put(self.data) res = RespondsePackage("ACK", "proxy registered") res.pack() self.data = res.serialize() self.send()
def handle(self): self.data = self.recv() logger.info("shutdown recieved: {}".format(self.data['command'])) res = RespondsePackage("ACK", "Shutting down {}".format(self.client_conn.address)) res.pack() self.pass_to_handler.put(self.data) self.data = res.serialize() self.send()
def handle(self): self.data = self.recv() logger.debug("heartbeat recieved: {}".format(self.data)) #passing msg to queue self.pass_to_handler.put(self.data) res = RespondsePackage("ACK", "ACK") res.pack() self.data = res.serialize() self.send()
def _pack_response_and_send(self, res): self.send_to_backup() res = RespondsePackage(status=res.split(":")[0], body=res.split(":")[1]) res.pack() if 'client' in self.data: res['client'] = self.data.get('client') self.data = res.serialize() self.send()