0
votes

Server is Openfire with custom component running and Client is iOS

1> User1 authenticates and then creates room1 and then sends a
presence to server_comp

2> Server_comp invites User2 to join room1 on behalf of User1

3> User2 accepts the invitation and joins the room.

4> All the message stanza conversation continues well.

I want to notify User2 whenever there is location coordinate changes at User1 client side. This I want to do through presence stanza.

Now User1 sending presence stanza without mentioning presence.type (available) to the room jid along with location element.

The presence stanza from User1 to room is not received at User2.

I have this delegate implemented, but this never hits. What is the use of this delegate?

-(void)xmppRoom:(XMPPRoom *)sender occupantDidUpdate:(XMPPJID *)occupantJID withPresence:(XMPPPresence *)presence {
  NSLog(@"%@ updated status with presence %@",[occupantJID full], presence.debugDescription);
 }

If i send default presence like unavailable type etc it works fine. I referred XMPP definite book and other online docs but could not find any help.

Now my understanding is the custom edited (added location attributes to the presence) presence is simply ignored by the room itself. MUC might be ignoring presence with other non-understandable elements. Is this my understanding correct?

I have a second question as:

The server component invites User2 to join User1 created room. Once user2 joins the room, then after some time if any of the user1/user2 left the room then why the server_comp also gets a unavailable presence though the comp itself is not part of the room? Is it like because server_comp invites User2 on behalf of user1?

1
About first: should be ignored but depend on implementation. However specs let available to programmer custom tags, but probably you'll just need to manage jabber:x:event and/or add extra events. About 2: depends mostly by implementation and Openfire configurationMrPk
@MrPk About first: are you saying that i can still configure server to accept altered presence stanza from occupants? I couldnt get any reference. Could you please provide some reference if possible? About 2: As you might be aware of poor documentation of openfire, except looking into code there is no other choice, is there?SaffronState
I will add an answer even I can't reply exactlyMrPk

1 Answers

0
votes

I know I can't full reply to your questions but there are many things to talk about: I'm a java developer and I was also a iOS one, but I don't know xmpp for iOS.

In general, there's no mechanism to validate any XML in OPENFIRE, so you can modify any XML as you want. Since Openfire works with XML Pull Parser library, it's safe to add new attributes as LAST ONES.

So if a message it's like

<message>
<body attr1="value1" attr2="value2">
</body>
</message>

add your custom tag in this way:

<message>
<body attr1="value1" attr2="value2" customattr="customvalue">
</body>
</message>

because XMLPullParser works with positions of attributes, so if in Openfire code there will be a direct access to a position (xml[1]) you'll not destroy any functionality. About tag order there's no problem, just don't wrap original root tag so as examples both will works:

<message>
<body attr1="value1" attr2="value2">
<customtagname xmlns="saffron.state:customaction"/>
</body>
</message>

<message>
<customtagname xmlns="saffron.state:customaction"/>
<body attr1="value1" attr2="value2">
</body>
</message>

However XMPP specs are really flexible as I know so there are some mechanism to add definied events and custom tags more or less in every Stanza (=Packet) that a client can intercept (in Smack API with a StanzaListener/Filter).

Most common elements are jabber:x:event (spec)

  <x xmlns="jabber:x:event">
    <offline/>
    <delivered/>
    <displayed/>
    <composing/>

but there is Extension Element mechanism that probably it's what are you looking for to add functionality (look here: specification)

More: presence passes mainly through Roster, but I think you are talking about groupchats. In groupchats there's a mechanism to ping user that seems transparent, the conference service has a param in minutes to kick an user that stay idle (default: 30, but there is also "never"). Openfire offer this functionality in his web console (groupchats -> Groupchat settings -> select a conference service -> other settings).

In groupchats it's not mandatory to ping the chat but you as developer can do it.