@Internal public class NettyWebSocketSession extends Object implements WebSocketSession
WebSocketSession interface for Netty.| Modifier and Type | Field and Description |
|---|---|
static io.netty.util.AttributeKey<NettyWebSocketSession> |
WEB_SOCKET_SESSION_KEY
The WebSocket session is stored within a Channel attribute using the given key.
|
EMPTY| Modifier | Constructor and Description |
|---|---|
protected |
NettyWebSocketSession(String id,
io.netty.channel.Channel channel,
HttpRequest<?> request,
MediaTypeCodecRegistry codecRegistry,
String protocolVersion,
boolean isSecure)
Creates a new netty web socket session.
|
| Modifier and Type | Method and Description |
|---|---|
MutableConvertibleValues<Object> |
clear()
Clear all values.
|
void |
close() |
void |
close(CloseReason closeReason)
Close the session with the given event.
|
<T> Optional<T> |
get(CharSequence name,
ArgumentConversionContext<T> conversionContext)
Resolve the given property for the given name.
|
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.
|
ConvertibleMultiValues<String> |
getRequestParameters()
The request parameters used to create this session.
|
URI |
getRequestURI()
The request URI this session was opened under.
|
boolean |
isOpen()
Whether the session is open.
|
boolean |
isSecure()
Whether the connection is secure.
|
boolean |
isWritable()
Whether the session is writable.
|
Set<String> |
names() |
MutableConvertibleValues<Object> |
put(CharSequence key,
Object value)
Insert a value for the given key and value.
|
MutableConvertibleValues<Object> |
remove(CharSequence key)
Remove a value for the given key.
|
<T> reactor.core.publisher.Flux<T> |
send(T message,
MediaType mediaType)
Send the given message to the remote peer.
|
<T> CompletableFuture<T> |
sendAsync(T message,
MediaType mediaType)
Send the given message to the remote peer asynchronously.
|
CompletableFuture<?> |
sendPingAsync(byte[] content)
Send a ping through this WebSocket.
|
void |
sendSync(Object message,
MediaType mediaType)
Send the given message to the remote peer synchronously.
|
String |
toString() |
Collection<Object> |
values() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetSubprotocol, getUriVariables, getUserPrincipal, send, sendAsync, sendSyncof, putAll, putAllasMap, asMap, asProperties, contains, empty, forEach, getValue, getValueType, isEmpty, iterator, subMap, subMap, subMapget, get, getforEach, spliteratorpublic static final io.netty.util.AttributeKey<NettyWebSocketSession> WEB_SOCKET_SESSION_KEY
protected NettyWebSocketSession(String id, io.netty.channel.Channel channel, HttpRequest<?> request, MediaTypeCodecRegistry codecRegistry, String protocolVersion, boolean isSecure)
id - The IDchannel - The channelrequest - The original request used to create the sessioncodecRegistry - The codec registryprotocolVersion - The protocol versionisSecure - Whether the session is securepublic String getId()
WebSocketSessiongetId in interface WebSocketSessionpublic MutableConvertibleValues<Object> getAttributes()
getAttributes in interface WebSocketSessionpublic boolean isOpen()
WebSocketSessionisOpen in interface WebSocketSessionpublic boolean isWritable()
WebSocketSessionisWritable in interface WebSocketSessionpublic boolean isSecure()
WebSocketSessionisSecure in interface WebSocketSessionpublic Set<? extends WebSocketSession> getOpenSessions()
WebSocketSessiongetOpenSessions in interface WebSocketSessionpublic URI getRequestURI()
WebSocketSessiongetRequestURI in interface WebSocketSessionpublic ConvertibleMultiValues<String> getRequestParameters()
WebSocketSessiongetRequestParameters in interface WebSocketSessionpublic String getProtocolVersion()
WebSocketSessiongetProtocolVersion in interface WebSocketSessionpublic <T> CompletableFuture<T> sendAsync(T message, MediaType mediaType)
WebSocketSessionsendAsync in interface WebSocketSessionT - 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.public void sendSync(Object message, MediaType mediaType)
WebSocketSessionsendSync in interface WebSocketSessionmessage - The messagemediaType - The media type of the message. Used to lookup an appropriate codec via the MediaTypeCodecRegistry.public <T> reactor.core.publisher.Flux<T> send(T message,
MediaType mediaType)
WebSocketSessionPublisher 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.send in interface WebSocketSessionT - 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.@NonNull public CompletableFuture<?> sendPingAsync(@NonNull byte[] content)
WebSocketSession@OnMessage method that accepts a
WebSocketPongMessage.sendPingAsync in interface WebSocketSessioncontent - The content of the ping. The remote should return the same content in its
WebSocketPongMessage.public void close()
close in interface WebSocketSessionclose in interface AutoCloseablepublic void close(CloseReason closeReason)
WebSocketSessionclose in interface WebSocketSessioncloseReason - The close eventpublic MutableConvertibleValues<Object> put(CharSequence key, @Nullable Object value)
MutableConvertibleValuesput in interface MutableConvertibleValues<Object>key - The keyvalue - The valuepublic MutableConvertibleValues<Object> remove(CharSequence key)
MutableConvertibleValuesremove in interface MutableConvertibleValues<Object>key - The keypublic MutableConvertibleValues<Object> clear()
MutableConvertibleValuesclear in interface MutableConvertibleValues<Object>public Set<String> names()
names in interface ConvertibleValues<Object>public Collection<Object> values()
values in interface ConvertibleValues<Object>public <T> Optional<T> get(CharSequence name, ArgumentConversionContext<T> conversionContext)
ValueResolverget in interface ValueResolver<CharSequence>T - The concrete typename - The nameconversionContext - The conversion context