Class Handshake
java.lang.Object
io.undertow.websockets.core.protocol.Handshake
- Direct Known Subclasses:
Hybi07Handshake
Abstract base class for doing a WebSocket Handshake.
- Author:
- Mike Brock
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addExtension
(ExtensionHandshake extension) Add a new WebSocket Extension handshake to the list of available extensions.abstract WebSocketChannel
createChannel
(WebSocketHttpExchange exchange, org.xnio.StreamConnection channel, ByteBufferPool pool) Create theWebSocketChannel
from theWebSocketHttpExchange
Return the algorithm that is used to hash during the handshakeReturn the magic number which will be mixed inReturn the version for which theHandshake
can be used.protected static String
getWebSocketLocation
(WebSocketHttpExchange exchange) Return the full url of the websocket location of the givenWebSocketHttpExchange
final void
handshake
(WebSocketHttpExchange exchange) Issue the WebSocket upgradeprotected abstract void
handshakeInternal
(WebSocketHttpExchange exchange) protected final List<ExtensionFunction>
initExtensions
(WebSocketHttpExchange exchange) Create theExtensionFunction
list associated with the negotiated extensions defined in the exchange's response.abstract boolean
matches
(WebSocketHttpExchange exchange) Returntrue
if this implementation can be used to issue a handshake.protected final void
performUpgrade
(WebSocketHttpExchange exchange) Perform the upgrade using no payloadprotected final void
performUpgrade
(WebSocketHttpExchange exchange, byte[] data) convenience method to perform the upgradeprotected List<WebSocketExtension>
selectedExtension
(List<WebSocketExtension> extensionList) protected final void
selectExtensions
(WebSocketHttpExchange exchange) protected final void
selectSubprotocol
(WebSocketHttpExchange exchange) Selects the first matching supported sub protocol and add it the the headers of the exchange.protected String
supportedSubprotols
(String[] requestedSubprotocolArray) protected void
upgradeChannel
(WebSocketHttpExchange exchange, byte[] data)
-
Field Details
-
subprotocols
-
availableExtensions
-
allowExtensions
protected boolean allowExtensions
-
-
Constructor Details
-
Handshake
protected Handshake(WebSocketVersion version, String hashAlgorithm, String magicNumber, Set<String> subprotocols)
-
-
Method Details
-
getVersion
Return the version for which theHandshake
can be used. -
getHashAlgorithm
Return the algorithm that is used to hash during the handshake -
getMagicNumber
Return the magic number which will be mixed in -
getWebSocketLocation
Return the full url of the websocket location of the givenWebSocketHttpExchange
-
handshake
Issue the WebSocket upgrade- Parameters:
exchange
- TheWebSocketHttpExchange
for which the handshake and upgrade should occur.
-
handshakeInternal
-
matches
Returntrue
if this implementation can be used to issue a handshake. -
createChannel
public abstract WebSocketChannel createChannel(WebSocketHttpExchange exchange, org.xnio.StreamConnection channel, ByteBufferPool pool) Create theWebSocketChannel
from theWebSocketHttpExchange
-
performUpgrade
convenience method to perform the upgrade -
upgradeChannel
-
performUpgrade
Perform the upgrade using no payload -
selectSubprotocol
Selects the first matching supported sub protocol and add it the the headers of the exchange. -
selectExtensions
-
supportedSubprotols
-
selectedExtension
-
addExtension
Add a new WebSocket Extension handshake to the list of available extensions.- Parameters:
extension
- a newExtensionHandshake
-
initExtensions
Create theExtensionFunction
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
-