what to do? ReadFlushMessage () will wait for this. message to get new content.
Not quitting the websocket connection immediately
private Set<String> message = new HashSet<>();
private void writeMessage(String message) {
this.message.add(message);
}
private String[] readFlushMessage() {
String[] _message = (String[])this.message.toArray();
this.message = new HashSet<>();
return _message;
}
private Publisher<Void> websocketPublisherA(HttpServerRequest request, HttpServerResponse response, WebSocketServerHandle handleObject) {
return response
.header("content-type", "text/plain")
.sendWebsocket((in, out) ->
out.options(NettyPipeline.SendOptions::flushOnEach)
.sendString(
Flux.just(readFlushMessage())
)
);
}