use QUrl to construct the websocket url
This commit is contained in:
@@ -69,8 +69,7 @@ class GotifyApplication(GotifySession):
|
|||||||
class GotifyClient(GotifySession):
|
class GotifyClient(GotifySession):
|
||||||
def __init__(self, url: str, client_token: str):
|
def __init__(self, url: str, client_token: str):
|
||||||
super(GotifyClient, self).__init__(url, client_token)
|
super(GotifyClient, self).__init__(url, client_token)
|
||||||
self.hostname = self.url.lstrip("https://").lstrip("http://")
|
self.listener = Listener(url, client_token)
|
||||||
self.listener = Listener(self.hostname, client_token)
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Application
|
Application
|
||||||
|
|||||||
@@ -17,13 +17,16 @@ class Listener(QtCore.QThread):
|
|||||||
opened = QtCore.pyqtSignal()
|
opened = QtCore.pyqtSignal()
|
||||||
closed = QtCore.pyqtSignal(int, str)
|
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__()
|
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(
|
self.ws = websocket.WebSocketApp(
|
||||||
f"wss://{self.hostname}/stream?token={self.client_token}",
|
qurl.toString(),
|
||||||
on_message=self._on_message,
|
on_message=self._on_message,
|
||||||
on_error=self._on_error,
|
on_error=self._on_error,
|
||||||
on_open=self._on_open,
|
on_open=self._on_open,
|
||||||
|
|||||||
Reference in New Issue
Block a user