[undertow-dev] SSE: testing time between events

Ryan Dewell ryan at dewell.org
Mon May 1 17:54:35 EDT 2017


Playing around at the moment, and missing something about the threading situation as it pertains to sending events.

In my ServerSentEventConnectionCallback:

public void connected(ServerSentEventConnection connection, String lastEventId) {
try {
  for (int i = 0; i<10; i++){
    connection.send("i="+i);
    Thread.sleep(1000);
  }
} catch (Exception e) {
  throw new RuntimeException(e);
}
}

Sending events, with one second between each.

I’d expect the time between events to be reflected in the browser / client.  However what instead happens is all 10 events arrive within the same millisecond (nanoseconds apart according to Chrome console time).

So I’m missing something here.  But I don’t see anything obvious.  For example, there is nothing like a “flush()” on ServerSentEventConnection that could be used after each event is sent.

Ideas/guidance?

Thanks!

Ryan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20170501/fde87510/attachment.html 


More information about the undertow-dev mailing list