There's an opensource Java client already out there:http://www.jamochamud.org/index.htmlI've been using it for a couple years now. I'm sure with minimal effort, one could modify that code for any purposes necessary.
HTML use enabled
Smilies option ON Smilies lookup table