Catalina Creek Builder

Subscribe to news  Blog

« View All

Tomcat Comet Pushlet Sample Fixes
-Brian Johnson, Friday, March 14th 2008, 07:10AM
The chat sample used to illustrate Tomcat's CometProcessor doesn't work. To be fair, it is listed as pseudo code and it's nice in that it illustrates the proper flow, but I wanted more proof and so fleshed out the sample to be able to chat.

The major changes:
  • It compiles
  • If you request chat, your message is added to the list (original version just throws them away)
  • Any request other than chat is a hold. This is the 'long poll' socket -- a response is not returned immediately.
  • Chat messages are posted to the held sockets.
  • It uses the JSESSIONID cookie to track if there has already been established. If so, it's released. This fixes a case in Internet Explorer where if you navigate away, the socket is still held & when you return to the chat page, you miss message.

The code is here.

Update (2/25/2009): I took down the chat pushlet server, as I'm no longer running Tomcat on port 80. The code (a bit hacky, I know, but I didn't want to completely rewrite the sample) moved around, but it's there again.

Comments:

Leave a Comment:

Name: (required)
Email: (required, will never be published)
Website:
Comment: