类 AbstractHandshakeHandler

    • 字段详细资料

    • 方法详细资料

      • setSupportedProtocols

        public void setSupportedProtocols​(String... protocols)
        Use this property to configure the list of supported sub-protocols. The first configured sub-protocol that matches a client-requested sub-protocol is accepted. If there are no matches the response will not contain a Sec-WebSocket-Protocol header.

        Note that if the WebSocketHandler passed in at runtime is an instance of SubProtocolCapable then there is not need to explicitly configure this property. That is certainly the case with the built-in STOMP over WebSocket support. Therefore this property should be configured explicitly only if the WebSocketHandler does not implement SubProtocolCapable.

      • start

        public void start()
        从接口复制的说明: Lifecycle
        Start this component.

        Should not throw an exception if the component is already running.

        In the case of a container, this will propagate the start signal to all components that apply.

        指定者:
        start 在接口中 Lifecycle
        另请参阅:
        SmartLifecycle.isAutoStartup()
      • stop

        public void stop()
        从接口复制的说明: Lifecycle
        Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method. Consider implementing SmartLifecycle and its stop(Runnable) variant when asynchronous stop behavior is necessary.

        Note that this stop notification is not guaranteed to come before destruction: On regular shutdown, Lifecycle beans will first receive a stop notification before the general destruction callbacks are being propagated; however, on hot refresh during a context's lifetime or on aborted refresh attempts, a given bean's destroy method will be called without any consideration of stop signals upfront.

        Should not throw an exception if the component is not running (not started yet).

        In the case of a container, this will propagate the stop signal to all components that apply.

        指定者:
        stop 在接口中 Lifecycle
        另请参阅:
        SmartLifecycle.stop(Runnable), DisposableBean.destroy()
      • doStop

        protected void doStop()
      • isRunning

        public boolean isRunning()
        从接口复制的说明: Lifecycle
        Check whether this component is currently running.

        In the case of a container, this will return true only if all components that apply are currently running.

        指定者:
        isRunning 在接口中 Lifecycle
        返回:
        whether the component is currently running
      • doHandshake

        public final boolean doHandshake​(ServerHttpRequest request,
                                         ServerHttpResponse response,
                                         WebSocketHandler wsHandler,
                                         Map<String,​Object> attributes)
                                  throws HandshakeFailureException
        从接口复制的说明: HandshakeHandler
        Initiate the handshake.
        指定者:
        doHandshake 在接口中 HandshakeHandler
        参数:
        request - the current request
        response - the current response
        wsHandler - the handler to process WebSocket messages; see PerConnectionWebSocketHandler for providing a handler with per-connection lifecycle.
        attributes - attributes from the HTTP handshake to associate with the WebSocket session; the provided attributes are copied, the original map is not used.
        返回:
        whether the handshake negotiation was successful or not. In either case the response status, headers, and body will have been updated to reflect the result of the negotiation
        抛出:
        HandshakeFailureException - thrown when handshake processing failed to complete due to an internal, unrecoverable error, i.e. a server error as opposed to a failure to successfully negotiate the handshake.
      • filterRequestedExtensions

        protected List<WebSocketExtensionfilterRequestedExtensions​(ServerHttpRequest request,
                                                                     List<WebSocketExtension> requestedExtensions,
                                                                     List<WebSocketExtension> supportedExtensions)
        Filter the list of requested WebSocket extensions.

        As of 4.1, the default implementation of this method filters the list to leave only extensions that are both requested and supported.

        参数:
        request - the current request
        requestedExtensions - the list of extensions requested by the client
        supportedExtensions - the list of extensions supported by the server
        返回:
        the selected extensions or an empty list
      • determineUser

        protected Principal determineUser​(ServerHttpRequest request,
                                          WebSocketHandler wsHandler,
                                          Map<String,​Object> attributes)
        A method that can be used to associate a user with the WebSocket session in the process of being established. The default implementation calls ServerHttpRequest.getPrincipal()

        Subclasses can provide custom logic for associating a user with a session, for example for assigning a name to anonymous users (i.e. not fully authenticated).

        参数:
        request - the handshake request
        wsHandler - the WebSocket handler that will handle messages
        attributes - handshake attributes to pass to the WebSocket session
        返回:
        the user for the WebSocket session, or null if not available