diff options
Diffstat (limited to 'sleekxmpp/clientxmpp.py')
-rw-r--r-- | sleekxmpp/clientxmpp.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sleekxmpp/clientxmpp.py b/sleekxmpp/clientxmpp.py index 69e7db6c..3313328a 100644 --- a/sleekxmpp/clientxmpp.py +++ b/sleekxmpp/clientxmpp.py @@ -98,14 +98,12 @@ class ClientXMPP(BaseXMPP): self.add_event_handler('connected', self._handle_connected) self.add_event_handler('session_bind', self._handle_session_bind) + self.add_event_handler('stream_start', self._handle_stream_start) + self.add_event_handler('session_start', self._handle_session_start) self.register_stanza(StreamFeatures) self.register_handler( - Callback('Stream Features', - MatchXPath('{%s}features' % self.stream_ns), - self._handle_stream_features)) - self.register_handler( Callback('Roster Update', MatchXPath('{%s}iq/{%s}query' % ( self.default_ns, @@ -119,6 +117,15 @@ class ClientXMPP(BaseXMPP): self.register_plugin('feature_mechanisms', pconfig={'use_mech': sasl_mech} if sasl_mech else None) + def _handle_stream_start(self, root): + self.register_handler( + Callback('Stream Features', + MatchXPath('{%s}features' % self.stream_ns), + self._handle_stream_features)) + + def _handle_session_start(self, e): + self.remove_handler('Stream Features') + def connect(self, address=tuple(), reattempt=True, use_tls=True, use_ssl=False): """Connect to the XMPP server. |