예제 #1
0
    def __init__(self, service, secret, tls=False):
        self.parser = DispatchParser()

        self.running = False

        self.handlers = []
        self.iq_handlers = []
        
        self.logger = None
        self.secret = secret
        self.jid = JID.parse(service)
        
        self.stream = ComponentStream(self.jid)
        self.register(self.stream)
        self.parser.register_default(self.default_handler)
        self.parser.register_default_start_element(self.handle_stream)
예제 #2
0
    def __init__(self, jid, password, tls=False, registerclass=None):
        self.parser = DispatchParser()

        self.running = False
        self.available = False

        self.handlers = []
        self.iq_handlers = []
        
        self.logger = None
        self.jid = JID.parse(jid)
        
        self.stream = Stream(self.jid, password, tls=tls, register=registerclass != None)
        self.register(self.stream)
        self.parser.register_default(self.default_handler)

        if registerclass:
            self.register(registerclass(self, self.jid.node, password, unicode(self.jid)))
예제 #3
0
 def test_parse(self):
     jid = JID.parse("bob@work/mobile")
     self.assertEqual(str(jid), "bob@work/mobile")
예제 #4
0
 def handle_jid(self, e):
     """
     Parses the bound JID and sets it to the stream.
     """
     self.jid = JID.parse(e.xml_text)
예제 #5
0
 def handle_jid(self, e):
     """
     Parses the bound JID and sets it to the stream.
     """
     self.jid = JID.parse(e.xml_text)