Back in June I spent an enjoyable weekend at Google’s London offices attending the delightful HackCamp. For being such kind hosts, I thought it only right to come up with a hack that combined the Atlas API with Google App Engine.
As I have mentioned before Atlas, along with its core services, indexes content that has recently been mentioned on Twitter and maintains a playlist of it. This constant stream of interesting content feels like it would be best served as soon as it’s available. App Engine provides a really simple interface to sending and receiving XMPP messages, a real-time technology that I was particularly interested in playing with.
XMPP is an XML protocol focused on real-time communication and is best known for powering popular chat services like Google Chat. App Engine allows developers to build applications that can communicate over XMPP by marshalling the XMPP messages to and from HTTP calls. So if a user adds
YOUR_APP_NAME@appspot.comto Google Chat and sends it a message, an HTTP request will be sent to
http://YOUR_APP_NAME.appspot.com/_ah/xmpp/message/chat/So, back to the hack.
I figured the easiest way to demonstrate how this real-time technology could be used to enhance the Atlas API’s data, would be to just send messages about the latest content to anyone that wants to hear about it. Firstly I used App Engine’s cron service to periodically trigger the system to check the newly mentioned content from Atlas. Then the new items are queued up, using the queueing service, and each one sent out as an XMPP message to anyone that’s registered an interest. The code to actually send out the message looks like this:
So it’s really pretty simple, and with some crude formatting, your chat client quickly starts receiving a stream of messages like:
I have put the code for the system at: http://github.com/thesmith/realtime and the application ID is firstname.lastname@example.org, which you can add as a Google Chat contact. Firstly though, you need to register your interest with the system at http://realtime-video.appspot.com/register.
This hack, and all the others that I’ve mentioned over the past few weeks, are hosted in the Atlas API’s App Gallery. It would be great to have the gallery busting with inspiring things that people have made using Atlas. So please, let me know what you’ve built and I’ll add it to the gallery and tell everyone about it here!