diff --git a/server.py b/server.py index fe6df3377450abf19add7650a26fd7e2eee5be58..960ce8901c03da32a5c8676bf7b5b0890866fa29 100644 --- a/server.py +++ b/server.py @@ -422,7 +422,7 @@ class Server(multiprocessing.Process): # Register client. Check if chatgroup exists, if yes answer client with chatgroup server IP def register_client(self, group, client_addr): - if group not in self.local_servers_cache: + if group not in self.local_group_cache: print(self.server_id+": "+"Group "+group+" doesn't exist.") else: @@ -438,9 +438,18 @@ class Server(multiprocessing.Process): self.local_clients_cache[client_cache_key] = client_addr def find_groupchat_server_addresse(self, group): - for key in self.local_servers_cache: + # double check if group really exist + for key in self.local_group_cache: + print("Key ", key) if group == str(key): - addr = self.local_servers_cache[key][0] + print("ID: ", self.local_group_cache[key]) + if self.local_group_cache[key] == "MAIN": + addr = self.server_address + else: + id = self.local_group_cache[key] + addr = self.local_servers_cache[id][0] + + print("Address: ", addr) return addr