Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,26 @@
* 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);
* }
Expand Down