flutter_client_sse icon indicating copy to clipboard operation
flutter_client_sse copied to clipboard

How to close current opened EventSource session in flutter_client_sse?

Open alaa2003 opened this issue 5 months ago • 0 comments

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

alaa2003 avatar Sep 26 '24 20:09 alaa2003