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

Server Sent Events (SSE) #23

Open
sirinath opened this issue Jun 2, 2020 · 1 comment
Open

Server Sent Events (SSE) #23

sirinath opened this issue Jun 2, 2020 · 1 comment

Comments

@sirinath
Copy link

sirinath commented Jun 2, 2020

Do you have a way to do SSE?

If not is there a possibility to add this functionality?

@eduard-vasinskyi
Copy link
Contributor

Hello, @sirinath
There is currently no API for Server Sent Events. However you can easily achieve this functionality by utilizing 'CSP' module.
Just create a ChannelSupplier of events, encode each event as a separate ByteBuf and send it as a body stream of an HTTP response. And don't forget to add header Content-Type: text/event-stream.
Here is a demo snippet that illustrates how it can be done: https://gist.github.com/eduard-vasinskyi/65287c900a70288a1b298a9027b26ca5
Each second, server sends an event that contains current time.

If you have more questions, please feel free to ask.
We will let you know once full support for Server Sent Events will be implemented.

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