0
votes

Being new to XMPP and Java (I am iOS dev) by following some tutorial I managed to write a server component (Openfire) and client iOS app (using robbiehanson's ios xmppframeowrk). I could able to send and receive message to and from component <-> iOS client. Here is a abstract code:

Sending presence from iOSclient app to server component:

XMPPPresence *presence = [XMPPPresence presence];
[presence addAttributeWithName:@"to" stringValue:serverComponentJid];
NSXMLElement *someInfo = [NSXMLElement elementWithName:@"someInfo"
                                               stringValue:@"xyz"];
[presence addChild:someInfo];
[_xmppStream sendElement:presence];

Receiving the packet in server component:

if (packet instanceof Presence){
        org.xmpp.packet.Presence recvPresence = (Presence) packet;

Element theInfo = recvPresence.getChildElement("someInfo", "***what_shoud_be_the_namespace_here***");
System.out.println("Some info in the presence as " + theInfo.attributeValue("someInfo"));

I can print the packet and see the someInfo. When i pass "" in the namespace then i am able to get it correct which is understandable. However I still dont understand what and how to use namespace in xmpp. Any guide, tut, link, ref or answers please

1
UPDATE: Edited the question. If i send an empty string then i am able to get the child element. like Element theInfo = recvPresence.getChildElement("someInfo", "");. However I still need some info on understanding xmpp namespace. Any ref.. links etcSaffronState

1 Answers

0
votes

Namespaces are used to define the "usage/scope" of a Stanza (Packet). They are used to define functionality and to bind actions (parser, listner and so on), so any API will be able to add a behaviour (default or custom) based by tagName and namespace.

So a namespace it's used like a reserved key for the protocol.

With custom namespaces it's possible to define custom IQ (or anything else) and have custom logic/parser etc. to fire exaclty when you want and obtain n custom actions as you like and need.

Official docs:

https://datatracker.ietf.org/doc/rfc6120/?include_text=1

And more:

http://xmpp.org/extensions/index.html