From 5ab77c745270d7d5c016c1dc7ef2a82533a4b16e Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Thu, 17 Jul 2014 14:19:04 +0200 Subject: Rename to slixmpp --- slixmpp/features/feature_session/session.py | 54 +++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 slixmpp/features/feature_session/session.py (limited to 'slixmpp/features/feature_session/session.py') diff --git a/slixmpp/features/feature_session/session.py b/slixmpp/features/feature_session/session.py new file mode 100644 index 00000000..c2694a9f --- /dev/null +++ b/slixmpp/features/feature_session/session.py @@ -0,0 +1,54 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2011 Nathanael C. Fritz + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +import logging + +from slixmpp.stanza import Iq, StreamFeatures +from slixmpp.xmlstream import register_stanza_plugin +from slixmpp.plugins import BasePlugin + +from slixmpp.features.feature_session import stanza + + +log = logging.getLogger(__name__) + + +class FeatureSession(BasePlugin): + + name = 'feature_session' + description = 'RFC 3920: Stream Feature: Start Session' + dependencies = set() + stanza = stanza + + def plugin_init(self): + self.xmpp.register_feature('session', + self._handle_start_session, + restart=False, + order=10001) + + register_stanza_plugin(Iq, stanza.Session) + register_stanza_plugin(StreamFeatures, stanza.Session) + + def _handle_start_session(self, features): + """ + Handle the start of the session. + + Arguments: + feature -- The stream features element. + """ + iq = self.xmpp.Iq() + iq['type'] = 'set' + iq.enable('session') + iq.send(now=True) + + self.xmpp.features.add('session') + + log.debug("Established Session") + self.xmpp.sessionstarted = True + self.xmpp.session_started_event.set() + self.xmpp.event('session_start') -- cgit v1.2.3