Provide a working example instead of unclear placeholders
See gh-34828 Signed-off-by: Artur <artur@vaadin.com>
This commit is contained in:
@@ -45,13 +45,26 @@ import reactor.core.publisher.Mono;
|
||||
* public Mono<Void> handle(WebSocketSession session) {
|
||||
*
|
||||
* Flux<WebSocketMessage> output = session.receive()
|
||||
* .doOnNext(message -> {
|
||||
* // ...
|
||||
* .doOnNext(message -> {
|
||||
* // This is for side effects such as
|
||||
* // - Logging incoming messages
|
||||
* // - Updating some metrics or counters
|
||||
* // - Performing access checks or validations (non-blocking)
|
||||
* System.out.println("Got message: " + message.getPayloadAsText());
|
||||
* })
|
||||
* .concatMap(message -> {
|
||||
* // ...
|
||||
* // This is where you handle the actual processing of the incoming message. It
|
||||
* // might involve:
|
||||
* // - Parsing the message content (e.g., JSON parsing)
|
||||
* // - Invoking a reactive service (e.g., database, HTTP call, etc.)
|
||||
* // - Returning a transformed value, typically a Mono<String> or Mono<SomeType>
|
||||
* // if you're mapping to another data format
|
||||
* return Mono.just(message.getPayloadAsText());
|
||||
* })
|
||||
* .map(value -> session.textMessage("Echo " + value));
|
||||
* .map(value -> {
|
||||
* // This is where you produce one or more responses for the message
|
||||
* return session.textMessage("Echo " + value));
|
||||
* });
|
||||
*
|
||||
* return session.send(output);
|
||||
* }
|
||||
|
||||
Reference in New Issue
Block a user