Skip to content
Snippets Groups Projects
Commit 2b61987f authored by Quoc Nguyen Dao's avatar Quoc Nguyen Dao
Browse files

Fix server server dd

parent 3ae2731e
Branches
No related tags found
1 merge request!2leader election und heartbeat
...@@ -48,10 +48,10 @@ class Server(): ...@@ -48,10 +48,10 @@ class Server():
while True: while True:
try:
data, address = broadcast_listen_sock.recvfrom(1024) data, address = broadcast_listen_sock.recvfrom(1024)
if data and not self.informServer: if data:
newServer_address = data.decode() newServer_address = data.decode()
self.printwt(f'New participant wants to connect: {newServer_address}') self.printwt(f'New participant wants to connect: {newServer_address}')
self.isLeader = False self.isLeader = False
...@@ -63,15 +63,16 @@ class Server(): ...@@ -63,15 +63,16 @@ class Server():
reply_message = MY_IP reply_message = MY_IP
broadcast_listen_sock.sendto(str.encode(reply_message), address) broadcast_listen_sock.sendto(str.encode(reply_message), address)
# self.SendClientListUpdate(newServer_address)
self.informServer = True
self.printwt('Replied my IP to new participant') self.printwt('Replied my IP to new participant')
except socket.timeout:
break
time.sleep(1) time.sleep(1)
self.print_group_view() # Debug-Ausgabe der Gruppenansicht nach dem Broadcast self.print_group_view()
self.printwt(f'The current leader IP is: {self.leader_IP}')
#this function enables the server to send a broadcast to the server group and receive the answers of existing members #this function enables the server to send a broadcast to the server group and receive the answers of existing members
def BroadcastSendAndReceive(self): def BroadcastSendAndReceive(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment