[JDEV] Server problem and JabberBeans problem

Matt Tucker matt at jivesoftware.com
Mon Jan 6 08:56:59 CST 2003


Adrian,

> Also, I'm trying to make a Jabber Client (I'm not a great programmer),
> I'm using JabberBeans.  I want to be able to send an object within a
> <message> tag.

You'll need to encode the serialized object as text. It's fairly easy to
do so:

  ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
  ObjectOutputStream out = new ObjectOutputStream(byteStream);
  out.writeObject(value);
  // Note: you'll need to track down a method to encode data as base-64.
  // There are quite a few of them though.
  String encodedVal =
StringUtils.encodeBase64(byteStream.toByteArray());
  // Now, add the encoded value as an x element of the message.
  // Finally, decoding on the other end looks similar, except in
reverse.


I'm not sure how you can add and get custom elements in JabberBeans,
though.

Regards,
Matt




More information about the JDev mailing list