public abstract class WebSocketServerHandshaker extends Object
Modifier and Type | Field and Description |
---|---|
protected static InternalLogger |
logger |
static String |
SUB_PROTOCOL_WILDCARD
Use this as wildcard to support all requested sub-protocols
|
Modifier | Constructor and Description |
---|---|
protected |
WebSocketServerHandshaker(WebSocketVersion version,
String uri,
String subprotocols,
int maxFramePayloadLength)
Constructor specifying the destination web socket location
|
protected |
WebSocketServerHandshaker(WebSocketVersion version,
String uri,
String subprotocols,
WebSocketDecoderConfig decoderConfig)
Constructor specifying the destination web socket location
|
Modifier and Type | Method and Description |
---|---|
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.
|
String |
selectedSubprotocol()
Returns the selected subprotocol.
|
protected String |
selectSubprotocol(String requestedSubprotocols)
Selects the first matching supported sub protocol
|
Set<String> |
subprotocols()
Returns the CSV of supported sub protocols
|
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 String SUB_PROTOCOL_WILDCARD
protected WebSocketServerHandshaker(WebSocketVersion version, String uri, 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, String uri, 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 String uri()
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 String selectSubprotocol(String requestedSubprotocols)
requestedSubprotocols
- CSV of protocols to be supported. e.g. "chat, superchat"public String selectedSubprotocol()
This is only available AFTER handshake() has been called.
protected abstract WebSocketFrameDecoder newWebsocketDecoder()
protected abstract WebSocketFrameEncoder newWebSocketEncoder()
Copyright © 2008–2024 The Netty Project. All rights reserved.