try not to send session termination messages to non-XEP-0201 clients
This commit is contained in:
parent
f7874d29c7
commit
df5200b3bb
|
@ -1752,6 +1752,8 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
if thread_id and not session.received_thread_id:
|
||||
session.received_thread_id = True
|
||||
|
||||
session.last_receive = time_time()
|
||||
|
||||
# check if the message is a XEP-0020 feature negotiation request
|
||||
if msg.getTag('feature', namespace=common.xmpp.NS_FEATURE):
|
||||
if gajim.HAVE_PYCRYPTO:
|
||||
|
|
|
@ -35,6 +35,7 @@ class StanzaSession(object):
|
|||
self.loggable = True
|
||||
|
||||
self.last_send = 0
|
||||
self.last_receive = 0
|
||||
self.status = None
|
||||
self.negotiated = {}
|
||||
|
||||
|
@ -110,17 +111,19 @@ class StanzaSession(object):
|
|||
self.negotiated = {}
|
||||
|
||||
def terminate(self):
|
||||
msg = xmpp.Message()
|
||||
feature = msg.NT.feature
|
||||
feature.setNamespace(xmpp.NS_FEATURE)
|
||||
# only send termination message if we think they might have XEP-0201 support
|
||||
if self.received_thread_id or self.last_receive == 0:
|
||||
msg = xmpp.Message()
|
||||
feature = msg.NT.feature
|
||||
feature.setNamespace(xmpp.NS_FEATURE)
|
||||
|
||||
x = xmpp.DataForm(typ='submit')
|
||||
x.addChild(node=xmpp.DataField(name='FORM_TYPE', value='urn:xmpp:ssn'))
|
||||
x.addChild(node=xmpp.DataField(name='terminate', value='1'))
|
||||
x = xmpp.DataForm(typ='submit')
|
||||
x.addChild(node=xmpp.DataField(name='FORM_TYPE', value='urn:xmpp:ssn'))
|
||||
x.addChild(node=xmpp.DataField(name='terminate', value='1'))
|
||||
|
||||
feature.addChild(node=x)
|
||||
feature.addChild(node=x)
|
||||
|
||||
self.send(msg)
|
||||
self.send(msg)
|
||||
|
||||
self.status = None
|
||||
|
||||
|
|
Loading…
Reference in New Issue