Online chat is deceptively difficult due to the stateless nature of http and the web in general, causing such hurdles as session timeouts, users opening multiple windows and different accounts being signed in on one browser window. There is also the problem of users closing the browser window and logging out and such things, which make dealing with undelivered messages quite tricky.
Are there any good articles that describe how others have solved these problems elegantly?
Please feel free to write your own thoughts on how an IM like facebook or gmail's can be achieved with maximum robustness.
Is there any decent code base / writeup for integrating with a locally hosted jabber server to achieve this?
Edit: The site will be one on one chat between any member of the site - as in bob can talk to carol and bob can talk to jim at the same time in a separate chat popup. This does make it a good candidate for jabber/xmpp.
I will gladly accept the answer that is most helpful within the next 4 days.