As I mentioned in an earlier post, I was working on building a chat room using XMPP (Jabber) and the XIFF AS3 API.
If you aren’t sure how to get started with XMPP and XIFF, make sure to check out that post to get you up and running.
Once I had successfully worked out using XIFF to connect with XMPP and pass data back and forth between the server and the client, I soon realized that I wanted to associate custom data with each user in the chat rooms.
The core protocol used in XMPP to express a user’s current network availability (offline or online, etc) is Presence.
On IM, you know when your buddies come online and become unavailable, etc because you subscribe to their presence.
The user’s presence is also sent to a chat room when he/she joins the room.
The default presence data typically only incorporates information about the user’s status (away, busy, available, etc).
The issue that I soon ran into with my chat rooms, was that our site already had a large collection of users with data associated with each user (id, username, picture, etc) and I wanted to associate this data with the chat users without duplicating the data.
The best place seemed to be their presence since its already linked directly with each user. The only issue I had was figuring out how to do that.
As I soon realized, the XMPP spec is extremely extensible and well thought through and XIFF has tried to manage this extensibility in its library as well.
In XIFF, extensions can be added to any XMPPStanza that is sent to the XMPP server.
By default, there are three core XMPP stanzas, IQ, Message and Presence.
Each of these stanza classes has an addExtension() method.
What I needed to do was write a custom extension class that I could pass into the Presence’s addExtension() method.
Digging in to the code, all XIFF extensions need to extend the Extension class and implement IExtension and ISerializable.
To implement IExtension, you will need to add getNS() and getElementName() methods.
getNS() will return the custom unique namespace that you will need to create and associate with this extension.
eg: http://yourdomain.com/extensionname
getElementName() will return the base XML element name to associate with this extension.
eg: extension_name
To implement ISerializable, you will need to add serialize() and deserialize() methods.
serialize() will convert the typed extension into XML data to be passed to the server while deserialize() will do the opposite and convert the received XML data into the typed extension.
For more detailed information on this, make sure to look at some of the existing extensions in XIFF’s library.
Once the class is complete, you will need to register the extension with XIFF. This registration process informs XIFF of the particular extension so that it knows how to handle it when it is received over the network.
This can be done by calling ExtensionClassRegistry.register( CustomExtension ) anytime before you try to pass the extension over XMPP.
Most extensions provide a static enable() method with the above code in it to handle this registration process.
At this point, you can create an instance of any of the core XMPP stanzas (IQ, Message, or Presence) and an instance of your new extension and then use the addExtension() method of the core stanza to pass in your extension.
The last step is to call the send() method on your XMPP connection passing in the XMPP stanza.
To finish up my particular example, I created a custom user extension that had the user’s id, name, picture, etc and attached it to the user’s presence.
This as mentioned above could be passed with the send method on the XMPP connection and anyone subscribed to my user’s presence would receive the custom extension as well.
One thing that I wanted to do was join a chat room and have this custom data associated with the presence information of all of the existing users in the room that gets broadcast out.
It took me a little bit to realize that the Room class has a feature for this already. Like I said, XMPP has thought of everything already.
When you join a chat room, you call the Room’s join() method and the second parameter allows you to add an array of Presence extensions. Just instantiate your custom Presence extension and wrap it in an array and pass it into the join() call.
Hopefully this helps out others that got stuck on sending custom data over XMPP with XIFF.
Let me know if you have any questions or want any other XIFF/XMPP tutorials.

Click image to view demo
A little over a year ago, I wrote an article for Adobe Edge on how to geocode with Papervision3D.
You can check that article out here.
Since then, however, Papervision3D has been making continual updates and the source code in my article no longer works.
This has been an issue for a while, as several people have noted in the comments on my post about the article.
I finally got around to updating it.
This new version works with the following library versions (both are the latest swcs at the time of this writing):
Here are the list of changes that needed to be made to work with the latest Papervision3D:
Here are a list of new additions made to the project:
I think that about covers all of the changes. I know many people have been asking for the markers to be interactive, so enjoy!
And without further ado, here’s the new source (make sure you grab the latest Papervision3D and Tweener libraries as well):
Download GeoGlobe