Using XIFF to send Custom Messages

Hi,

I am building a Flex chat client for OpenFire that will be embedded within a larger web application where we need the ability to push things to the client. For example, we would like to be able to enable or disable certain buttons on the UI from a moderator panel, push images (like a slideshow), and even turn the chat client on and off remotely.

Since we already have a connection to OpenFire, it occurred to me that it would be nice if I could create custom messages and send them through chat, but have them be intercepted and handled by our custom client.

Is it possible to define a custom message used only by my application, but send it through the existing connection to OpenFire? What does XIFF and/or OpenFire do with messages that are not one of the predefined XMPP types?

Bill

Bill,

You might want to read up a bit on the Jabber protocol. Basically the way it works is that there are general message types.

So within XIFF (look at the Room.as implementation) you could define your own custom message sending code. Using XIFF you can set up a callback to get fired when a response to a message you send comes back.

You can write plugins for openfire and these plugins can intercept packets and examine them to see if they contain your custom tags – It’‘s lots of work, but when it’‘s done it’'s pretty cool.

-Walt

Thanks for the info. I actually started reviewing the specifications for the protocol just before you recommended it, but I have now reached a point where I have a few more questions.

As nearly as I can tell, IQ msgs should be the preferred way of extending the protocol to accommodate custom messages. But when I look at all the use cases in the specs, it appears that it is always the client sending a get or set request to the server and the server responding. Is it kosher to have the server send unsolicited messages to clients? I can see what appears to be code to accommodate this case in XMPPConnection (i.e. it appears to check for a pending IQ with the same id and invokes the callback if one is found, but if not it creates and dispatches an IQEvent). I assumed this was to allow the server to send an IQ that was not the ‘‘result’’ of some client inquiry, but I also noticed that although handleIQ() appears to dispatch the event, IQEvent is not one of the events published in the list of events for XMPPConnection. Can I register a handler on the XIFF client for unsolicited IQ messages from the server?

Basically, what I would like to do is extend the protocol so that e.g. a user with moderator privileges could click a button to enable or disable a feature, show or hide a button, etc. on the client UI of all users in a particular room. I can see how I can write an extension in XIFF and a plugin in OpenFire to allow the moderator client to send this request and the plugin to process it, but I need to not only have the plugin respond to the sender, but also send some control (IQ) message to the room so that each client in that room will receive it. Can I just send the IQ msg to the room itself and it will be distributed all occupants? If I read the spec correctly, a chat message sent to the room is reflected to all the occupants, but I can’‘t find for sure whether this is also true for IQ messages. Do the IQ messages have to be sent directly to a user? If so, what API’'s on the server side would be relevant to allow me to iterate over the room occupants and send each of them this control message?

Oh well, I’'ll let you digest this one first before I ask anything else. Any help or suggestion is appreciated.

Bill Bailey