public abstract class WebSocketClientHandshaker
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
actualSubprotocol |
protected java.util.Map<java.lang.String,java.lang.String> |
customHeaders |
private java.lang.String |
expectedSubprotocol |
private boolean |
handshakeComplete |
private long |
maxFramePayloadLength |
private WebSocketVersion |
version |
private java.net.URI |
webSocketUrl |
| Modifier | Constructor and Description |
|---|---|
protected |
WebSocketClientHandshaker(java.net.URI webSocketUrl,
WebSocketVersion version,
java.lang.String subprotocol,
java.util.Map<java.lang.String,java.lang.String> customHeaders)
Base constructor with default values
|
protected |
WebSocketClientHandshaker(java.net.URI webSocketUrl,
WebSocketVersion version,
java.lang.String subprotocol,
java.util.Map<java.lang.String,java.lang.String> customHeaders,
long maxFramePayloadLength)
Base constructor
|
| Modifier and Type | Method and Description |
|---|---|
abstract void |
finishHandshake(Channel channel,
HttpResponse response)
Validates and finishes the opening handshake initiated by
handshake(org.jboss.netty.channel.Channel)}. |
java.lang.String |
getActualSubprotocol()
Returns the subprotocol response sent by the server.
|
java.lang.String |
getExpectedSubprotocol()
Returns the CSV of requested subprotocol(s) sent to the server as specified in the constructor
|
long |
getMaxFramePayloadLength()
Returns the max length for any frame's payload
|
WebSocketVersion |
getVersion()
Version of the web socket specification that is being used
|
java.net.URI |
getWebSocketUrl()
Returns the URI to the web socket.
|
abstract ChannelFuture |
handshake(Channel channel)
Begins the opening handshake
|
boolean |
isHandshakeComplete()
Flag to indicate if the opening handshake is complete
|
(package private) static void |
replaceDecoder(Channel channel,
ChannelHandler wsDecoder)
Replace the HTTP decoder with a new Web Socket decoder.
|
protected void |
setActualSubprotocol(java.lang.String actualSubprotocol) |
protected void |
setHandshakeComplete() |
private final java.net.URI webSocketUrl
private final WebSocketVersion version
private volatile boolean handshakeComplete
private final java.lang.String expectedSubprotocol
private volatile java.lang.String actualSubprotocol
protected final java.util.Map<java.lang.String,java.lang.String> customHeaders
private final long maxFramePayloadLength
protected WebSocketClientHandshaker(java.net.URI webSocketUrl,
WebSocketVersion version,
java.lang.String subprotocol,
java.util.Map<java.lang.String,java.lang.String> customHeaders)
webSocketUrl - URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be
sent to this URL.version - Version of web socket specification to use to connect to the serversubprotocol - Sub protocol request sent to the server.customHeaders - Map of custom headers to add to the client requestprotected WebSocketClientHandshaker(java.net.URI webSocketUrl,
WebSocketVersion version,
java.lang.String subprotocol,
java.util.Map<java.lang.String,java.lang.String> customHeaders,
long maxFramePayloadLength)
webSocketUrl - URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be
sent to this URL.version - Version of web socket specification to use to connect to the serversubprotocol - CSV of requested subprotocol(s) sent to the server.customHeaders - Map of custom headers to add to the client requestmaxFramePayloadLength - Maximum length of a frame's payloadpublic java.net.URI getWebSocketUrl()
public WebSocketVersion getVersion()
public long getMaxFramePayloadLength()
public boolean isHandshakeComplete()
protected void setHandshakeComplete()
public java.lang.String getExpectedSubprotocol()
public java.lang.String getActualSubprotocol()
protected void setActualSubprotocol(java.lang.String actualSubprotocol)
public abstract ChannelFuture handshake(Channel channel) throws java.lang.Exception
channel - Channeljava.lang.Exceptionpublic abstract void finishHandshake(Channel channel, HttpResponse response)
handshake(org.jboss.netty.channel.Channel)}.channel - Channelresponse - HTTP response containing the closing handshake detailsstatic void replaceDecoder(Channel channel, ChannelHandler wsDecoder)
ChannelPipeline.replace(String, String, ChannelHandler), because the server
might have sent the first frame immediately after the upgrade response. In such a case, the HTTP decoder might
have the first frame in its cumulation buffer and the HTTP decoder will forward it to the next handler.
The Web Socket decoder will not receive it if we simply replaced it. For more information, refer to
HttpResponseDecoder and its unit tests.