One With The Machine
Yes, I'm there. I'm in that zone. Like Martin just told me via IM, its a good thing I have an understanding wife. I haven't showered/shaved since Monday and I just woke up (and it's almost 2 p.m.) after going to bed around 6:30 a.m. again... I'm in that total-focus zone. If you aren't a programmer you have NO idea why several 20 hour sessions in front of a computer is at all enjoyable, but believe me it's sooooooooo nice to get it all out.
You have all these ideas and never enough time to implement them. Or you start to get into what ever you're developing and then you have to stop for whatever reason and you don't get started again for a week. It's so great to get to sit down and get it done.
I thought I was going to be done with the first stuff by now. I can't quit now because I'm quite close, but I'm in the middle of Jabber-parsing hell at the moment. I'm not using any of the libraries out there because they're either for J2SE or come with weird licenses (1% of my income??) or just don't work. So I'm parsing the XML with KXML2 and it's not particularly intuitive, but it does work and is better than parsing the XML myself. However, that doesn't mean that understanding the varied messages that Jabber sends out is any easier. Here's some links for your education: Core elements, Conferencing messages, and the XMPP spec itself right from my currently open browser.
In case you don't know anything about Jabber or just a little like I did before, the way it works is that you open a couple socket connections to port 5222, one for writing and one for reading. You then communicate to the server by writing ONE xml document - this document starts with this:
<stream:stream xmlns:stream='http://etherx.jabber.org/streams' to='host.com' xmlns='jabber:client' >
Notice how that message isn't closed with a / at the end? That's because you've just opened up a virtual XML document. Now you stuff fragments down the pipe like:
<iq type='get' to='user@domain'> <query xmlns='jabber:iq:last'/> </iq>
There's only three types of messages (xml element types): Presence, Message and IQ. IQ stands for info/query and is how you ask for server capabilities and things like that. Then when you're done, you send a </stream:stream> message to close off your document and that's how you sign out. Incredible isn't? The entire time, the server has done the same thing, so you're watching its document as it comes down as well.
Thankfully, KXML2 actually uses an InputStream as its input, not a file or something like that, so all I have to do is open up the stream to the Jabber server and pass it to the KXML2 parser and then listen to the events it throws (more or less). The big problem is that I'm used to working with DOM-like XML docs, not parsing piece by piece, so it sort of sucks to have to try to figure out where I am in the stream and then move forward step by step through the tree to get the info I need, rather than just saying .getElement("name") or something simple like that.
Okay. I'm shaving/showering than back to work. You know it's bad when I went downstairs to the store yesterday (wearing a baseball cap to cover my perma-bed head - which actually doesn't work since no one here where's baseball caps... so they look at you funny anyways) and I'm thinking "is 2 liters of Code Light enough? I guess I could always come back tomorrow...". I am one with Caffeine as well...