summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream/xmlstream.py
diff options
context:
space:
mode:
Diffstat (limited to 'sleekxmpp/xmlstream/xmlstream.py')
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index f72171a1..f56c360e 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -192,6 +192,7 @@ class XMLStream(object):
#: The expected name of the server, for validation.
self._expected_server_name = ''
+ self._service_name = ''
#: The desired, or actual, address of the connected server.
self.address = (host, int(port))
@@ -473,8 +474,10 @@ class XMLStream(object):
if self.default_domain:
try:
- self.address = self.pick_dns_answer(self.default_domain,
- self.address[1])
+ host, address, port = self.pick_dns_answer(self.default_domain,
+ self.address[1])
+ self.address = (address, port)
+ self._service_name = host
except StopIteration:
log.debug("No remaining DNS records to try.")
self.dns_answers = None
@@ -723,6 +726,20 @@ class XMLStream(object):
self.event("disconnected", direct=True)
return True
+ def abort(self):
+ self.session_started_event.clear()
+ self.stop.set()
+ if self._disconnect_wait_for_threads:
+ self._wait_for_threads()
+ try:
+ self.socket.shutdown(Socket.SHUT_RDWR)
+ self.socket.close()
+ self.filesocket.close()
+ except Socket.error:
+ pass
+ self.state.transition_any(['connected', 'disconnected'], 'disconnected', func=lambda: True)
+ self.event("killed", direct=True)
+
def reconnect(self, reattempt=True, wait=False, send_close=True):
"""Reset the stream's state and reconnect to the server."""
log.debug("reconnecting...")