Choobula Chat
I thought I would make some use of the GootProductions Labs and post a little side-project I’ve been working on… Choobula Chat.
“Wait… what?” you might ask?
But of course! Choobula Chat, the latest and greatest chatting sensation!
The basic idea is this: hook up a Flex 3, socket-based chat app with a tiny Python push server. End result? A really fast, really pretty, socket-driven chat app.
What’s with the name?
It revolves around a lovely lady from New Zealand who has some, shall we say, problems pronouncing the word “tubular.” We thought it was pretty funny, so we posted it on the “interchoobes.” Hopefully she doesn’t kill us for this…
Flex
Most of the heavy lifting on the Flex side is done using a XMLSocket. It’s a pretty easy-to-use full duplex socket connection, which enables all the fancy connection magic that makes Choobula Chat so cool. Although XMLSocket’s name leads you to believe that the protocol is somehow XML-based, I’ve found no evidence of this being enforced anywhere. Choobula Chat uses some ugly HTML/plaintext mashups and nobody seems to mind.
Here’s the Choobula Chat source (please forgive the hackiness of the code!)
Python
The server proved to be a tad trickier, but that’s mostly because I’m still learning Python (great language, by the way. Totally beats Java any day of the week). Luckily, I found a great post by Daniel d’Andrada T. de Carvalho about Python’s built in ThreadingTCPServer — I essentially used his code as a starting point (and you can really tell!)
Here’s server.py
Run the script, then give it the hostname you wish to publish on (try this site if you’re not sure) and a port (greater than 1024). Tell clients to connect to your_hostname:port (e.g. my.computer.my.isp.net:1337)
If you prefer precompiled versions, here’s the client and server
The server exe is the .py script, compiled with py2exe, compressed into a self-extracting archive with 7-zip, then packaged in a one-click form using AutoIt3. Kinda hacky, but it works.
Copyright
All code in this example (chat.mxml and server.py) is licensed under the MIT license:
Copyright© 2008 GootProductions
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.