public abstract class WebSocketServerHandshaker
extends java.lang.Object
限定符和类型 | 字段和说明 |
---|---|
static ChannelFutureListener |
HANDSHAKE_LISTENER
ChannelFutureListener which will call
Channels.fireExceptionCaught(ChannelHandlerContext, Throwable)
if the ChannelFuture was not successful. |
static java.lang.String |
SUB_PROTOCOL_WILDCARD
Use this as wildcard to support all requested sub-protocols
|
限定符 | 构造器和说明 |
---|---|
protected |
WebSocketServerHandshaker(WebSocketVersion version,
java.lang.String webSocketUrl,
java.lang.String subprotocols)
Constructor using default values
|
protected |
WebSocketServerHandshaker(WebSocketVersion version,
java.lang.String webSocketUrl,
java.lang.String subprotocols,
long maxFramePayloadLength)
Constructor specifying the destination web socket location
|
限定符和类型 | 方法和说明 |
---|---|
abstract ChannelFuture |
close(Channel channel,
CloseWebSocketFrame frame)
Performs the closing handshake
|
long |
getMaxFramePayloadLength()
Returns the max length for any frame's payload
|
java.lang.String |
getSelectedSubprotocol()
Returns the selected subprotocol.
|
java.util.Set<java.lang.String> |
getSubprotocols()
Returns the CSV of supported sub protocols
|
WebSocketVersion |
getVersion()
Returns the version of the specification being supported
|
java.lang.String |
getWebSocketUrl()
Returns the URL of the web socket
|
abstract ChannelFuture |
handshake(Channel channel,
HttpRequest req)
Performs the opening handshake
|
protected java.lang.String |
selectSubprotocol(java.lang.String requestedSubprotocols)
Selects the first matching supported sub protocol
|
protected void |
setSelectedSubprotocol(java.lang.String value) |
protected ChannelFuture |
writeHandshakeResponse(Channel channel,
HttpResponse res,
ChannelHandler encoder,
ChannelHandler decoder)
Upgrades the connection and send the handshake response.
|
public static final java.lang.String SUB_PROTOCOL_WILDCARD
public static final ChannelFutureListener HANDSHAKE_LISTENER
ChannelFutureListener
which will call
Channels.fireExceptionCaught(ChannelHandlerContext, Throwable)
if the ChannelFuture
was not successful.protected WebSocketServerHandshaker(WebSocketVersion version, java.lang.String webSocketUrl, java.lang.String subprotocols)
version
- the protocol versionwebSocketUrl
- 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.protected WebSocketServerHandshaker(WebSocketVersion version, java.lang.String webSocketUrl, java.lang.String subprotocols, long maxFramePayloadLength)
version
- the protocol versionwebSocketUrl
- 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 java.lang.String getWebSocketUrl()
public java.util.Set<java.lang.String> getSubprotocols()
public WebSocketVersion getVersion()
public long getMaxFramePayloadLength()
public abstract ChannelFuture handshake(Channel channel, HttpRequest req)
channel
- Channelreq
- HTTP Requestprotected ChannelFuture writeHandshakeResponse(Channel channel, HttpResponse res, ChannelHandler encoder, ChannelHandler decoder)
public abstract ChannelFuture close(Channel channel, CloseWebSocketFrame frame)
channel
- Channelframe
- Closing Frame that was receivedprotected java.lang.String selectSubprotocol(java.lang.String requestedSubprotocols)
requestedSubprotocols
- CSV of protocols to be supported. e.g. "chat, superchat"public java.lang.String getSelectedSubprotocol()
This is only available AFTER handshake() has been called.
protected void setSelectedSubprotocol(java.lang.String value)