public class WebSocketServerProtocolHandler extends MessageToMessageDecoder<WebSocketFrame>
ChannelInboundHandler.userEventTriggered(ChannelHandlerContext, Object)
and check if the event was instance
of WebSocketServerProtocolHandler.HandshakeComplete
, the event will contain extra information about the handshake such as the request and
selected subprotocol.限定符和类型 | 类和说明 |
---|---|
static class |
WebSocketServerProtocolHandler.HandshakeComplete
The Handshake was completed successfully and the channel was upgraded to websockets.
|
static class |
WebSocketServerProtocolHandler.ServerHandshakeStateEvent
Events that are fired to notify about handshake status
|
ChannelHandler.Sharable
构造器和说明 |
---|
WebSocketServerProtocolHandler(java.lang.String websocketPath) |
WebSocketServerProtocolHandler(java.lang.String websocketPath,
boolean checkStartsWith) |
WebSocketServerProtocolHandler(java.lang.String websocketPath,
boolean checkStartsWith,
long handshakeTimeoutMillis) |
WebSocketServerProtocolHandler(java.lang.String websocketPath,
long handshakeTimeoutMillis) |
WebSocketServerProtocolHandler(java.lang.String websocketPath,
java.lang.String subprotocols) |
WebSocketServerProtocolHandler(java.lang.String websocketPath,
java.lang.String subprotocols,
boolean allowExtensions) |
WebSocketServerProtocolHandler(java.lang.String websocketPath,
java.lang.String subprotocols,
boolean checkStartsWith,
boolean dropPongFrames,
long handshakeTimeoutMillis,
WebSocketDecoderConfig decoderConfig) |
WebSocketServerProtocolHandler(java.lang.String websocketPath,
java.lang.String subprotocols,
boolean allowExtensions,
int maxFrameSize) |
WebSocketServerProtocolHandler(java.lang.String websocketPath,
java.lang.String subprotocols,
boolean allowExtensions,
int maxFrameSize,
boolean allowMaskMismatch) |
WebSocketServerProtocolHandler(java.lang.String websocketPath,
java.lang.String subprotocols,
boolean allowExtensions,
int maxFrameSize,
boolean allowMaskMismatch,
boolean checkStartsWith) |
WebSocketServerProtocolHandler(java.lang.String websocketPath,
java.lang.String subprotocols,
boolean allowExtensions,
int maxFrameSize,
boolean allowMaskMismatch,
boolean checkStartsWith,
boolean dropPongFrames) |
WebSocketServerProtocolHandler(java.lang.String websocketPath,
java.lang.String subprotocols,
boolean allowExtensions,
int maxFrameSize,
boolean allowMaskMismatch,
boolean checkStartsWith,
boolean dropPongFrames,
long handshakeTimeoutMillis) |
WebSocketServerProtocolHandler(java.lang.String websocketPath,
java.lang.String subprotocols,
boolean allowExtensions,
int maxFrameSize,
boolean allowMaskMismatch,
boolean checkStartsWith,
long handshakeTimeoutMillis) |
WebSocketServerProtocolHandler(java.lang.String websocketPath,
java.lang.String subprotocols,
boolean allowExtensions,
int maxFrameSize,
boolean allowMaskMismatch,
long handshakeTimeoutMillis) |
WebSocketServerProtocolHandler(java.lang.String websocketPath,
java.lang.String subprotocols,
boolean allowExtensions,
int maxFrameSize,
long handshakeTimeoutMillis) |
WebSocketServerProtocolHandler(java.lang.String websocketPath,
java.lang.String subprotocols,
boolean allowExtensions,
long handshakeTimeoutMillis) |
WebSocketServerProtocolHandler(java.lang.String websocketPath,
java.lang.String subprotocols,
long handshakeTimeoutMillis) |
WebSocketServerProtocolHandler(WebSocketServerProtocolConfig serverConfig)
Base constructor
|
限定符和类型 | 方法和说明 |
---|---|
void |
bind(ChannelHandlerContext ctx,
java.net.SocketAddress localAddress,
ChannelPromise promise)
Called once a bind operation is made.
|
protected WebSocketServerHandshakeException |
buildHandshakeException(java.lang.String message)
Returns a
WebSocketHandshakeException that depends on which client or server pipeline
this handler belongs. |
void |
close(ChannelHandlerContext ctx,
ChannelPromise promise)
Called once a close operation is made.
|
void |
connect(ChannelHandlerContext ctx,
java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress,
ChannelPromise promise)
Called once a connect operation is made.
|
protected void |
decode(ChannelHandlerContext ctx,
WebSocketFrame frame,
java.util.List<java.lang.Object> out)
Decode from one message to an other.
|
void |
deregister(ChannelHandlerContext ctx,
ChannelPromise promise)
Called once a deregister operation is made from the current registered
EventLoop . |
void |
disconnect(ChannelHandlerContext ctx,
ChannelPromise promise)
Called once a disconnect operation is made.
|
void |
exceptionCaught(ChannelHandlerContext ctx,
java.lang.Throwable cause)
Calls
ChannelHandlerContext.fireExceptionCaught(Throwable) to forward
to the next ChannelHandler in the ChannelPipeline . |
void |
flush(ChannelHandlerContext ctx)
Called once a flush operation is made.
|
void |
handlerAdded(ChannelHandlerContext ctx)
Do nothing by default, sub-classes may override this method.
|
void |
read(ChannelHandlerContext ctx)
Intercepts
ChannelHandlerContext.read() . |
void |
write(ChannelHandlerContext ctx,
java.lang.Object msg,
ChannelPromise promise)
Called once a write operation is made.
|
acceptInboundMessage, channelRead
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
ensureNotSharable, handlerRemoved, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handlerRemoved
public WebSocketServerProtocolHandler(WebSocketServerProtocolConfig serverConfig)
serverConfig
- Server protocol configuration.public WebSocketServerProtocolHandler(java.lang.String websocketPath)
public WebSocketServerProtocolHandler(java.lang.String websocketPath, long handshakeTimeoutMillis)
public WebSocketServerProtocolHandler(java.lang.String websocketPath, boolean checkStartsWith)
public WebSocketServerProtocolHandler(java.lang.String websocketPath, boolean checkStartsWith, long handshakeTimeoutMillis)
public WebSocketServerProtocolHandler(java.lang.String websocketPath, java.lang.String subprotocols)
public WebSocketServerProtocolHandler(java.lang.String websocketPath, java.lang.String subprotocols, long handshakeTimeoutMillis)
public WebSocketServerProtocolHandler(java.lang.String websocketPath, java.lang.String subprotocols, boolean allowExtensions)
public WebSocketServerProtocolHandler(java.lang.String websocketPath, java.lang.String subprotocols, boolean allowExtensions, long handshakeTimeoutMillis)
public WebSocketServerProtocolHandler(java.lang.String websocketPath, java.lang.String subprotocols, boolean allowExtensions, int maxFrameSize)
public WebSocketServerProtocolHandler(java.lang.String websocketPath, java.lang.String subprotocols, boolean allowExtensions, int maxFrameSize, long handshakeTimeoutMillis)
public WebSocketServerProtocolHandler(java.lang.String websocketPath, java.lang.String subprotocols, boolean allowExtensions, int maxFrameSize, boolean allowMaskMismatch)
public WebSocketServerProtocolHandler(java.lang.String websocketPath, java.lang.String subprotocols, boolean allowExtensions, int maxFrameSize, boolean allowMaskMismatch, long handshakeTimeoutMillis)
public WebSocketServerProtocolHandler(java.lang.String websocketPath, java.lang.String subprotocols, boolean allowExtensions, int maxFrameSize, boolean allowMaskMismatch, boolean checkStartsWith)
public WebSocketServerProtocolHandler(java.lang.String websocketPath, java.lang.String subprotocols, boolean allowExtensions, int maxFrameSize, boolean allowMaskMismatch, boolean checkStartsWith, long handshakeTimeoutMillis)
public WebSocketServerProtocolHandler(java.lang.String websocketPath, java.lang.String subprotocols, boolean allowExtensions, int maxFrameSize, boolean allowMaskMismatch, boolean checkStartsWith, boolean dropPongFrames)
public WebSocketServerProtocolHandler(java.lang.String websocketPath, java.lang.String subprotocols, boolean allowExtensions, int maxFrameSize, boolean allowMaskMismatch, boolean checkStartsWith, boolean dropPongFrames, long handshakeTimeoutMillis)
public WebSocketServerProtocolHandler(java.lang.String websocketPath, java.lang.String subprotocols, boolean checkStartsWith, boolean dropPongFrames, long handshakeTimeoutMillis, WebSocketDecoderConfig decoderConfig)
public void handlerAdded(ChannelHandlerContext ctx)
ChannelHandlerAdapter
handlerAdded
在接口中 ChannelHandler
handlerAdded
在类中 ChannelHandlerAdapter
protected void decode(ChannelHandlerContext ctx, WebSocketFrame frame, java.util.List<java.lang.Object> out) throws java.lang.Exception
MessageToMessageDecoder
ctx
- the ChannelHandlerContext
which this MessageToMessageDecoder
belongs toframe
- the message to decode to an other oneout
- the List
to which decoded messages should be addedjava.lang.Exception
- is thrown if an error occursprotected WebSocketServerHandshakeException buildHandshakeException(java.lang.String message)
WebSocketHandshakeException
that depends on which client or server pipeline
this handler belongs. Should be overridden in implementation otherwise a default exception is used.public void exceptionCaught(ChannelHandlerContext ctx, java.lang.Throwable cause) throws java.lang.Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireExceptionCaught(Throwable)
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.exceptionCaught
在接口中 ChannelHandler
exceptionCaught
在接口中 ChannelInboundHandler
java.lang.Exception
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws java.lang.Exception
ChannelOutboundHandler
close
在接口中 ChannelOutboundHandler
ctx
- the ChannelHandlerContext
for which the close operation is madepromise
- the ChannelPromise
to notify once the operation completesjava.lang.Exception
- thrown if an error occurspublic void write(ChannelHandlerContext ctx, java.lang.Object msg, ChannelPromise promise) throws java.lang.Exception
ChannelOutboundHandler
ChannelPipeline
. Those are then ready to be flushed to the actual Channel
once
Channel.flush()
is calledwrite
在接口中 ChannelOutboundHandler
ctx
- the ChannelHandlerContext
for which the write operation is mademsg
- the message to writepromise
- the ChannelPromise
to notify once the operation completesjava.lang.Exception
- thrown if an error occurspublic void bind(ChannelHandlerContext ctx, java.net.SocketAddress localAddress, ChannelPromise promise) throws java.lang.Exception
ChannelOutboundHandler
bind
在接口中 ChannelOutboundHandler
ctx
- the ChannelHandlerContext
for which the bind operation is madelocalAddress
- the SocketAddress
to which it should boundpromise
- the ChannelPromise
to notify once the operation completesjava.lang.Exception
- thrown if an error occurspublic void connect(ChannelHandlerContext ctx, java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, ChannelPromise promise) throws java.lang.Exception
ChannelOutboundHandler
connect
在接口中 ChannelOutboundHandler
ctx
- the ChannelHandlerContext
for which the connect operation is maderemoteAddress
- the SocketAddress
to which it should connectlocalAddress
- the SocketAddress
which is used as source on connectpromise
- the ChannelPromise
to notify once the operation completesjava.lang.Exception
- thrown if an error occurspublic void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws java.lang.Exception
ChannelOutboundHandler
disconnect
在接口中 ChannelOutboundHandler
ctx
- the ChannelHandlerContext
for which the disconnect operation is madepromise
- the ChannelPromise
to notify once the operation completesjava.lang.Exception
- thrown if an error occurspublic void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws java.lang.Exception
ChannelOutboundHandler
EventLoop
.deregister
在接口中 ChannelOutboundHandler
ctx
- the ChannelHandlerContext
for which the close operation is madepromise
- the ChannelPromise
to notify once the operation completesjava.lang.Exception
- thrown if an error occurspublic void read(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelOutboundHandler
ChannelHandlerContext.read()
.read
在接口中 ChannelOutboundHandler
java.lang.Exception
public void flush(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelOutboundHandler
flush
在接口中 ChannelOutboundHandler
ctx
- the ChannelHandlerContext
for which the flush operation is madejava.lang.Exception
- thrown if an error occurs