public interface WebSocketSession extends MutableConvertibleValues<java.lang.Object>, java.lang.AutoCloseable
javax.websocket
and likely to be able to implement the spec in the future.EMPTY
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
close(CloseReason closeReason)
Close the session with the given event.
|
MutableConvertibleValues<java.lang.Object> |
getAttributes() |
java.lang.String |
getId()
The ID of the session.
|
java.util.Set<? extends WebSocketSession> |
getOpenSessions()
The current open sessions.
|
java.lang.String |
getProtocolVersion()
The protocol version of the WebSocket protocol currently being used.
|
default ConvertibleMultiValues<java.lang.String> |
getRequestParameters()
The request parameters used to create this session.
|
java.net.URI |
getRequestURI()
The request URI this session was opened under.
|
default java.util.Optional<java.lang.String> |
getSubprotocol()
The subprotocol if one is used.
|
default ConvertibleValues<java.lang.Object> |
getUriVariables()
Any matching URI path variables.
|
default java.util.Optional<java.security.Principal> |
getUserPrincipal()
The user
Principal used to create the session. |
boolean |
isOpen()
Whether the session is open.
|
boolean |
isSecure()
Whether the connection is secure.
|
boolean |
isWritable()
Whether the session is writable.
|
default <T> org.reactivestreams.Publisher<T> |
send(T message)
Send the given message to the remote peer.
|
<T> org.reactivestreams.Publisher<T> |
send(T message,
MediaType mediaType)
Send the given message to the remote peer.
|
default <T> java.util.concurrent.CompletableFuture<T> |
sendAsync(T message)
Send the given message to the remote peer asynchronously.
|
<T> java.util.concurrent.CompletableFuture<T> |
sendAsync(T message,
MediaType mediaType)
Send the given message to the remote peer asynchronously.
|
default void |
sendSync(java.lang.Object message)
Send the given message to the remote peer synchronously.
|
default void |
sendSync(java.lang.Object message,
MediaType mediaType)
Send the given message to the remote peer synchronously.
|
clear, of, put, putAll, putAll, remove
asMap, asMap, asProperties, contains, empty, forEach, getValue, getValueType, isEmpty, iterator, names, subMap, subMap, subMap, values
get, get, get, get
java.lang.String getId()
MutableConvertibleValues<java.lang.Object> getAttributes()
boolean isOpen()
boolean isWritable()
boolean isSecure()
java.util.Set<? extends WebSocketSession> getOpenSessions()
java.net.URI getRequestURI()
java.lang.String getProtocolVersion()
<T> org.reactivestreams.Publisher<T> send(T message, MediaType mediaType)
Publisher
does not start sending until subscribed to.
If you return it from Micronaut annotated methods such as OnOpen
and OnMessage
,
Micronaut will subscribe to it and send the message without blocking.T
- The message typemessage
- The messagemediaType
- The media type of the message. Used to lookup an appropriate codec via the MediaTypeCodecRegistry
.Publisher
that either emits an error or emits the message once it has been published successfully.<T> java.util.concurrent.CompletableFuture<T> sendAsync(T message, MediaType mediaType)
T
- The message typemessage
- The messagemediaType
- The media type of the message. Used to lookup an appropriate codec via the MediaTypeCodecRegistry
.CompletableFuture
that tracks the execution. CompletableFuture.get()
and related methods will return the message on success, on error throw the underlying Exception.default void sendSync(java.lang.Object message, MediaType mediaType)
message
- The messagemediaType
- The media type of the message. Used to lookup an appropriate codec via the MediaTypeCodecRegistry
.default <T> org.reactivestreams.Publisher<T> send(T message)
Publisher
does not start sending until subscribed to.
If you return it from Micronaut annotated methods such as OnOpen
and OnMessage
,
Micronaut will subscribe to it and send the message without blocking.T
- The message typemessage
- The messagePublisher
that either emits an error or emits the message once it has been published successfully.default <T> java.util.concurrent.CompletableFuture<T> sendAsync(T message)
T
- The message typemessage
- The messageCompletableFuture
that tracks the execution. CompletableFuture.get()
and related methods will return the message on success, on error throw the underlying Exception.default void sendSync(java.lang.Object message)
message
- The messagedefault java.util.Optional<java.lang.String> getSubprotocol()
default ConvertibleMultiValues<java.lang.String> getRequestParameters()
default ConvertibleValues<java.lang.Object> getUriVariables()
default java.util.Optional<java.security.Principal> getUserPrincipal()
Principal
used to create the session.Principal
void close()
close
in interface java.lang.AutoCloseable
void close(CloseReason closeReason)
closeReason
- The close event