Mercurial > libervia-backend
comparison sat/core/xmpp.py @ 2694:a8ec00731ce7
core: removed whitespace ping (not needed anymore as we handle XMPP ping)
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 19 Nov 2018 21:08:25 +0100 |
parents | f64f1158a26e |
children | 2ea2369ae7de |
comparison
equal
deleted
inserted
replaced
2693:f64f1158a26e | 2694:a8ec00731ce7 |
---|---|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 from sat.core.constants import Const as C | 21 from sat.core.constants import Const as C |
22 from sat.memory import cache | 22 from sat.memory import cache |
23 from twisted.internet import task, defer | 23 from twisted.internet import defer |
24 from twisted.words.protocols.jabber.xmlstream import XMPPHandler | 24 from twisted.words.protocols.jabber.xmlstream import XMPPHandler |
25 from twisted.words.protocols.jabber import xmlstream | 25 from twisted.words.protocols.jabber import xmlstream |
26 from twisted.words.protocols.jabber import error | 26 from twisted.words.protocols.jabber import error |
27 from twisted.words.protocols.jabber import jid | 27 from twisted.words.protocols.jabber import jid |
28 from twisted.words.xish import domish | 28 from twisted.words.xish import domish |
239 self.host_app.bridge.connected( | 239 self.host_app.bridge.connected( |
240 self.profile, unicode(self.jid) | 240 self.profile, unicode(self.jid) |
241 ) # we send the signal to the clients | 241 ) # we send the signal to the clients |
242 | 242 |
243 | 243 |
244 self.keep_alife = task.LoopingCall( | |
245 self.xmlstream.send, " " | |
246 ) # Needed to avoid disconnection (specially with openfire) | |
247 self.keep_alife.start(C.XMPP_KEEP_ALIFE) | |
248 self.disco = SatDiscoProtocol(self) | 244 self.disco = SatDiscoProtocol(self) |
249 self.disco.setHandlerParent(self) | 245 self.disco.setHandlerParent(self) |
250 self.discoHandler = disco.DiscoHandler() | 246 self.discoHandler = disco.DiscoHandler() |
251 self.discoHandler.setHandlerParent(self) | 247 self.discoHandler.setHandlerParent(self) |
252 disco_d = defer.succeed(None) | 248 disco_d = defer.succeed(None) |
282 for hook in send_hooks: | 278 for hook in send_hooks: |
283 xs.addHook(C.STREAM_HOOK_SEND, hook) | 279 xs.addHook(C.STREAM_HOOK_SEND, hook) |
284 super(SatXMPPEntity, self)._connected(xs) | 280 super(SatXMPPEntity, self)._connected(xs) |
285 | 281 |
286 def disconnectProfile(self, reason): | 282 def disconnectProfile(self, reason): |
287 try: | |
288 self.keep_alife.stop() | |
289 except AttributeError: | |
290 log.debug(_("No keep_alife")) | |
291 if self._connected_d is not None: | 283 if self._connected_d is not None: |
292 self.host_app.bridge.disconnected( | 284 self.host_app.bridge.disconnected( |
293 self.profile | 285 self.profile |
294 ) # we send the signal to the clients | 286 ) # we send the signal to the clients |
295 self._connected_d.callback(None) | 287 self._connected_d.callback(None) |