Skip to content

Provide a working example instead of unclear placeholders #34828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
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