use QUrl to construct the websocket url

This commit is contained in:
dries.k
2022-02-03 19:18:31 +01:00
parent bdec8a5212
commit 6c280606b2
2 changed files with 8 additions and 6 deletions

View File

@@ -69,8 +69,7 @@ class GotifyApplication(GotifySession):
class GotifyClient(GotifySession):
def __init__(self, url: str, client_token: str):
super(GotifyClient, self).__init__(url, client_token)
self.hostname = self.url.lstrip("https://").lstrip("http://")
self.listener = Listener(self.hostname, client_token)
self.listener = Listener(url, client_token)
"""
Application

View File

@@ -17,13 +17,16 @@ class Listener(QtCore.QThread):
opened = QtCore.pyqtSignal()
closed = QtCore.pyqtSignal(int, str)
def __init__(self, hostname: str, client_token: str):
def __init__(self, url: str, client_token: str):
super(Listener, self).__init__()
self.hostname = hostname
self.client_token = client_token
qurl = QtCore.QUrl(url)
qurl.setScheme("wss")
qurl.setPath("/stream")
qurl.setQuery(f"token={client_token}")
self.ws = websocket.WebSocketApp(
f"wss://{self.hostname}/stream?token={self.client_token}",
qurl.toString(),
on_message=self._on_message,
on_error=self._on_error,
on_open=self._on_open,