Open OndroMih opened 6 years ago
SseEventSource::open is synchronous. The Javascript processing model would require any such operation to be non-blocking, and the corresponding method async. We have more options in Java.
I don’t recall anyone requesting an async version of open (or close) yet.
On Apr 26, 2018, at 3:42 AM, Ondrej Mihályi notifications@github.com wrote:
I assume that SseEventSource.open is meant to be non-blocking and not wait until the connection is established but the Javadoc doesn't make it clear.
The Javascript version of EventSource https://developer.mozilla.org/en-US/docs/Web/API/EventSource/onopen specify an opopen method to specify a handler to be called after the connection is established.
Ideally, open should return a CompletableFuture or another async API in a similar way as Invocation.Builder rx methods.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/eclipse-ee4j/jaxrs-api/issues/625, or mute the thread https://github.com/notifications/unsubscribe-auth/AFU9N6NKrF4WExHcHQnVcsO8ri9hh-9hks5tsaSxgaJpZM4Tk78z.
@spericas Can we provide the non-blocking open in SseEventSource with a open handler too ? Then SseEventSource#open doesn't need to wait the connection created and do the following things :
eventSource.open(); //this is blocked and wait the sse connection
client.target("http://foo.bar/test").request().post(Entity.entity("msg", MediaType.TEXT_PLAIN_TYPE));
@jimma I've re-purposed this issue to consider adding an async open. Suggestions on how to define a handler for it are welcome.
In the future, can the blocking version throw a TimeoutException or something like that?
I assume that
SseEventSource.open
is meant to be non-blocking and not wait until the connection is established but the Javadoc doesn't make it clear.The Javascript version of EventSource specify an
opopen
method to specify a handler to be called after the connection is established.Ideally,
open
should return a CompletableFuture or another async API in a similar way as Invocation.Builderrx
methods.