public abstract class WebSocketClientHandshaker
extends java.lang.Object
限定符和类型 | 字段和说明 |
---|---|
protected HttpHeaders |
customHeaders |
限定符 | 构造器和说明 |
---|---|
protected |
WebSocketClientHandshaker(java.net.URI uri,
WebSocketVersion version,
java.lang.String subprotocol,
HttpHeaders customHeaders,
int maxFramePayloadLength)
Base constructor
|
限定符和类型 | 方法和说明 |
---|---|
java.lang.String |
actualSubprotocol()
Returns the subprotocol response sent by the server.
|
ChannelFuture |
close(Channel channel,
CloseWebSocketFrame frame)
Performs the closing handshake
|
ChannelFuture |
close(Channel channel,
CloseWebSocketFrame frame,
ChannelPromise promise)
Performs the closing handshake
|
java.lang.String |
expectedSubprotocol()
Returns the CSV of requested subprotocol(s) sent to the server as specified in the constructor
|
void |
finishHandshake(Channel channel,
FullHttpResponse response)
Validates and finishes the opening handshake initiated by
handshake(io.netty.channel.Channel) }. |
ChannelFuture |
handshake(Channel channel)
Begins the opening handshake
|
ChannelFuture |
handshake(Channel channel,
ChannelPromise promise)
Begins the opening handshake
|
boolean |
isHandshakeComplete()
Flag to indicate if the opening handshake is complete
|
int |
maxFramePayloadLength()
Returns the max length for any frame's payload
|
protected abstract FullHttpRequest |
newHandshakeRequest()
Returns a new {@link FullHttpRequest) which will be used for the handshake.
|
protected abstract WebSocketFrameDecoder |
newWebsocketDecoder()
Returns the decoder to use after handshake is complete.
|
protected abstract WebSocketFrameEncoder |
newWebSocketEncoder()
Returns the encoder to use after the handshake is complete.
|
ChannelFuture |
processHandshake(Channel channel,
HttpResponse response)
Process the opening handshake initiated by
handshake(io.netty.channel.Channel) }. |
ChannelFuture |
processHandshake(Channel channel,
HttpResponse response,
ChannelPromise promise)
Process the opening handshake initiated by
handshake(io.netty.channel.Channel) }. |
java.net.URI |
uri()
Returns the URI to the web socket. e.g.
|
protected abstract void |
verify(FullHttpResponse response)
Verify the
FullHttpResponse and throws a WebSocketHandshakeException if something is wrong. |
WebSocketVersion |
version()
Version of the web socket specification that is being used
|
protected final HttpHeaders customHeaders
protected WebSocketClientHandshaker(java.net.URI uri, WebSocketVersion version, java.lang.String subprotocol, HttpHeaders customHeaders, int maxFramePayloadLength)
uri
- 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 requestmaxFramePayloadLength
- Maximum length of a frame's payloadpublic java.net.URI uri()
public WebSocketVersion version()
public int maxFramePayloadLength()
public boolean isHandshakeComplete()
public java.lang.String expectedSubprotocol()
public java.lang.String actualSubprotocol()
public ChannelFuture handshake(Channel channel)
channel
- Channelpublic final ChannelFuture handshake(Channel channel, ChannelPromise promise)
channel
- Channelpromise
- the ChannelPromise
to be notified when the opening handshake is sentprotected abstract FullHttpRequest newHandshakeRequest()
public final void finishHandshake(Channel channel, FullHttpResponse response)
handshake(io.netty.channel.Channel)
}.channel
- Channelresponse
- HTTP response containing the closing handshake detailspublic final ChannelFuture processHandshake(Channel channel, HttpResponse response)
handshake(io.netty.channel.Channel)
}.channel
- Channelresponse
- HTTP response containing the closing handshake detailsChannelFuture
which is notified once the handshake completes.public final ChannelFuture processHandshake(Channel channel, HttpResponse response, ChannelPromise promise)
handshake(io.netty.channel.Channel)
}.channel
- Channelresponse
- HTTP response containing the closing handshake detailspromise
- the ChannelPromise
to notify once the handshake completes.ChannelFuture
which is notified once the handshake completes.protected abstract void verify(FullHttpResponse response)
FullHttpResponse
and throws a WebSocketHandshakeException
if something is wrong.protected abstract WebSocketFrameDecoder newWebsocketDecoder()
protected abstract WebSocketFrameEncoder newWebSocketEncoder()
public ChannelFuture close(Channel channel, CloseWebSocketFrame frame)
channel
- Channelframe
- Closing Frame that was receivedpublic ChannelFuture close(Channel channel, CloseWebSocketFrame frame, ChannelPromise promise)
channel
- Channelframe
- Closing Frame that was receivedpromise
- the ChannelPromise
to be notified when the closing handshake is done