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

How to close current opened EventSource session in flutter_client_sse? #36

Open
alaa2003 opened this issue Sep 26, 2024 · 1 comment
Open

Comments

@alaa2003
Copy link

alaa2003 commented Sep 26, 2024

Hello
at the Browser like (chrome) its possible to close active opened event-source by just close the Browser,
now I have a server allow only 1 concurrent SSE , so only one client (session) is allowed,
for example if you tried to open new tab in browser, you will not able to call same link of Events twice (only 1 client/session is allowed)
first question is: How to close current active EventSource , for example evtSource.close() ??
second question, how to monitor current status of event-source (readyState) , for example at html version:
The readyState read-only property of the [EventSource] interface returns a number representing the state of the connection

A number which is one of the three possible state constants defined on the [EventSource] interface:
EventSource.CONNECTING (0)
The connection is not yet open.

EventSource.OPEN] (1)
The connection is open and ready to communicate.

EventSource.CLOSED (2)
The connection is closed or couldn't be opened.

[Examples]
const evtSource = new EventSource("sse.php");
console.log(evtSource.readyState);
ref:
https://developer.mozilla.org/en-US/docs/Web/API/EventSource/readyState

@unrollable
Copy link

It will automatically reconnect in any case even if you called the unsubscribeFromSSE.
I think this is a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants