コード例 #1
0
 def register_callback(self, kind, function):
     self.register_handler(
         Callback(
             kind,
             MatchXPath(
                 '{jabber:client}iq/{com:ctl}query/{com:ctl}ctl[@td="' +
                 kind + '"]'), function))
コード例 #2
0
ファイル: __init__.py プロジェクト: tk4100/sucks
 def session_start(self, event):
     logging.debug("----------------- starting session ----------------")
     logging.debug("event = {}".format(event))
     self.register_handler(Callback("general",
                                    MatchXPath('{jabber:client}iq/{com:ctl}query/{com:ctl}'),
                                    self._handle_ctl))
     self.ready_flag.set()
コード例 #3
0
    def testCallback(self):
        """Test using stream callback handlers."""
        def callback_handler(stanza):
            self.xmpp.send_raw("""
              <message>
                <body>Success!</body>
              </message>
            """)

        callback = Callback('Test Callback', MatchXPath('{test}tester'),
                            callback_handler)

        self.xmpp.register_handler(callback)

        self.recv("""<tester xmlns="test" />""")

        msg = self.Message()
        msg['body'] = 'Success!'
        self.send(msg)