I don’t know of any formal libraries but there have been a few implementations thrown around.
- Page polls every 5 seconds or so to the server for new chats
- Chats saved on server as XML (I believe), though they could be database entries but that might be slower.
Comet implementation (not a fan of the name, but hey, though this is the more difficult implementation)
- Use Flash or a Java applet to open a socket to the chat server and do your own communication.