@Internal public class NettyRxWebSocketSession extends java.lang.Object implements RxWebSocketSession
RxWebSocketSession
interface for Netty and RxJava.Modifier and Type | Field and Description |
---|---|
static io.netty.util.AttributeKey<NettyRxWebSocketSession> |
WEB_SOCKET_SESSION_KEY
The WebSocket session is stored within a Channel attribute using the given key.
|
EMPTY
Modifier | Constructor and Description |
---|---|
protected |
NettyRxWebSocketSession(java.lang.String id,
io.netty.channel.Channel channel,
HttpRequest<?> request,
MediaTypeCodecRegistry codecRegistry,
java.lang.String protocolVersion,
boolean isSecure)
Creates a new netty web socket session.
|
Modifier and Type | Method and Description |
---|---|
MutableConvertibleValues<java.lang.Object> |
clear()
Clear all values.
|
void |
close() |
void |
close(CloseReason closeReason)
Close the session with the given event.
|
<T> java.util.Optional<T> |
get(java.lang.CharSequence name,
ArgumentConversionContext<T> conversionContext)
Resolve the given property for the given name.
|
MutableConvertibleValues<java.lang.Object> |
getAttributes() |
java.lang.String |
getId()
The ID of the session.
|
java.util.Set<? extends RxWebSocketSession> |
getOpenSessions()
The current open sessions.
|
java.lang.String |
getProtocolVersion()
The protocol version of the WebSocket protocol currently being used.
|
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.
|
boolean |
isOpen()
Whether the session is open.
|
boolean |
isSecure()
Whether the connection is secure.
|
boolean |
isWritable()
Whether the session is writable.
|
java.util.Set<java.lang.String> |
names() |
MutableConvertibleValues<java.lang.Object> |
put(java.lang.CharSequence key,
java.lang.Object value)
Insert a value for the given key and value.
|
MutableConvertibleValues<java.lang.Object> |
remove(java.lang.CharSequence key)
Remove a value for the given key.
|
<T> io.reactivex.Flowable<T> |
send(T message,
MediaType mediaType)
Broadcast a message and return a
Flowable . |
<T> java.util.concurrent.CompletableFuture<T> |
sendAsync(T message,
MediaType mediaType)
Send the given message to the remote peer asynchronously.
|
void |
sendSync(java.lang.Object message,
MediaType mediaType)
Send the given message to the remote peer synchronously.
|
java.lang.String |
toString() |
java.util.Collection<java.lang.Object> |
values() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getSubprotocol, getUriVariables, getUserPrincipal, send, sendAsync, sendSync
of, putAll, putAll
asMap, asMap, asProperties, contains, empty, forEach, getValue, getValueType, isEmpty, iterator, subMap, subMap, subMap
get, get, get
public static final io.netty.util.AttributeKey<NettyRxWebSocketSession> WEB_SOCKET_SESSION_KEY
protected NettyRxWebSocketSession(java.lang.String id, io.netty.channel.Channel channel, HttpRequest<?> request, MediaTypeCodecRegistry codecRegistry, java.lang.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 java.lang.String getId()
WebSocketSession
getId
in interface WebSocketSession
public MutableConvertibleValues<java.lang.Object> getAttributes()
getAttributes
in interface WebSocketSession
public boolean isOpen()
WebSocketSession
isOpen
in interface WebSocketSession
public boolean isWritable()
WebSocketSession
isWritable
in interface WebSocketSession
public boolean isSecure()
WebSocketSession
isSecure
in interface WebSocketSession
public java.util.Set<? extends RxWebSocketSession> getOpenSessions()
RxWebSocketSession
getOpenSessions
in interface RxWebSocketSession
getOpenSessions
in interface WebSocketSession
WebSocketSession.getOpenSessions()
public java.net.URI getRequestURI()
WebSocketSession
getRequestURI
in interface WebSocketSession
public ConvertibleMultiValues<java.lang.String> getRequestParameters()
WebSocketSession
getRequestParameters
in interface WebSocketSession
public java.lang.String getProtocolVersion()
WebSocketSession
getProtocolVersion
in interface WebSocketSession
public <T> java.util.concurrent.CompletableFuture<T> sendAsync(T message, MediaType mediaType)
WebSocketSession
sendAsync
in interface WebSocketSession
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.public void sendSync(java.lang.Object message, MediaType mediaType)
WebSocketSession
sendSync
in interface WebSocketSession
message
- The messagemediaType
- The media type of the message. Used to lookup an appropriate codec via the MediaTypeCodecRegistry
.public <T> io.reactivex.Flowable<T> send(T message, MediaType mediaType)
RxWebSocketSession
Flowable
.send
in interface RxWebSocketSession
send
in interface WebSocketSession
T
- The message generic typemessage
- The messagemediaType
- The media typeFlowable
public void close()
close
in interface WebSocketSession
close
in interface java.lang.AutoCloseable
public void close(CloseReason closeReason)
WebSocketSession
close
in interface WebSocketSession
closeReason
- The close eventpublic java.lang.String toString()
toString
in class java.lang.Object
public MutableConvertibleValues<java.lang.Object> put(java.lang.CharSequence key, @Nullable java.lang.Object value)
MutableConvertibleValues
put
in interface MutableConvertibleValues<java.lang.Object>
key
- The keyvalue
- The valuepublic MutableConvertibleValues<java.lang.Object> remove(java.lang.CharSequence key)
MutableConvertibleValues
remove
in interface MutableConvertibleValues<java.lang.Object>
key
- The keypublic MutableConvertibleValues<java.lang.Object> clear()
MutableConvertibleValues
clear
in interface MutableConvertibleValues<java.lang.Object>
public java.util.Set<java.lang.String> names()
names
in interface ConvertibleValues<java.lang.Object>
public java.util.Collection<java.lang.Object> values()
values
in interface ConvertibleValues<java.lang.Object>
public <T> java.util.Optional<T> get(java.lang.CharSequence name, ArgumentConversionContext<T> conversionContext)
ValueResolver
get
in interface ValueResolver<java.lang.CharSequence>
T
- The concrete typename
- The nameconversionContext
- The conversion context