Package io.quarkus.websockets.next
Interface WebSocketConnection
- All Superinterfaces:
BlockingSender,Sender
- All Known Implementing Classes:
WebSocketConnectionImpl
@Experimental("This API is experimental and may change in the future")
public interface WebSocketConnection
extends Sender, BlockingSender
This interface represents a connection from a client to a specific
WebSocket endpoint on the server.
Quarkus provides a built-in CDI bean that implements this interface and can be injected in a WebSocket
endpoint and used to interact with the connected client, or all clients connected to the endpoint respectively
(broadcasting).
Specifically, it is possible to send messages using blocking and non-blocking methods, declared on
BlockingSender and Sender respectively.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceMakes it possible to send messages to all clients connected to the same WebSocket endpoint. -
Method Summary
Modifier and TypeMethodDescriptionSends messages to all open clients connected to the same WebSocket endpoint.default io.smallrye.mutiny.Uni<Void>close()Close the connection.io.smallrye.mutiny.Uni<Void>close(CloseReason reason) Close the connection with a specific reason.default voidClose the connection and wait for the completion.default voidcloseAndAwait(CloseReason reason) Close the connection and wait for the completion.The returned set also includes the connection this method is called upon.id()booleanisClosed()default booleanisOpen()booleanisSecure()Methods inherited from interface io.quarkus.websockets.next.BlockingSender
sendBinaryAndAwait, sendBinaryAndAwait, sendPingAndAwait, sendPongAndAwait, sendTextAndAwait, sendTextAndAwaitMethods inherited from interface io.quarkus.websockets.next.Sender
sendBinary, sendBinary, sendPing, sendPong, sendText, sendText
-
Method Details
-
id
String id()- Returns:
- the unique identifier assigned to this connection
-
endpointId
String endpointId()- Returns:
- the endpoint id
- See Also:
-
pathParam
- Parameters:
name-- Returns:
- the decoded value of the path parameter or
null - See Also:
-
broadcast
WebSocketConnection.BroadcastSender broadcast()Sends messages to all open clients connected to the same WebSocket endpoint.- Returns:
- the broadcast sender
- See Also:
-
getOpenConnections
Set<WebSocketConnection> getOpenConnections()The returned set also includes the connection this method is called upon.- Returns:
- the set of open connections to the same endpoint
-
isSecure
boolean isSecure()- Returns:
trueif the HTTP connection is encrypted via SSL/TLS
-
isClosed
boolean isClosed()- Returns:
trueif the WebSocket is closed
-
closeReason
CloseReason closeReason()- Returns:
- the close reason or
nullif the connection is not closed
-
isOpen
default boolean isOpen()- Returns:
trueif the WebSocket is open
-
close
Close the connection.- Returns:
- a new
Uniwith anullitem
-
close
Close the connection with a specific reason.- Parameters:
reason-- Returns:
- a new
Uniwith anullitem
-
closeAndAwait
default void closeAndAwait()Close the connection and wait for the completion. -
closeAndAwait
Close the connection and wait for the completion. -
handshakeRequest
HandshakeRequest handshakeRequest()- Returns:
- the handshake request
-
subprotocol
String subprotocol()- Returns:
- the subprotocol selected by the handshake
-
creationTime
Instant creationTime()- Returns:
- the time when this connection was created
-