svenkubiak/mangooio

Web Sockets & Server Sent Events

Closed this issue · 1 comments

Good day,

Do you have any example that illustrates how the above can be developed using the framework?

Regards

Sorry for the late reply. While there is no support for Web Sockets, usage of ServerSentEvent on the server side is quite easy.

Setup your SSE URL in initializeRoutes() in the Bootstrap class, e.g.

...
Bind.serverSentEvent().to("/mysse");
...

Then send data to your SSE endpoint using the ServerSentEventManager at any point in your application.

...
private final ServerSentEventManager sse;
...
sse.send("/sse", "myData");
...

Everything else is handled on the client side, e.g.

https://www.w3schools.com/html/html5_serversentevents.asp