public abstract class WebSocketClientHandshaker
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected HttpHeaders |
customHeaders |
| Modifier | Constructor and Description |
|---|---|
protected |
WebSocketClientHandshaker(java.net.URI uri, WebSocketVersion version, java.lang.String subprotocol, HttpHeaders customHeaders, int maxFramePayloadLength)
基础构造函数
|
protected final HttpHeaders customHeaders
protected WebSocketClientHandshaker(java.net.URI uri,
WebSocketVersion version,
java.lang.String subprotocol,
HttpHeaders customHeaders,
int maxFramePayloadLength)
uri - Web套接字通信的URL。
例如“ws://myhost.com/mypath”。
后续的网络套接字帧将被发送到这个URL。
version - 用于连接到服务器的Web套接字规范的版本
subprotocol - 发送到服务器的子协议请求。
customHeaders - 要添加到客户端请求的自定义标头的映射
maxFramePayloadLength - 帧有效负载的最大长度
public 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 - 频道
public final ChannelFuture handshake(Channel channel, ChannelPromise promise)
channel - 频道
promise - ChannelPromise在开始握手时发送通知
protected abstract FullHttpRequest newHandshakeRequest()
public final void finishHandshake(Channel channel, FullHttpResponse response)
handshake(io.netty.channel.Channel) }发起的开放握手。
channel - 频道
response - 包含关闭握手细节的HTTP响应
public final ChannelFuture processHandshake(Channel channel, HttpResponse response)
handshake(io.netty.channel.Channel) }发起的开放握手。
channel - 频道
response - 包含关闭握手细节的HTTP响应
ChannelFuture一旦握手完成就会收到通知。
public final ChannelFuture processHandshake(Channel channel, HttpResponse response, ChannelPromise promise)
handshake(io.netty.channel.Channel) }发起的开放握手。
channel - 频道
response - 包含关闭握手细节的HTTP响应
promise - 在握手完成后通知ChannelPromise 。
ChannelFuture一旦握手完成就会收到通知。
protected abstract void verify(FullHttpResponse response)
FullHttpResponse并在出现问题时抛出WebSocketHandshakeException 。
protected abstract WebSocketFrameDecoder newWebsocketDecoder()
protected abstract WebSocketFrameEncoder newWebSocketEncoder()
public ChannelFuture close(Channel channel, CloseWebSocketFrame frame)
channel - 频道
frame - 已收到的关闭帧
public ChannelFuture close(Channel channel, CloseWebSocketFrame frame, ChannelPromise promise)
channel - 频道
frame - 收到已收到的帧
promise - ChannelPromise关闭握手完成时通知
Copyright © 2008–2018 The Netty Project. All rights reserved.