-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RemoteEndpoint.Async methods could provide better connection back to the Session #185
Comments
@glassfishrobot Commented |
@glassfishrobot Commented |
|
Exposing the session via the The comments re Exposing the |
I'd like to come up with a solution that's lamda friendly 🤓 |
@joakime What did you have in mind over and above adding Note: In the |
@markt-asf Having the So you see a use that might look like this? RemoteEndpoint.Async async = session.getAsyncRemote();
async.sendText("Sequence 1", result -> {
Session asyncSession = result.getSession();
if(!result.isOK()) {
asyncSession.close();
}
}); |
Yes, something along those lines. |
I've been looking at this some more. Adding I'll give it a couple of days and, unless the discussion goes in another direction, create a PR to add this new method. |
In with the callback and the Future version of the RemoteEndpoint.Async there is no obvious way to discover what the original Session object was, this makes things a little bit more complicated when you are trying to broadcast to a number of listening clients.
Ideally the "SendResult" object should have a reference to the original Session that way the SendMessage object could be implemented with once instance rather than one for each Session. This would allow the broadcasting code to be able to check the state of the Session, perhaps dealing with a odd exception by checking to see if the Session is still open / or valid.
Having to write some kind of if/else code to deal with the Throwable parameter on SendResult also feels a little bit dirty particular as normally we are expecting SessionsException. Could we always get a SessionException instead that might have a more generic cause - this would make life a bit easier. I guess this would also be another way to get hold of the Session consistently.
It would also be nice for consistency if the Future returned by the polling version of the API instead of returning
Future<Void>
returnFuture<SendResult>
for consistency. Although obviously the semantics might be different in a failure case - I suppose it could also returnFuture<Session>
but it would be less flexible.Affected Versions
[1.0]
The text was updated successfully, but these errors were encountered: