public abstract class WebSocketServerHandshaker extends Object
Modifier and Type | Field and Description |
---|---|
protected static io.netty.util.internal.logging.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
|
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 |
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 io.netty.util.internal.logging.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 payloadpublic String uri()
public WebSocketVersion version()
public int maxFramePayloadLength()
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)
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 doneprotected 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–2017 The Netty Project. All rights reserved.