public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker
针对网络套接字规范版本draft-ietf-hybi-thewebsocketprotocol- 00执行客户端打开和关闭握手
这个代码的很大一部分来自Netty 3.2 HTTP示例。
customHeaders
Constructor and Description |
---|
WebSocketClientHandshaker00(java.net.URI webSocketURL, WebSocketVersion version, java.lang.String subprotocol, HttpHeaders customHeaders, int maxFramePayloadLength)
构造函数指定要启动的目标Web套接字位置和版本
|
Modifier and Type | Method and Description |
---|---|
protected FullHttpRequest |
newHandshakeRequest()
将打开请求发送到服务器:GET / demo HTTP / 1.1升级:WebSocket连接:升级主机:example.com原产地:http://example.com Sec-WebSocket-Key1:4 @ 1 46546xW%0l 1 5 Sec- WebSocket-Key2:12998 5 Y3 1.P00 ^ n:ds [4U
|
protected WebSocketFrameDecoder |
newWebsocketDecoder()
返回握手完成后使用的解码器。
|
protected WebSocketFrameEncoder |
newWebSocketEncoder()
返回握手完成后使用的编码器。
|
protected void |
verify(FullHttpResponse response)
进程服务器响应:HTTP / 1.1 101 WebSocket协议握手升级:WebSocket连接:升级Sec-WebSocket-Origin:http://example.com Sec-WebSocket-位置:ws://example.com/demo Sec-WebSocket协议:样品8jKS'y:G * Co,Wxa-
|
actualSubprotocol, close, close, expectedSubprotocol, finishHandshake, handshake, handshake, isHandshakeComplete, maxFramePayloadLength, processHandshake, processHandshake, uri, version
public WebSocketClientHandshaker00(java.net.URI webSocketURL, WebSocketVersion version, java.lang.String subprotocol, HttpHeaders customHeaders, int maxFramePayloadLength)
webSocketURL
- 网络套接字通信的URL。
例如“ws://myhost.com/mypath”。
后续的网络套接字帧将被发送到这个URL。
version
- 用于连接到服务器的Web套接字规范的版本
subprotocol
- 发送到服务器的子协议请求。
customHeaders
- 要添加到客户端请求的自定义标头的映射
maxFramePayloadLength
- 帧的有效载荷的最大长度
protected FullHttpRequest newHandshakeRequest()
将开放请求发送到服务器:
GET /demo HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Host: example.com
Origin: http://example.com
Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5
Sec-WebSocket-Key2: 12998 5 Y3 1 .P00
^n:ds[4U
newHandshakeRequest
WebSocketClientHandshaker
protected void verify(FullHttpResponse response)
进程服务器响应:
HTTP/1.1 101 WebSocket Protocol Handshake
Upgrade: WebSocket
Connection: Upgrade
Sec-WebSocket-Origin: http://example.com
Sec-WebSocket-Location: ws://example.com/demo
Sec-WebSocket-Protocol: sample
8jKS'y:G*Co,Wxa-
verify
在课程
WebSocketClientHandshaker
response
- 针对beginOpeningHandshake00()发送的请求从服务器返回的HTTP响应。
WebSocketHandshakeException
protected WebSocketFrameDecoder newWebsocketDecoder()
WebSocketClientHandshaker
newWebsocketDecoder
在课堂
WebSocketClientHandshaker
protected WebSocketFrameEncoder newWebSocketEncoder()
WebSocketClientHandshaker
newWebSocketEncoder
在课程
WebSocketClientHandshaker
Copyright © 2008–2018 The Netty Project. All rights reserved.