I've written a small PBI and JS for handling Comet requests. It uses the long polling technique. It works, but with a limitation: if you have two (or more) webpages open, only one of them receives the response. This may be a bug in the JS rather than the PBI - I don't know yet.
I'll post the code for this setup soon (I'd like to try and solve the above problem first). In the meantime I have a question for people who know more about this stuff than me...
The long polling technique is pretty crude, and also not reliable cross-browser because different browsers wait different lengths of time for a response before simply cancelling the request. It also means that your server will have loads of open connections, all the time, waiting to be responded to and closed. And in Chrome, the "Waiting for website.com..." status remains onscreen constantly.
Apart from long polling, there are some other methods.
One of them is server push. That article describes stuff I don't understand, especially this:
But there's a (possibly much better) method: server-sent events. This is the one I'm really interested in. Does anyone have any experience of doing this? If not, does anyone know if this kind of thing is possible with PB?the web server does not terminate a connection after response data has been served to a client. The web server leaves the connection open such that if an event is received, it can immediately be sent to one or multiple clients. Otherwise the data would have to be queued until the client's next request is received