public interface WebSocketSession extends MutableConvertibleValues<Object>, 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<Object> |
getAttributes() |
String |
getId()
The ID of the session.
|
Set<? extends WebSocketSession> |
getOpenSessions()
The current open sessions.
|
String |
getProtocolVersion()
The protocol version of the WebSocket protocol currently being used.
|
default ConvertibleMultiValues<String> |
getRequestParameters()
The request parameters used to create this session.
|
URI |
getRequestURI()
The request URI this session was opened under.
|
default Optional<String> |
getSubprotocol()
The subprotocol if one is used.
|
default ConvertibleValues<Object> |
getUriVariables()
Any matching URI path variables.
|
default Optional<Principal> |
getUserPrincipal()
The user
Principal used to create the session. |
boolean |
isOpen()
Whether the session is open.
|
boolean |
isSecure()
Whether the connection is secure.
|
default <T> Publisher<T> |
send(T message)
Send the given message to the remote peer.
|
<T> Publisher<T> |
send(T message,
MediaType mediaType)
Send the given message to the remote peer.
|
default <T> CompletableFuture<T> |
sendAsync(T message)
Send the given message to the remote peer asynchronously.
|
<T> CompletableFuture<T> |
sendAsync(T message,
MediaType mediaType)
Send the given message to the remote peer asynchronously.
|
default void |
sendSync(Object message)
Send the given message to the remote peer synchronously.
|
default void |
sendSync(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, getValueType, isEmpty, iterator, names, subMap, subMap, subMap, values
get, get, get, get
forEach, spliterator
String getId()
MutableConvertibleValues<Object> getAttributes()
boolean isOpen()
boolean isSecure()
Set<? extends WebSocketSession> getOpenSessions()
URI getRequestURI()
String getProtocolVersion()
<T> Publisher<T> send(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
.Publisher
that either emits an error or emits the message once it has been published successfully.<T> 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
.Publisher
that either emits an error or emits the message once it has been published successfully.default void sendSync(Object message, MediaType mediaType)
message
- The messagemediaType
- The media type of the message. Used to lookup an appropriate codec via the MediaTypeCodecRegistry
.default <T> Publisher<T> send(T message)
T
- The message typemessage
- The messagePublisher
that either emits an error or emits the message once it has been published successfully.default <T> CompletableFuture<T> sendAsync(T message)
T
- The message typemessage
- The messagePublisher
that either emits an error or emits the message once it has been published successfully.default void sendSync(Object message)
message
- The messagedefault Optional<String> getSubprotocol()
default ConvertibleMultiValues<String> getRequestParameters()
default ConvertibleValues<Object> getUriVariables()
default Optional<Principal> getUserPrincipal()
Principal
used to create the session.Principal
void close()
close
in interface AutoCloseable
void close(CloseReason closeReason)
closeReason
- The close event