Class Handshake

  • Direct Known Subclasses:
    Hybi07Handshake

    public abstract class Handshake
    extends java.lang.Object
    Abstract base class for doing a WebSocket Handshake.
    Author:
    Mike Brock
    • Field Detail

      • subprotocols

        protected final java.util.Set<java.lang.String> subprotocols
      • allowExtensions

        protected boolean allowExtensions
    • Constructor Detail

      • Handshake

        protected Handshake​(WebSocketVersion version,
                            java.lang.String hashAlgorithm,
                            java.lang.String magicNumber,
                            java.util.Set<java.lang.String> subprotocols)
    • Method Detail

      • getHashAlgorithm

        public java.lang.String getHashAlgorithm()
        Return the algorithm that is used to hash during the handshake
      • getMagicNumber

        public java.lang.String getMagicNumber()
        Return the magic number which will be mixed in
      • matches

        public abstract boolean matches​(WebSocketHttpExchange exchange)
        Return true if this implementation can be used to issue a handshake.
      • performUpgrade

        protected final void performUpgrade​(WebSocketHttpExchange exchange,
                                            byte[] data)
        convenience method to perform the upgrade
      • performUpgrade

        protected final void performUpgrade​(WebSocketHttpExchange exchange)
        Perform the upgrade using no payload
      • selectSubprotocol

        protected final void selectSubprotocol​(WebSocketHttpExchange exchange)
        Selects the first matching supported sub protocol and add it the the headers of the exchange.
      • supportedSubprotols

        protected java.lang.String supportedSubprotols​(java.lang.String[] requestedSubprotocolArray)
      • addExtension

        public final void addExtension​(ExtensionHandshake extension)
        Add a new WebSocket Extension handshake to the list of available extensions.
        Parameters:
        extension - a new ExtensionHandshake
      • initExtensions

        protected final java.util.List<ExtensionFunction> initExtensions​(WebSocketHttpExchange exchange)
        Create the ExtensionFunction list associated with the negotiated extensions defined in the exchange's response.
        Parameters:
        exchange - the exchange used to retrieve negotiated extensions
        Returns:
        a list of ExtensionFunction with the implementation of the extensions