public abstract class WebSocketServerHandshaker
extends java.lang.Object
限定符和类型 | 字段和说明 |
---|---|
protected static InternalLogger |
logger |
static java.lang.String |
SUB_PROTOCOL_WILDCARD
Use this as wildcard to support all requested sub-protocols
|
限定符 | 构造器和说明 |
---|---|
protected |
WebSocketServerHandshaker(WebSocketVersion version,
java.lang.String uri,
java.lang.String subprotocols,
int maxFramePayloadLength)
Constructor specifying the destination web socket location
|
protected |
WebSocketServerHandshaker(WebSocketVersion version,
java.lang.String uri,
java.lang.String subprotocols,
WebSocketDecoderConfig decoderConfig)
Constructor specifying the destination web socket location
|
限定符和类型 | 方法和说明 |
---|---|
ChannelFuture |
close(Channel channel,
CloseWebSocketFrame frame)
Performs the closing handshake.
|
ChannelFuture |
close(Channel channel,
CloseWebSocketFrame frame,
ChannelPromise promise)
Performs the closing handshake.
|
ChannelFuture |
close(ChannelHandlerContext ctx,
CloseWebSocketFrame frame)
Performs the closing handshake.
|
ChannelFuture |
close(ChannelHandlerContext ctx,
CloseWebSocketFrame frame,
ChannelPromise promise)
Performs the closing handshake.
|
WebSocketDecoderConfig |
decoderConfig()
Gets this decoder configuration.
|
ChannelFuture |
handshake(Channel channel,
FullHttpRequest req)
Performs the opening handshake.
|
ChannelFuture |
handshake(Channel channel,
FullHttpRequest req,
HttpHeaders responseHeaders,
ChannelPromise promise)
Performs the opening handshake
When call this method you MUST NOT retain the
FullHttpRequest which is passed in. |
ChannelFuture |
handshake(Channel channel,
HttpRequest req)
Performs the opening handshake.
|
ChannelFuture |
handshake(Channel channel,
HttpRequest req,
HttpHeaders responseHeaders,
ChannelPromise promise)
Performs the opening handshake
When call this method you MUST NOT retain the
HttpRequest which is passed in. |
int |
maxFramePayloadLength()
Gets the maximum length for any frame's payload.
|
protected abstract FullHttpResponse |
newHandshakeResponse(FullHttpRequest req,
HttpHeaders responseHeaders)
Returns a new {@link FullHttpResponse) which will be used for as response to the handshake request.
|
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.
|
java.lang.String |
selectedSubprotocol()
Returns the selected subprotocol.
|
protected java.lang.String |
selectSubprotocol(java.lang.String requestedSubprotocols)
Selects the first matching supported sub protocol
|
java.util.Set<java.lang.String> |
subprotocols()
Returns the CSV of supported sub protocols
|
java.lang.String |
uri()
Returns the URL of the web socket
|
WebSocketVersion |
version()
Returns the version of the specification being supported
|
protected static final InternalLogger logger
public static final java.lang.String SUB_PROTOCOL_WILDCARD
protected WebSocketServerHandshaker(WebSocketVersion version, java.lang.String uri, java.lang.String subprotocols, int maxFramePayloadLength)
version
- the protocol versionuri
- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be
sent to this URL.subprotocols
- CSV of supported protocols. Null if sub protocols not supported.maxFramePayloadLength
- Maximum length of a frame's payloadprotected WebSocketServerHandshaker(WebSocketVersion version, java.lang.String uri, java.lang.String subprotocols, WebSocketDecoderConfig decoderConfig)
version
- the protocol versionuri
- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be
sent to this URL.subprotocols
- CSV of supported protocols. Null if sub protocols not supported.decoderConfig
- Frames decoder configuration.public java.lang.String uri()
public java.util.Set<java.lang.String> subprotocols()
public WebSocketVersion version()
public int maxFramePayloadLength()
public WebSocketDecoderConfig decoderConfig()
public ChannelFuture handshake(Channel channel, FullHttpRequest req)
FullHttpRequest
which is passed in.channel
- Channelreq
- HTTP RequestChannelFuture
which is notified once the opening handshake completespublic final ChannelFuture handshake(Channel channel, FullHttpRequest req, HttpHeaders responseHeaders, ChannelPromise promise)
FullHttpRequest
which is passed in.channel
- Channelreq
- HTTP RequestresponseHeaders
- Extra headers to add to the handshake response or null
if no extra headers should be addedpromise
- the ChannelPromise
to be notified when the opening handshake is doneChannelFuture
which is notified when the opening handshake is donepublic ChannelFuture handshake(Channel channel, HttpRequest req)
FullHttpRequest
which is passed in.channel
- Channelreq
- HTTP RequestChannelFuture
which is notified once the opening handshake completespublic final ChannelFuture handshake(Channel channel, HttpRequest req, HttpHeaders responseHeaders, ChannelPromise promise)
HttpRequest
which is passed in.channel
- Channelreq
- HTTP RequestresponseHeaders
- Extra headers to add to the handshake response or null
if no extra headers should be addedpromise
- the ChannelPromise
to be notified when the opening handshake is doneChannelFuture
which is notified when the opening handshake is doneprotected abstract FullHttpResponse newHandshakeResponse(FullHttpRequest req, HttpHeaders responseHeaders)
public ChannelFuture close(Channel channel, CloseWebSocketFrame frame)
ChannelHandler
you most likely want to use
close(ChannelHandlerContext, CloseWebSocketFrame)
.channel
- the Channel
to use.frame
- Closing Frame that was received.public ChannelFuture close(Channel channel, CloseWebSocketFrame frame, ChannelPromise promise)
ChannelHandler
you most likely want to use
close(ChannelHandlerContext, CloseWebSocketFrame, ChannelPromise)
.channel
- the Channel
to use.frame
- Closing Frame that was received.promise
- the ChannelPromise
to be notified when the closing handshake is donepublic ChannelFuture close(ChannelHandlerContext ctx, CloseWebSocketFrame frame)
ctx
- the ChannelHandlerContext
to use.frame
- Closing Frame that was received.public ChannelFuture close(ChannelHandlerContext ctx, CloseWebSocketFrame frame, ChannelPromise promise)
ctx
- the ChannelHandlerContext
to use.frame
- Closing Frame that was received.promise
- the ChannelPromise
to be notified when the closing handshake is done.protected java.lang.String selectSubprotocol(java.lang.String requestedSubprotocols)
requestedSubprotocols
- CSV of protocols to be supported. e.g. "chat, superchat"public java.lang.String selectedSubprotocol()
This is only available AFTER handshake() has been called.
protected abstract WebSocketFrameDecoder newWebsocketDecoder()
protected abstract WebSocketFrameEncoder newWebSocketEncoder()