Friday, January 4th, 2008

Mibbit: Ajax-based IRC Client

Category: Ajax, JavaScript

<p>I’m always surprised but what people are building using JavaScript & Ajax. It’s spurred so much creativity over the last two years and it doesn’t appear to be stopping soon. Most recently, I discovered Mibbit, a JS/Ajax-based IRC client, and had the opportunity to interview the developer of the site, Jimmy Moore.

What prompted you to build it?

I had a few reasons for deciding to build mibbit.
Firstly, I install new o/s’s from time to time at home, and sometimes need a little help with installing/updating a particular driver/package etc, so would have to install an irc client. I wasn’t a massive irc user at the time, and so having to install a client each time I wanted to ask a question on #linux for instance irritated me.
Secondly, I tried other web irc clients. For me, the standard of java applet, sucked. Very slow to load, very very ugly kludgy.
So I thought ajax would be a good way to make an easy to use and convenient irc client for the masses.
After I had built most of it, I found cgi::irc which does a similar type of job.
I also decided to built it to learn javascript, and to work out how to get the maximum performance out of comet style XMLHttpRequest things.

Did you use any specific lib or is all of the DOM/Ajax/JS homegrown?

I programmed the initial version in javascript, with a php backend from the ground up. I wanted to understand everything fully with the communications, so I did not use any libraries. PHP/apache didn’t scale so well, and so I rewrote the backend in java using nio. I’m now pretty confident it’ll scale to tens of thousands of connections (php/apache topped out at around 20). I did look at other backend options, but didn’t find one that was specific enough and tuned enough for what I wanted.

Can you explain a little bit about the underpinnings of the app so folks can know how it works?

The first part I got working was the communications between browser and server. That’s done using 2 XMLHttpRequests. The first one is simply to send data from browser to server. It utilizes keep-alive, to minimise new connections.

The second XHR is the ‘receive lazy polling’ one. It connects to the server, and the server holds it open until there are messages available, or a timeout expires. This one is also keep-alive, so the next request goes down the same connection.

What you end up with is 2 connections held open to the server, with packets (json in this case), and some http headers from time to time.
To make sure the server would scale, I wrote a custom webserver in java using nio. It handles all of the connections in a single thread and as I say, scales to tens of thousands of connections.

If the client requests a new connection, it sends a request to the webserver, which then connects out, and starts proxying etc. It also runs an ident server in the case of irc connections so that an irc server can identify individual browsers. I looked at existing frameworks etc to do this sort of thing, but I valued learning how it all works, and thought that my use case may be specific enough to be able to optimise more than general frameworks can.

What are the main features and what are future enhancements?

I’ve tried to pick cool features that perhaps some other clients don’t have, but this is a work in progress…

  • Connect to multiple servers/channels
  • Activity on blurred tabs shows up by tab turning yellow
  • If the mibbit.com window/tab doesn’t have focus, it flashes “people said stuff” to notify you something happened
  • Tab completion on nicknames
  • Parsing of smilies, nicknames, urls, mIRC color codes
  • Full utf-8 support
  • Typing notify – people who are currently typing, and are using mibbit (They have a green top on), turn red.
  • Recent chat – If you join a channel, which is currently joined by a fellow mibbit user, you’ll get a little recent chat from that channel to give you some idea of what’s going on (This is one of the features that would be hard to add to a desktop client – leveraging from the fact mibbit is centralized – same with the typing notifies which do not go over irc connections)
  • Input history – up down arrows
  • Runs an ident server and communicates the browsers IP address to the IRC server so that individuals can still be identified uniquely

In terms of future enhancements, I’d like to make everything fully customizable – people have very different opinions of what is nice (smilies/not smilies etc). Also more features that leverage off the fact that it is centralized, building on top of chat networks to add extra features such as the typing notify/recent chat.

Is this an OSS project? Can others help?

At the moment it is not open source. The idea is to first enable publishers to embed a client in their websites. This varies from embedding the whole client, or a specific channel, or a PM. For instance you could use it to have a link saying [PM me on irc] and that would open a new window with a chat pane in it PMing you on a given irc server. Or you could embed a specific channel in an iframe on your site. The next stage would be to allow further integration with an open API, customization etc.

Posted by Rey Bango at 6:46 am
1 Comment

++++-
4.1 rating from 49 votes

1 Comment »

Comments feed TrackBack URI

This is nice, but nothing new. Check out http://orbited.org/livehelp.html — it is a web-based irc client released under the MIT license. It is based on a full web-based irc client called WebIRC, also released under the MIT license.

Comment by heyadayo — January 4, 2008

Leave a comment

You must be logged in to post a comment.