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)
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)))
def test_parse(self): jid = JID.parse("bob@work/mobile") self.assertEqual(str(jid), "bob@work/mobile")
def handle_jid(self, e): """ Parses the bound JID and sets it to the stream. """ self.jid = JID.parse(e.xml_text)