Skip to content

Commit

Permalink
Fix(autodiscovery): Added missing zeroconf remove service method, fix…
Browse files Browse the repository at this point in the history
…ed UIClient arguments in UI

Co-authored-by: Hauke Platte <[email protected]>
  • Loading branch information
Petzys and HOOK-Hawkins committed Mar 20, 2024
1 parent 028932c commit 0c12d4e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions UI/autodiscovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def add_service(self, zc: Zeroconf, type_: str, name: str) -> None:
else:
logger.error(f"Service {name} found, no info")

def remove_service(self, zc: Zeroconf, type_: str, name: str) -> None:
logger.info(f"Service {name} removed")


zeroconf = Zeroconf()
listener = MyListener()
Expand Down
17 changes: 10 additions & 7 deletions UI/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,17 @@ def _start_game(self):


def reload(tkinter_obj: tk.Widget, queue: Queue):
print('hiu')
for i in range(10):
servers = discover_games(i+1)
queue.put(servers)
tkinter_obj.event_generate('<<lobby/reload>>')
print(servers)
tkinter_obj.event_generate('<<thread/exit>>')
print('dead')
try:
tkinter_obj.event_generate('<<lobby/reload>>')
except tk.TclError:
pass
try:
tkinter_obj.event_generate('<<thread/exit>>')
except tk.TclError:
pass
exit()

class Lobby_Overview(tk.Container):
Expand All @@ -217,7 +220,7 @@ def __init__(self, master):
self.queue = Queue()
self.thread = False
self.servers = {}
self.master.master.network_events['lobby/connect'] = self._connect
self.master.master.network_events['lobby/connect'] = self._lobby_connect
self.master.master.network_events['lobby/connect_error'] = self._connect_error
self.bind('<<lobby/reload>>', lambda *args: self._finish_reload())
self.bind('<<thread/exit>>', lambda *args: self._thread_reset())
Expand Down Expand Up @@ -259,7 +262,7 @@ def _enter(self):
def _connect(self, ip):
root = self.master.master
root.out_queue = {root.players[root.player].uuid: Queue()}
root.network_client = client_thread(root, in_queue=list(root.out_queue.values())[0], out_queue=root.in_queue, player=root.players[root.player], ip=self.etrAddress.get())
root.network_client = client_thread(root, in_queue=list(root.out_queue.values())[0], out_queue=root.in_queue, player=root.players[root.player], ip=ip)
self.etrAddress.config(state=tk.DISABLED)
self.btnConnect.config(text="Connecting...", state=tk.DISABLED)

Expand Down

0 comments on commit 0c12d4e

Please sign in to comment.