In aTalk implementation, it handles its own Presence sending; and the XMPP Connection Configuration is configured as config.setSendPresence(false).
However it is found that smack ServiceDiscoveryManager get triggered off to resend the same Presence stanza when aTalk sends the Presence available upon first registered with the server. This is shown in the aTalk logcat below.
There is some comment in source, but not quite understand “We only send a presence packet if there was already one send”. Is this meant to add <c/> extension before sending the Presence stanza.
// Re-send the last sent presence, and let the stanza interceptor
// add a <c/> node to it.
// See http://xmpp.org/extensions/xep-0115.html#advertise
// We only send a presence packet if there was already one send
// to respect ConnectionConfiguration.isSendPresence()
I was initially concern resend of Presence(available) may trigger server duplicate sending of publish#event twice, but fount this is not the case on ejabberd server. However the server responses multiple times (2+4) to the two Presence stanzas sent.
Sending of Presence stanza may also contains the <show/> attributes, but I cannot locate where smack supports the manual sending of Presence stanza. Any reason?
// ======== aTalk logcat =========== //
07:40:49.075 E java.lang.Exception: <presence xmlns='jabber:client' id='KG4SK-7'><status/><priority>30</priority></presence>
at org.jivesoftware.smack.AbstractXMPPConnection.sendStanza(AbstractXMPPConnection.java:873)
at net.java.sip.communicator.impl.protocol.jabber.OperationSetPersistentPresenceJabberImpl.publishPresenceStatus(OperationSetPersistentPresenceJabberImpl.java:584)
at net.java.sip.communicator.impl.globaldisplaydetails.GlobalStatusServiceImpl$PublishPresenceStatusThread.run(GlobalStatusServiceImpl.java:527)
07:40:49.077 D SENT (0):
<presence id='KG4SK-7'>
<status/>
<priority>
30
</priority>
<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='https://atalk.org' ver='i/QosNuYTO9lDz6/GUxZBJxCfKk='/>
</presence>
07:40:49.101 E java.lang.Exception: <presence xmlns='jabber:client' id='KG4SK-8'><status/><priority>30</priority><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='https://atalk.org' ver='i/QosNuYTO9lDz6/GUxZBJxCfKk='/></presence>
at org.jivesoftware.smack.AbstractXMPPConnection.sendStanza(AbstractXMPPConnection.java:873)
at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.lambda$renewEntityCapsVersion$1$org-jivesoftware-smackx-disco-ServiceDiscoveryManager(ServiceDiscoveryManager.java:974)
at org.jivesoftware.smackx.disco.ServiceDiscoveryManager$$ExternalSyntheticLambda1.run(Unknown Source:2)
at org.jivesoftware.smack.ScheduledAction.lambda$run$0$org-jivesoftware-smack-ScheduledAction(ScheduledAction.java:87)
at org.jivesoftware.smack.ScheduledAction$$ExternalSyntheticLambda0.run(Unknown Source:2)
at java.lang.Thread.run(Thread.java:1012)
07:40:49.104 D SENT (0):
<presence id='KG4SK-8'>
<status/>
<priority>
30
</priority>
<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='https://atalk.org' ver='i/QosNuYTO9lDz6/GUxZBJxCfKk='/>
</presence>
07:40:50.351 D RECV (0):
<presence xml:lang='en-US' to='swan@atalk.sytes.net/atalk-8oh83s' from='swan@atalk.sytes.net/atalk-8oh83s' id='KG4SK-7'>
<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='https://atalk.org' ver='i/QosNuYTO9lDz6/GUxZBJxCfKk='/>
<x xmlns='vcard-temp:x:update'>
<photo>
7ec4901ae9e5b9d9077acbf3a0f9700d9fbcabfa
</photo>
</x>
<priority>
30
</priority>
<status/>
</presence>
07:40:50.354 D Smack presence update for: swan@atalk.sytes.net/atalk-8oh83s - available
07:40:50.355 D RECV (0):
<presence xml:lang='en-US' to='swan@atalk.sytes.net/atalk-8oh83s' from='swan@atalk.sytes.net/atalk-8oh83s' id='KG4SK-7'>
<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='https://atalk.org' ver='i/QosNuYTO9lDz6/GUxZBJxCfKk='/>
<x xmlns='vcard-temp:x:update'>
<photo>
7ec4901ae9e5b9d9077acbf3a0f9700d9fbcabfa
</photo>
</x>
<priority>
30
</priority>
<status/>
</presence>
07:40:50.407 D RECV (0):
<presence xml:lang='en-US' to='swan@atalk.sytes.net/atalk-8oh83s' from='swan@atalk.sytes.net/atalk-8oh83s' id='KG4SK-8'>
<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='https://atalk.org' ver='i/QosNuYTO9lDz6/GUxZBJxCfKk='/>
<x xmlns='vcard-temp:x:update'>
<photo>
7ec4901ae9e5b9d9077acbf3a0f9700d9fbcabfa
</photo>
</x>
<priority>
30
</priority>
<status/>
</presence>
07:40:50.443 D RECV (0):
<presence xml:lang='en-US' to='swan@atalk.sytes.net/atalk-8oh83s' from='swan@atalk.sytes.net/atalk-8oh83s' id='KG4SK-8'>
<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='https://atalk.org' ver='i/QosNuYTO9lDz6/GUxZBJxCfKk='/>
<x xmlns='vcard-temp:x:update'>
<photo>
7ec4901ae9e5b9d9077acbf3a0f9700d9fbcabfa
</photo>
</x>
<delay from='swan@atalk.sytes.net/atalk-8oh83s' stamp='2024-03-07T23:40:54.607814Z' xmlns='urn:xmpp:delay'/>
<priority>
30
</priority>
<status/>
</presence>
07:40:50.450 D RECV (0):
<presence xml:lang='en-US' to='swan@atalk.sytes.net/atalk-8oh83s' from='swan@atalk.sytes.net/atalk-8oh83s' id='KG4SK-8'>
<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='https://atalk.org' ver='i/QosNuYTO9lDz6/GUxZBJxCfKk='/>
<x xmlns='vcard-temp:x:update'>
<photo>
7ec4901ae9e5b9d9077acbf3a0f9700d9fbcabfa
</photo>
</x>
<delay from='swan@atalk.sytes.net/atalk-8oh83s' stamp='2024-03-07T23:40:54.607814Z' xmlns='urn:xmpp:delay'/>
<priority>
30
</priority>
<status/>
</presence>
07:40:50.450 D RECV (0):
<presence xml:lang='en-US' to='swan@atalk.sytes.net/atalk-8oh83s' from='swan@atalk.sytes.net/atalk-8oh83s' id='KG4SK-8'>
<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='https://atalk.org' ver='i/QosNuYTO9lDz6/GUxZBJxCfKk='/>
<x xmlns='vcard-temp:x:update'>
<photo>
7ec4901ae9e5b9d9077acbf3a0f9700d9fbcabfa
</photo>
</x>
<delay from='swan@atalk.sytes.net/atalk-8oh83s' stamp='2024-03-07T23:40:54.607814Z' xmlns='urn:xmpp:delay'/>
<priority>
30
</priority>
<status/>
</presence>