go-sse icon indicating copy to clipboard operation
go-sse copied to clipboard

Session close/release support

Open coyzeng opened this issue 6 months ago • 1 comments

Session can not be closed by server side.

coyzeng avatar Jun 06 '25 04:06 coyzeng

Hi there and thank you for opening this issue!

If you are using an sse.Provider the subscription is automatically ended when the context passed to sse.Provider.Subscribe is canceled.

Other than that a session is just a wrapper around the net/http request and response. The SSE stream itself is over when the request handler closes.

If you want to send a custom close message you can just use sse.Session.Send after the sse.Provider closed the subscription. To control when that happens, use a context with cancellation.

By giving me some more insight into what exactly you're trying to achieve and possibly some code samples I could assist you better. Let me know how I could help you further!

tmaxmax avatar Jun 06 '25 12:06 tmaxmax