XMPP Presence

146 views
Skip to first unread message

Ashutosh Thakur

unread,
Dec 22, 2014, 4:55:44 PM12/22/14
to xmppfr...@googlegroups.com
Hello,

I am working on showing the status of the user (online/ offline/ away). In the sample XMPP project the status of any user depends on the value of "section" that's being saved in "XMPPUserCoreDataStorageObject" however I thought about using the delegate method:

- (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence

My issue is I am not getting "status" keyword along with the presence. It looks something like this:

<?xml version="1.0" encoding="UTF-8"?>
<presence xmlns="jabber:client" to="ha...@xyz.com" from="ha...@xyz.com/652873306-tigase-174">
   <x xmlns="vcard-temp:x:update">
      <photo />
   </x>
   <c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://github.com/robbiehanson/XMPPFramework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4=" />
</presence>

According to stackoverflow post: http://stackoverflow.com/questions/20145107/how-to-filter-the-xmpp-presence-that-is-received-in-ios

Presence packet should look like this:

    //    <presence xmlns="jabber:client" 
    //    id="Jothb-6" 
    //    from="sen...@domain.com/resource" 
    //    to="rece...@domain.com">
    //    <status>Online</status>
    //    <show>presence message</show>
    //    <priority>1</priority>
    //    </presence>

Can anyone please guide me why my packet is different? Is this something I need to talk to our backend engineer? I just want to clarify before I bring backend engineer onboard regarding this issue.

Thanks.
Ashu

Spencer MacDonald

unread,
Dec 22, 2014, 5:11:41 PM12/22/14
to xmppfr...@googlegroups.com
I have pasted from the RFC below, but in short that presence is from an ‘available’ entity as it has no show element and no type attribute.

The status element is just a free form string often referred to a mood message and not something you would base any assumptions on.

Regards

Spencer

2.2.1.  Types of Presence

The 'type' attribute of a presence stanza is OPTIONAL. A presence stanza that does not possess a 'type' attribute is used to signal to the server that the sender is online and available for communication. If included, the 'type' attribute specifies a lack of availability, a request to manage a subscription to another entity's presence, a request for another entity's current presence, or an error related to a previously-sent presence stanza. If included, the 'type' attribute MUST have one of the following values:


  • unavailable -- Signals that the entity is no longer available for communication.
  • subscribe -- The sender wishes to subscribe to the recipient's presence.
  • subscribed -- The sender has allowed the recipient to receive their presence.
  • unsubscribe -- The sender is unsubscribing from another entity's presence.
  • unsubscribed -- The subscription request has been denied or a previously-granted subscription has been cancelled.
  • probe -- A request for an entity's current presence; SHOULD be generated only by a server on behalf of a user.
  • error -- An error has occurred regarding processing or delivery of a previously-sent presence stanza.

For detailed information regarding presence semantics and the subscription model used in the context of XMPP-based instant messaging and presence applications, refer to Exchanging Presence Information and Managing Subscriptions.


2.2.2.1.  Show

The OPTIONAL <show/> element contains non-human-readable XML character data that specifies the particular availability status of an entity or specific resource. A presence stanza MUST NOT contain more than one <show/> element. The <show/> element MUST NOT possess any attributes. If provided, the XML character data value MUST be one of the following (additional availability types could be defined through a properly-namespaced child element of the presence stanza):


  • away -- The entity or resource is temporarily away.
  • chat -- The entity or resource is actively interested in chatting.
  • dnd -- The entity or resource is busy (dnd = "Do Not Disturb").
  • xa -- The entity or resource is away for an extended period (xa = "eXtended Away").

If no <show/> element is provided, the entity is assumed to be online and available.


2.2.2.2.  Status

The OPTIONAL <status/> element contains XML character data specifying a natural-language description of availability status. It is normally used in conjunction with the show element to provide a detailed description of an availability state (e.g., "In a meeting"). The <status/> element MUST NOT possess any attributes, with the exception of the 'xml:lang' attribute. Multiple instances of the <status/> element MAY be included but only if each instance possesses an 'xml:lang' attribute with a distinct language value.



--
You received this message because you are subscribed to the Google Groups "XMPPFramework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xmppframewor...@googlegroups.com.
To post to this group, send email to xmppfr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xmppframework/5b4ddbfe-260a-4083-be4d-7520edf89e0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ashutosh Thakur

unread,
Dec 22, 2014, 5:46:57 PM12/22/14
to xmppfr...@googlegroups.com
@ ObjColumnist

Thanks a lot! 
Message has been deleted

Ashutosh Thakur

unread,
Jan 8, 2015, 1:47:02 PM1/8/15
to xmppfr...@googlegroups.com
I had an issue where Device1 could see Device2 online however Device2 was not able to see Device1 online. The issue is resolved and I would like to update the thread with what seems to be a problem on my end. Might help someone in future to debug.

Basically I was getting my Roster and then Presence..Presence was looking for the user in core data using this method:

- (XMPPUserCoreDataStorageObject *)userForJID:(XMPPJID *)jid xmppStream:(XMPPStream *)stream managedObjectContext:(NSManagedObjectContext *)moc

In my case it was returning nil as the database was not populated at the time. That was the reason why presence was not reflecting properly on UI. My quick solution to test it was to send my Presence after I am sure I have a Roster populated and saved.

Thanks.

MEHUL PANCHAL

unread,
Feb 1, 2018, 8:14:50 AM2/1/18
to XMPPFramework

  Hi Ashutosh Thakur,

  Can you tell me how we can retrieve presence of roster after entering into screen of that particular ? i already tried many ways
  

  Please help!
Reply all
Reply to author
Forward
0 new messages