Server-sent events in fluent-http
Today, I’ve added the initial support of Server-sent events in fluent-http.
The underlying http server we use (Simple) doesn’t support websockets yet. But streaming good-old server-sent events works very well.
To produce a stream of messages, we rely on the Java 8 Stream API.
new WebServer(routes -> routes
.get("/events", () -> Stream.iterate(0, (a) -> a + 1)))
.start(9090);
This code streams the values 0,1,2,3,4,5… for ever.