summaryrefslogtreecommitdiff
path: root/sleekxmpp/features/feature_session.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-06-30 15:40:22 -0700
committerLance Stout <lancestout@gmail.com>2011-06-30 15:40:22 -0700
commit754ac5092a3a37819a71f6565a1e54b3f2547940 (patch)
tree8eac47a45f53e7f5bca0ffe312409dbb71924e42 /sleekxmpp/features/feature_session.py
parent9ed972ffeba8f5071d5cae8497322764207fec04 (diff)
downloadslixmpp-754ac5092a3a37819a71f6565a1e54b3f2547940.tar.gz
slixmpp-754ac5092a3a37819a71f6565a1e54b3f2547940.tar.bz2
slixmpp-754ac5092a3a37819a71f6565a1e54b3f2547940.tar.xz
slixmpp-754ac5092a3a37819a71f6565a1e54b3f2547940.zip
Reorganize features into plugins.
Diffstat (limited to 'sleekxmpp/features/feature_session.py')
-rw-r--r--sleekxmpp/features/feature_session.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/sleekxmpp/features/feature_session.py b/sleekxmpp/features/feature_session.py
new file mode 100644
index 00000000..5bae358c
--- /dev/null
+++ b/sleekxmpp/features/feature_session.py
@@ -0,0 +1,46 @@
+"""
+ SleekXMPP: The Sleek XMPP Library
+ Copyright (C) 2010 Nathanael C. Fritz
+ This file is part of SleekXMPP.
+
+ See the file LICENSE for copying permission.
+"""
+
+import logging
+
+from sleekxmpp.xmlstream.matcher import *
+from sleekxmpp.xmlstream.handler import *
+from sleekxmpp.plugins.base import base_plugin
+
+
+log = logging.getLogger(__name__)
+
+
+class feature_session(base_plugin):
+
+ def plugin_init(self):
+ self.name = 'Start Session'
+ self.rfc = '3920'
+ self.description = 'Start Session Stream Feature'
+
+ self.xmpp.register_feature('session',
+ self._handle_start_session,
+ restart=False,
+ order=10001)
+
+ 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')
+ response = iq.send(now=True)
+
+ log.debug("Established Session")
+ self.xmpp.sessionstarted = True
+ self.xmpp.session_started_event.set()
+ self.xmpp.event("session_start")