From 168d9e7a69b4c0e4fa9fee6755b71e9919a647f0 Mon Sep 17 00:00:00 2001 From: gounux Date: Thu, 25 Jul 2024 18:46:28 +0200 Subject: [PATCH] feat: add more debug logs --- qtribu/gui/dck_qchat.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qtribu/gui/dck_qchat.py b/qtribu/gui/dck_qchat.py index 259049de..5d57f16f 100644 --- a/qtribu/gui/dck_qchat.py +++ b/qtribu/gui/dck_qchat.py @@ -104,6 +104,7 @@ def __init__(self, iface: QgisInterface, parent: QWidget = None): self.ws_client = QtWebSockets.QWebSocket( "", QtWebSockets.QWebSocketProtocol.Version13, None ) + self.ws_client.error.connect(self.on_ws_error) self.ws_client.textMessageReceived.connect(self.on_ws_message_received) # send message signal listener @@ -279,6 +280,7 @@ def on_ws_connected(self, room: str) -> None: self.grb_user.setEnabled(True) self.current_room = room self.connected = True + self.log(message=f"Websocket connected to room {room}") def disconnect_from_room(self, log: bool = True, close_ws: bool = True) -> None: """ @@ -306,6 +308,7 @@ def on_ws_disconnected(self) -> None: Action called when websocket is disconnected """ self.connected = False + self.log(message="Websocket disconnected") def on_ws_error(self, error_code: int) -> None: """ @@ -329,6 +332,10 @@ def on_ws_message_received(self, message: str) -> None: self.handle_internal_message(message) return + self.log( + message=f"Message received: [{message['author']}]: '{message['message']}'" + ) + # check if a cheatcode is activated if self.settings.qchat_activate_cheatcode: activated = self.check_cheatcode(message) @@ -391,6 +398,7 @@ def handle_internal_message(self, message: dict[str, Any]) -> None: user_txt=self.tr("user") if nb_users <= 1 else self.tr("users"), ) ) + self.log(message=f"Internal message received: {nb_users} users in room") def on_message_double_clicked(self, item: QTreeWidgetItem, column: int) -> None: """