Class NettyWebSocketSession

  • All Implemented Interfaces:
    io.micronaut.core.convert.value.ConvertibleValues<java.lang.Object>, io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object>, io.micronaut.core.value.ValueResolver<java.lang.CharSequence>, io.micronaut.websocket.WebSocketSession, java.lang.AutoCloseable, java.lang.Iterable<java.util.Map.Entry<java.lang.String,​java.lang.Object>>

    @Internal
    public class NettyWebSocketSession
    extends java.lang.Object
    implements io.micronaut.websocket.WebSocketSession
    Implementation of the WebSocketSession interface for Netty.
    Since:
    1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static io.netty.util.AttributeKey<NettyWebSocketSession> WEB_SOCKET_SESSION_KEY
      The WebSocket session is stored within a Channel attribute using the given key.
      • Fields inherited from interface io.micronaut.core.convert.value.ConvertibleValues

        EMPTY
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected NettyWebSocketSession​(java.lang.String id, io.netty.channel.Channel channel, io.micronaut.http.HttpRequest<?> request, io.micronaut.http.codec.MediaTypeCodecRegistry codecRegistry, java.lang.String protocolVersion, boolean isSecure)
      Creates a new netty web socket session.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> clear()  
      void close()  
      void close​(io.micronaut.websocket.CloseReason closeReason)  
      <T> java.util.Optional<T> get​(java.lang.CharSequence name, io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext)  
      io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> getAttributes()  
      java.lang.String getId()  
      java.util.Set<? extends io.micronaut.websocket.WebSocketSession> getOpenSessions()  
      java.lang.String getProtocolVersion()  
      io.micronaut.core.convert.value.ConvertibleMultiValues<java.lang.String> getRequestParameters()  
      java.net.URI getRequestURI()  
      boolean isOpen()  
      boolean isSecure()  
      boolean isWritable()  
      java.util.Set<java.lang.String> names()  
      io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> put​(java.lang.CharSequence key, java.lang.Object value)  
      io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> remove​(java.lang.CharSequence key)  
      <T> reactor.core.publisher.Flux<T> send​(T message, io.micronaut.http.MediaType mediaType)  
      <T> java.util.concurrent.CompletableFuture<T> sendAsync​(T message, io.micronaut.http.MediaType mediaType)  
      java.util.concurrent.CompletableFuture<?> sendPingAsync​(byte[] content)  
      void sendSync​(java.lang.Object message, io.micronaut.http.MediaType mediaType)  
      java.lang.String toString()  
      java.util.Collection<java.lang.Object> values()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface io.micronaut.core.convert.value.ConvertibleValues

        asMap, asMap, asProperties, contains, forEach, getValue, getValueType, isEmpty, iterator, subMap, subMap, subMap
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
      • Methods inherited from interface io.micronaut.core.convert.value.MutableConvertibleValues

        putAll, putAll
      • Methods inherited from interface io.micronaut.core.value.ValueResolver

        get, get, get
      • Methods inherited from interface io.micronaut.websocket.WebSocketSession

        getSubprotocol, getUriVariables, getUserPrincipal, send, sendAsync, sendSync
    • Field Detail

      • WEB_SOCKET_SESSION_KEY

        public static final io.netty.util.AttributeKey<NettyWebSocketSession> WEB_SOCKET_SESSION_KEY
        The WebSocket session is stored within a Channel attribute using the given key.
    • Constructor Detail

      • NettyWebSocketSession

        protected NettyWebSocketSession​(java.lang.String id,
                                        io.netty.channel.Channel channel,
                                        io.micronaut.http.HttpRequest<?> request,
                                        io.micronaut.http.codec.MediaTypeCodecRegistry codecRegistry,
                                        java.lang.String protocolVersion,
                                        boolean isSecure)
        Creates a new netty web socket session.
        Parameters:
        id - The ID
        channel - The channel
        request - The original request used to create the session
        codecRegistry - The codec registry
        protocolVersion - The protocol version
        isSecure - Whether the session is secure
    • Method Detail

      • getId

        public java.lang.String getId()
        Specified by:
        getId in interface io.micronaut.websocket.WebSocketSession
      • getAttributes

        public io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> getAttributes()
        Specified by:
        getAttributes in interface io.micronaut.websocket.WebSocketSession
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface io.micronaut.websocket.WebSocketSession
      • isWritable

        public boolean isWritable()
        Specified by:
        isWritable in interface io.micronaut.websocket.WebSocketSession
      • isSecure

        public boolean isSecure()
        Specified by:
        isSecure in interface io.micronaut.websocket.WebSocketSession
      • getOpenSessions

        public java.util.Set<? extends io.micronaut.websocket.WebSocketSession> getOpenSessions()
        Specified by:
        getOpenSessions in interface io.micronaut.websocket.WebSocketSession
      • getRequestURI

        public java.net.URI getRequestURI()
        Specified by:
        getRequestURI in interface io.micronaut.websocket.WebSocketSession
      • getRequestParameters

        public io.micronaut.core.convert.value.ConvertibleMultiValues<java.lang.String> getRequestParameters()
        Specified by:
        getRequestParameters in interface io.micronaut.websocket.WebSocketSession
      • getProtocolVersion

        public java.lang.String getProtocolVersion()
        Specified by:
        getProtocolVersion in interface io.micronaut.websocket.WebSocketSession
      • sendAsync

        public <T> java.util.concurrent.CompletableFuture<T> sendAsync​(T message,
                                                                       io.micronaut.http.MediaType mediaType)
        Specified by:
        sendAsync in interface io.micronaut.websocket.WebSocketSession
      • sendSync

        public void sendSync​(java.lang.Object message,
                             io.micronaut.http.MediaType mediaType)
        Specified by:
        sendSync in interface io.micronaut.websocket.WebSocketSession
      • send

        public <T> reactor.core.publisher.Flux<T> send​(T message,
                                                       io.micronaut.http.MediaType mediaType)
        Specified by:
        send in interface io.micronaut.websocket.WebSocketSession
      • sendPingAsync

        @NonNull
        public java.util.concurrent.CompletableFuture<?> sendPingAsync​(@NonNull
                                                                       byte[] content)
        Specified by:
        sendPingAsync in interface io.micronaut.websocket.WebSocketSession
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface io.micronaut.websocket.WebSocketSession
      • close

        public void close​(io.micronaut.websocket.CloseReason closeReason)
        Specified by:
        close in interface io.micronaut.websocket.WebSocketSession
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • put

        public io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> put​(java.lang.CharSequence key,
                                                                                              @Nullable
                                                                                              java.lang.Object value)
        Specified by:
        put in interface io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object>
      • remove

        public io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> remove​(java.lang.CharSequence key)
        Specified by:
        remove in interface io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object>
      • clear

        public io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> clear()
        Specified by:
        clear in interface io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object>
      • names

        public java.util.Set<java.lang.String> names()
        Specified by:
        names in interface io.micronaut.core.convert.value.ConvertibleValues<java.lang.Object>
      • values

        public java.util.Collection<java.lang.Object> values()
        Specified by:
        values in interface io.micronaut.core.convert.value.ConvertibleValues<java.lang.Object>
      • get

        public <T> java.util.Optional<T> get​(java.lang.CharSequence name,
                                             io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext)
        Specified by:
        get in interface io.micronaut.core.value.ValueResolver<java.lang.CharSequence>