diff options
author | lovetox <philipp@hoerist.com> | 2020-04-05 23:57:32 +0300 |
---|---|---|
committer | lovetox <philipp@hoerist.com> | 2020-04-05 23:57:32 +0300 |
commit | f3df66ee57b632f9526604ab16e9fc6de7ab8e12 (patch) | |
tree | f103d41fdf19aa976496e02c2e1089ee97a98406 | |
parent | 19d047e08a3e7cf3ac3e7a9d0c71637d8519ef78 (diff) |
Client: Allow websocket URIs when using set_custom_host()
-rw-r--r-- | nbxmpp/addresses.py | 8 | ||||
-rw-r--r-- | nbxmpp/client.py | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/nbxmpp/addresses.py b/nbxmpp/addresses.py index 7131778..59be915 100644 --- a/nbxmpp/addresses.py +++ b/nbxmpp/addresses.py @@ -142,14 +142,18 @@ class ServerAddresses(Observable): if address is None: return - host, protocol, type_ = address + host_or_uri, protocol, type_ = address + if protocol == ConnectionProtocol.WEBSOCKET: + host, uri = None, host_or_uri + else: + host, uri = host_or_uri, None self._fallback_addresses = [] self._addresses = [ ServerAddress(domain=self._domain, service=None, host=host, - uri=None, + uri=uri, protocol=protocol, type=type_, proxy=None)] diff --git a/nbxmpp/client.py b/nbxmpp/client.py index 44c192c..bcb159d 100644 --- a/nbxmpp/client.py +++ b/nbxmpp/client.py @@ -171,10 +171,10 @@ class Client(Observable): def custom_host(self): return self._custom_host - def set_custom_host(self, host, protocol, type_): + def set_custom_host(self, host_or_uri, protocol, type_): if self._domain is None: raise ValueError('Call set_domain() first before set_custom_host()') - self._custom_host = (host, protocol, type_) + self._custom_host = (host_or_uri, protocol, type_) def set_accepted_certificates(self, certificates): self._accepted_certificates = certificates |