Administrator Functions

Currently I use FML as a jabber client inside our corporate intranet but needed to build a server side jabber alerter, so I am back using smack for this. Sending a message to one recipient is great, but I would like to use some of the admin functions within Jabber. Like MOTD or a plain announcement.

I love the ability to add XHTML to the body, however if there was an interface that allowed me to just send an xml node to the Jabber server that I formatted on my own that would be great, this way I could send my own packet that might look like this :


Server 1 and 2 are down

If there is already a way to this, please enlighten me.

Christopher,

You have a few options:

  1. At the most generic level, the Packet class is easily extensible. Here’'s a simple way to send arbitrary XML:
Packet myPacket = new Packet() {
    public String toXML() {
        return "<message to=\"comm.trvloffice.com/announce/MOTD\">" +
               "<body>Server 1 and 2 are down</body></message>";
    }
};
con.sendPacket(myPacket);

The disadvantage to this approach is that you need to do all the work of assembling the correct XML. Also, for your specific example packet, you could just create a new Message call setTo(String) and setBody(String).

  1. Packet extensions are specifically meant to address being able to insert and parse arbitrary XML snippets. If you’'re sending IQ packets, IQ providers do the same thing. Please see the Javadocs including the provider package and let us know if you have specific questions.

  2. If you’‘re writing both ends using Smack (doesn’'t sound like this is the case), you can use Smack properties, which are described in the documentation. This provides a very simple way to attach arbitrary data to any packet, including Java objects. Internally, this is implemented as a packet extension.

Regards,

Matt

thanks matt