[JDEV] Sending message in xml tags
Matt Tucker
matt at jivesoftware.com
Wed Apr 23 07:59:00 CDT 2003
Satish,
You can always add and remove XML elements on the fly and then use XML
parsing routines to figure out incoming packets. However, it sounds like
you're just looking for a very simple way to to programatically pass
info back and forth between two XMPP nodes? If so, I'd recommend
checking out our Open Source client library Smack --
http://www.jivesoftware.com/xmpp/smack
The feature that may help you most is the ability to attach an arbitrary
map of data (including Java objects) to each packet. As an example:
Setting Properties:
Message message = chat.createMessage();
// Add a Color object as a property.
message.setProperty("favoriteColor", new Color(0, 0, 255));
// Add an int as a property.
message.setProperty("favoriteNumber", 4);
chat.sendMessage(message);
Getting those same properties would use the following code:
Message message = chat.nextMessage();
// Get a Color object property.
Color favoriteColor = (Color)message.getProperty("favoriteColor");
// Get an int property. Note that properties are always returned as
// Objects, so we must cast the value to an Integer, then convert
// it to an int.
int favoriteNumber =
((Integer)message.getProperty("favoriteNumber")).intValue();
This is a different solution than what you were asking for, but it could
be much simpler if I understand the problem you're trying to solve.
Regards,
Matt
Satish Plakote wrote:
> hi
> i am using muse api from http://www.echomine.org/projects/muse/
> Trying to develope a java client.
>
> Let me put it through an example
> I want to send a XML info of this type to a user ' xyz '.
>
> <message to="icm at jabber">
> <x xtype="forward" xmlns="http://abc/jabber">
> <forward call="callid" to="xyz at jabber" />
> </x>
> </message>
>
> I will be adding /deleting nodes on the fly.
> I have not been able to come across classes/Api's that allow
> me to do it.
> I can send plain mesages to any user,but not in XML format.
> I hope i have been clear abt my problem.
> I would appreciate links that give me some good code sample
> rather than
> theory.
>
>
> Rgds
> Satish
>
>
>
> _______________________________________________
> jdev mailing list
> jdev at jabber.org
> http://mailman.jabber.org/listinfo/jdev
More information about the JDev
mailing list