When a browser is a client, you typically don't have multiple read events.

Filip

Pieter Fibbe wrote:
Hi,

I have been trying to write a Comet webapp, but it's not totally clear
to me when and how CometEvents are exactly triggered. According to the
documentation a "typical life cycle of a Comet request will consist in
a series of events such as: BEGIN -> READ -> READ -> READ ->
ERROR/TIMEOUT" (from: http://www.mbaworld.com/docs/aio.html).

It seems that a READ event is triggered only by a POST request, but
the "event flow" that I am getting never triggers more that one READ
event in a row, for example: BEGIN-> ->READ->END, BEGIN-> ->READ->END,
etc. Is the way a comet application should work? So you have to
establish a new connection every time you get a response from the
server and wait for the next response, process it and start from the
beginning? My idea was having one connection and reuse that connection
for multiple requests. So on the client side there would be something
like the following code:


<script>
var xhr;
function init() {
        xhr = new XMLHttpRequest();
});

function triggerEvent() {
        xhr.open("POST", "/servlets/cometservlet", true);
        xhr.send("something");
}
</script>
<input type="button" onclick="triggerEvent" />


Since it is not possible to invoke xhr.send() several times without
opening the connection first (xhr.open()), a CometEvent.BEGIN is
always triggered first. So how can the "BEGIN -> READ -> READ -> READ"
series (given in the documentation) be implemented?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to