Home / Class/ WebSocketServerProtocolHandler Class — netty Architecture

WebSocketServerProtocolHandler Class — netty Architecture

Architecture documentation for the WebSocketServerProtocolHandler class in WebSocketServerProtocolHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  24d9f96e_3f70_9b0f_3941_7e5455fcbe3b["WebSocketServerProtocolHandler"]
  8c1d603a_aa1f_712c_b960_89f0dc9c25ca["WebSocketServerProtocolHandler.java"]
  24d9f96e_3f70_9b0f_3941_7e5455fcbe3b -->|defined in| 8c1d603a_aa1f_712c_b960_89f0dc9c25ca
  4281dc88_6033_4b15_89d2_7373e9715476["WebSocketServerProtocolHandler()"]
  24d9f96e_3f70_9b0f_3941_7e5455fcbe3b -->|method| 4281dc88_6033_4b15_89d2_7373e9715476
  15bda771_3a9c_e6aa_7fcd_ea586cfd059b["handlerAdded()"]
  24d9f96e_3f70_9b0f_3941_7e5455fcbe3b -->|method| 15bda771_3a9c_e6aa_7fcd_ea586cfd059b
  ca63dc9d_3136_91f5_fca2_402a15bd197d["decode()"]
  24d9f96e_3f70_9b0f_3941_7e5455fcbe3b -->|method| ca63dc9d_3136_91f5_fca2_402a15bd197d
  a0b04edc_fb7d_9c95_ed34_08c7c9bc4e56["WebSocketServerHandshakeException()"]
  24d9f96e_3f70_9b0f_3941_7e5455fcbe3b -->|method| a0b04edc_fb7d_9c95_ed34_08c7c9bc4e56
  3d292f19_062f_1a78_4428_b018cc17faae["exceptionCaught()"]
  24d9f96e_3f70_9b0f_3941_7e5455fcbe3b -->|method| 3d292f19_062f_1a78_4428_b018cc17faae
  38d8bd5a_be00_3cd0_2bbc_83446139d42c["WebSocketServerHandshaker()"]
  24d9f96e_3f70_9b0f_3941_7e5455fcbe3b -->|method| 38d8bd5a_be00_3cd0_2bbc_83446139d42c
  4c487689_3983_51f3_23a3_0cba84b79fd7["setHandshaker()"]
  24d9f96e_3f70_9b0f_3941_7e5455fcbe3b -->|method| 4c487689_3983_51f3_23a3_0cba84b79fd7

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java lines 54–276

public class WebSocketServerProtocolHandler extends WebSocketProtocolHandler {

    /**
     * Events that are fired to notify about handshake status
     */
    public enum ServerHandshakeStateEvent {
        /**
         * The Handshake was completed successfully and the channel was upgraded to websockets.
         *
         * @deprecated in favor of {@link HandshakeComplete} class,
         * it provides extra information about the handshake
         */
        @Deprecated
        HANDSHAKE_COMPLETE,

        /**
         * The Handshake was timed out
         */
        HANDSHAKE_TIMEOUT
    }

    /**
     * The Handshake was completed successfully and the channel was upgraded to websockets.
     */
    public static final class HandshakeComplete {
        private final String requestUri;
        private final HttpHeaders requestHeaders;
        private final String selectedSubprotocol;

        public HandshakeComplete(String requestUri, HttpHeaders requestHeaders, String selectedSubprotocol) {
            this.requestUri = requestUri;
            this.requestHeaders = requestHeaders;
            this.selectedSubprotocol = selectedSubprotocol;
        }

        public String requestUri() {
            return requestUri;
        }

        public HttpHeaders requestHeaders() {
            return requestHeaders;
        }

        public String selectedSubprotocol() {
            return selectedSubprotocol;
        }
    }

    private static final AttributeKey<WebSocketServerHandshaker> HANDSHAKER_ATTR_KEY =
            AttributeKey.valueOf(WebSocketServerHandshaker.class, "HANDSHAKER");

    private final WebSocketServerProtocolConfig serverConfig;

    /**
     * Base constructor
     *
     * @param serverConfig
     *            Server protocol configuration.
     */
    public WebSocketServerProtocolHandler(WebSocketServerProtocolConfig serverConfig) {
        super(checkNotNull(serverConfig, "serverConfig").dropPongFrames(),
              serverConfig.sendCloseFrame(),
              serverConfig.forceCloseTimeoutMillis()
        );
        this.serverConfig = serverConfig;
    }

    public WebSocketServerProtocolHandler(String websocketPath) {
        this(websocketPath, DEFAULT_HANDSHAKE_TIMEOUT_MILLIS);
    }

    public WebSocketServerProtocolHandler(String websocketPath, long handshakeTimeoutMillis) {
        this(websocketPath, false, handshakeTimeoutMillis);
    }

    public WebSocketServerProtocolHandler(String websocketPath, boolean checkStartsWith) {
        this(websocketPath, checkStartsWith, DEFAULT_HANDSHAKE_TIMEOUT_MILLIS);
    }

    public WebSocketServerProtocolHandler(String websocketPath, boolean checkStartsWith, long handshakeTimeoutMillis) {
        this(websocketPath, null, false, 65536, false, checkStartsWith, handshakeTimeoutMillis);

Frequently Asked Questions

What is the WebSocketServerProtocolHandler class?
WebSocketServerProtocolHandler is a class in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java.
Where is WebSocketServerProtocolHandler defined?
WebSocketServerProtocolHandler is defined in codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandler.java at line 54.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free