I’ve been working on building a chat room using XMPP (Jabber) and the XIFF AS3 API.
As Mike Chambers mentioned back in August, unfortunately there’s not a lot of documentation or tutorials out there for getting up and running with this library.
If you do want to get started, hopefully this will help you out.
First things first, you’ll need an XMPP server running. I’ve setup Openfire which is an open source, cross-platform, easy to setup XMPP server.
Next you’ll need the actual XIFF library.
Once you have the server installed and setup and the library downloaded, you can follow along with Mike Chambers tutorial up above for establishing an initial connection using the XIFF library.
Now at this point, you’ve managed to connect to an XMPP / Jabber server, join a room, and send a message to the room. This was great when I was jumping in and just trying to figure out how to get started. After you get your head wrapped around this, you’ll probably ask yourself the same thing I asked myself… “sweet… but now what?”
At this point you’re kind of on your own… or at least I was. I searched and searched but couldn’t find much more than a couple of simple tutorials very similar to Mike’s.
The one exception to this was a demo that I found from Nick Velloff that included source.
The demo shows examples of connecting to an XMPP server, logging in, registering, adding buddies, removing buddies, displaying the logged in user’s roster (list of buddies), changing a buddy’s group, changing the logged in user’s presence, messaging your buddies, and creating a multi user chat room. Shew… what a God-send right?
Well, once you download the source code and try to get it running locally you’ll soon realize that its not the immediate help you were hoping for. This demo was released back in October of 2007 and since then the XIFF library has been overhauled quite significantly.
Trying to alter the demo’s source to fit the new code was not an immediately simple fix either.
So anyway, I decided to sit down last week and go through every line of the demo code and update it to work with the latest XIFF library.
I also groomed the code a bit to make it take advantage of the Flex layout engine, separate the connection logic from the view, and fix some things that weren’t completely working in Nick’s original.
One other important thing to note is that the source code of my demo includes the current XIFF library for two reasons: 1) In case the library changes again and I haven’t updated the demo, you’ll still be able to download a completely functioning sample, and 2) I had to make some minor tweaks to the library to remove the voids from the constructors and add clone and toString methods to all of the events. I have submitted bug reports for both of those issues and hopefully they will be fixed soon, but until then I made the tweaks myself.
If the team over at Jive Software does not want me to include the source I will remove it and then explain what needs to be tweaked.
Hopefully this demo will help you as much as it helped me, although I have to say rewriting it probably helped me learn XIFF a lot more than just downloading a completely working sample, so definitely take your time with it, there’s quite a lot under the hood.
To download the source, click on the image above to view the demo and then right-click on the demo to view and download the source.
Please note that my host is not setup with a working XMPP server so the demo is not functional above, you must download it and connect it to your own XMPP server to see it fully functioning.
As the XIFF library changes, I will try and keep this demo updated.