Skip to content
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

WebSockets Next: document OpenConnections #40955

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
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
25 changes: 25 additions & 0 deletions docs/src/main/asciidoc/websockets-next-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,31 @@ The `WebSocketConnection` provides both a blocking and a non-blocking method to
- `sendTextAndAwait(String message)`: Sends a text message to the client and waits for the message to be sent. It's blocking and should only be called from an executor thread.
- `sendText(String message)`: Sends a text message to the client. It returns a `Uni`. It's non-blocking, but you must subscribe to it.

=== List open connections

It is also possible to list all open connections.
Quarkus provides a CDI bean of type `io.quarkus.websockets.next.OpenConnections` that declares convenient methods to access the connections.

[source, java]
----
import io.quarkus.logging.Log;
import io.quarkus.websockets.next.OpenConnections;

class MyBean {

@Inject
OpenConnections connections;

void logAllOpenConnections() {
Log.infof("Open connections: %s", connections.listAll()); <1>
}
}
----
<1> `OpenConnections#listAll()` returns an immutable snapshot of all open connections at the given time.

There are also other convenient methods.
For example, `OpenConnections#findByEndpointId(String)` makes it easy to find connections for a specific endpoint.

== Serialization and Deserialization

The WebSocket Next extension supports automatic serialization and deserialization of messages.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/websockets-next-tutorial.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ This guide is maintained in the main Quarkus repository
and pull requests should be submitted there:
https://github.com/quarkusio/quarkus/tree/main/docs/src/main/asciidoc
////
= Getting started with WebSockets-Next
= Getting started with WebSockets Next
include::_attributes.adoc[]
:categories: web
:diataxis-type: tutorial
Expand Down