Skip to content
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

EventSource: how to know the client disconnected? #749

Open
katatunix opened this issue Jan 7, 2021 · 2 comments
Open

EventSource: how to know the client disconnected? #749

katatunix opened this issue Jan 7, 2021 · 2 comments
Labels

Comments

@katatunix
Copy link

In the module [EventSource] (https://suave.io/Suave.html#def:module%20Suave.EventSource) I don't see any function to detect the client is disconnected.

My use case is: the server side (using Suave of course) observes data from an external source, then forward those data to the client side. But it should stop that observation, and finish the socket computation, as soon as the client disconnected.

That would be nice if there is an Async<unit> which will be done when the client disconnected.

How to achieve that?

@ademar
Copy link
Member

ademar commented Jan 8, 2021

The only way to know if the client is connected is by polling the socket or trying to read or write to it which would raise a connection reset exception.

I think you would need to bake such a thing into your handler.

@ademar
Copy link
Member

ademar commented Jan 8, 2021

Also related #321

@ademar ademar added the feature label Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants