connect and disconnect management
This commit is contained in:
parent
c0ec68334d
commit
2f688dab5c
1 changed files with 10 additions and 2 deletions
12
sat.tac
12
sat.tac
|
|
@ -81,7 +81,7 @@ class SAT:
|
|||
self.bridge.register("getProgress", self.getProgress)
|
||||
|
||||
self._import_plugins()
|
||||
self.connect()
|
||||
#self.connect()
|
||||
|
||||
|
||||
def _import_plugins(self):
|
||||
|
|
@ -99,13 +99,16 @@ class SAT:
|
|||
|
||||
def connect(self):
|
||||
print "connecting..."
|
||||
reactor.connectTCP(self.memory.getParamV("Server", "Connection"), 5222, self.factory)
|
||||
self.connectionStatus="online" #TODO: check if connection is OK
|
||||
self.connected=True #TODO: use startedConnecting and clientConnectionLost of XMPPClientFactory
|
||||
|
||||
def getService(self):
|
||||
print "GetService !"
|
||||
"""if (self.connected):
|
||||
info("already connected !")
|
||||
return"""
|
||||
info("Getting client...")
|
||||
info("Getting service...")
|
||||
self.me = jid.JID(self.memory.getParamV("JabberID", "Connection"))
|
||||
self.factory = client.XMPPClientFactory(self.me, self.memory.getParamV("Password", "Connection"))
|
||||
self.factory.addBootstrap(xmlstream.STREAM_AUTHD_EVENT,self.authd)
|
||||
|
|
@ -119,6 +122,11 @@ class SAT:
|
|||
info("not connected !")
|
||||
return
|
||||
info("Disconnecting...")
|
||||
self.factory.stopTrying()
|
||||
if self.xmlstream:
|
||||
self.xmlstream.sendFooter()
|
||||
self.connectionStatus="offline" #TODO: check if connection is OK
|
||||
self.connected=False #TODO: use startedConnecting and clientConnectionLost of XMPPClientFactory
|
||||
|
||||
def run(self):
|
||||
debug("running app")
|
||||
|
|
|
|||
Loading…
Reference in a new issue