Skip to content

Commit

Permalink
feat: add more debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
gounux committed Jul 25, 2024
1 parent c37b094 commit 168d9e7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions qtribu/gui/dck_qchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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:
"""
Expand All @@ -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)
Expand Down Expand Up @@ -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:
"""
Expand Down

0 comments on commit 168d9e7

Please sign in to comment.