Skip to content

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

@alaa2003

Description

@alaa2003

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions