@Internal public class NettyRxWebSocketSession extends 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(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 RxWebSocketSession> |
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.
|
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> io.reactivex.Flowable<T> |
send(T message,
MediaType mediaType)
Broadcast a message and return a
Flowable . |
<T> CompletableFuture<T> |
sendAsync(T message,
MediaType mediaType)
Send the given message to the remote peer asynchronously.
|
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, wait
getSubprotocol, getUriVariables, getUserPrincipal, send, sendAsync, sendSync
of, putAll, putAll
asMap, asMap, asProperties, contains, empty, forEach, getValueType, isEmpty, iterator, subMap, subMap, subMap
get, get, get
forEach, spliterator
public static final io.netty.util.AttributeKey<NettyRxWebSocketSession> WEB_SOCKET_SESSION_KEY
protected NettyRxWebSocketSession(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()
WebSocketSession
getId
in interface WebSocketSession
public MutableConvertibleValues<Object> getAttributes()
getAttributes
in interface WebSocketSession
public boolean isOpen()
WebSocketSession
isOpen
in interface WebSocketSession
public boolean isSecure()
WebSocketSession
isSecure
in interface WebSocketSession
public Set<? extends RxWebSocketSession> getOpenSessions()
RxWebSocketSession
getOpenSessions
in interface RxWebSocketSession
getOpenSessions
in interface WebSocketSession
WebSocketSession.getOpenSessions()
public URI getRequestURI()
WebSocketSession
getRequestURI
in interface WebSocketSession
public ConvertibleMultiValues<String> getRequestParameters()
WebSocketSession
getRequestParameters
in interface WebSocketSession
public String getProtocolVersion()
WebSocketSession
getProtocolVersion
in interface WebSocketSession
public <T> 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
.Publisher
that either emits an error or emits the message once it has been published successfully.public void sendSync(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 AutoCloseable
public void close(CloseReason closeReason)
WebSocketSession
close
in interface WebSocketSession
closeReason
- The close eventpublic MutableConvertibleValues<Object> put(CharSequence key, @Nullable Object value)
MutableConvertibleValues
put
in interface MutableConvertibleValues<Object>
key
- The keyvalue
- The valuepublic MutableConvertibleValues<Object> remove(CharSequence key)
MutableConvertibleValues
remove
in interface MutableConvertibleValues<Object>
key
- The keypublic MutableConvertibleValues<Object> clear()
MutableConvertibleValues
clear
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)
ValueResolver
get
in interface ValueResolver<CharSequence>
T
- The concrete typename
- The nameconversionContext
- The conversion context