def Quit(self, request, context): resp_node = self.server.FindResponsible(request, context) room_name = request.roomname resp_serv = resp_node[1][1] if not resp_node[ 0]: # Communicate with the server that might know who will respond the request for serv in resp_serv: try: channel = grpc.insecure_channel(self.server.address + ':' + str(serv)) conn = rpc.ChatSServerStub( channel) ## connection with the responsible server result = conn.FindResponsible( chat.FindRRequest(roomname=room_name)) resp_serv = self.Str_to_list_ports(result.port) break except: print("False Error Quit at", serv) if self.Request_port() in resp_serv: return self.server.Quit(request, context) for serv in resp_serv: try: channel = grpc.insecure_channel(self.server.address + ':' + str(serv)) conn = rpc.ChatSServerStub( channel) ## connection with the server return conn.Quit( chat.QuitRequest(roomname=request.roomname, nickname=request.nickname)) except: print("True Error Quit at", serv)
def Quit(self): q = chat.QuitRequest(roomname=self.Roomname, nickname=self.Nickname) for i in range(trys): try: self.conn.Quit(q) break except Exception as e: print("Quit") print(e) self.new_channel() self.Roomname = '' self.Nickname = ''