code: added asyncConnect
This commit is contained in:
parent
58f47458ae
commit
05987404cc
1 changed files with 22 additions and 2 deletions
|
|
@ -34,6 +34,11 @@ class SatXMPPClient(client.XMPPClient):
|
|||
self.profile = profile
|
||||
self.host_app = host_app
|
||||
self.client_initialized = defer.Deferred()
|
||||
self.conn_deferred = defer.Deferred()
|
||||
|
||||
def getConnectionDeferred(self):
|
||||
"""Return a deferred which fire when the client is connected"""
|
||||
return self.conn_deferred
|
||||
|
||||
def _authd(self, xmlstream):
|
||||
if not self.host_app.trigger.point("XML Initialized", xmlstream, self.profile):
|
||||
|
|
@ -65,6 +70,7 @@ class SatXMPPClient(client.XMPPClient):
|
|||
|
||||
self.disco.requestInfo(jid.JID(self.host_app.memory.getParamA("Server", "Connection", profile_key=self.profile))).addCallback(self.host_app.serverDisco, self.profile) #FIXME: use these informations
|
||||
self.disco.requestItems(jid.JID(self.host_app.memory.getParamA("Server", "Connection", profile_key=self.profile))).addCallback(self.host_app.serverDiscoItems, self.disco, self.profile, self.client_initialized)
|
||||
self.conn_deferred.callback(None)
|
||||
|
||||
def initializationFailed(self, reason):
|
||||
print ("initializationFailed: %s" % reason)
|
||||
|
|
@ -74,6 +80,7 @@ class SatXMPPClient(client.XMPPClient):
|
|||
except:
|
||||
#we already send an error signal, no need to raise an exception
|
||||
pass
|
||||
self.conn_deferred.errback()
|
||||
|
||||
def isConnected(self):
|
||||
return self.__connected
|
||||
|
|
@ -262,7 +269,6 @@ class RegisteringAuthenticator(xmlstream.ConnectAuthenticator):
|
|||
if self.user_email:
|
||||
_email = query.addElement('email')
|
||||
_email.addContent(self.user_email)
|
||||
print iq.toXml()
|
||||
reg = iq.send(self.jabber_host).addCallbacks(self.registrationAnswer, self.registrationFailure)
|
||||
|
||||
def registrationAnswer(self, answer):
|
||||
|
|
|
|||
Loading…
Reference in a new issue