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.Modifier and Type | Class and Description |
---|---|
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
Constructor and Description |
---|
WebSocketServerProtocolHandler(String websocketPath) |
WebSocketServerProtocolHandler(String websocketPath,
boolean checkStartsWith) |
WebSocketServerProtocolHandler(String websocketPath,
boolean checkStartsWith,
long handshakeTimeoutMillis) |
WebSocketServerProtocolHandler(String websocketPath,
long handshakeTimeoutMillis) |
WebSocketServerProtocolHandler(String websocketPath,
String subprotocols) |
WebSocketServerProtocolHandler(String websocketPath,
String subprotocols,
boolean allowExtensions) |
WebSocketServerProtocolHandler(String websocketPath,
String subprotocols,
boolean checkStartsWith,
boolean dropPongFrames,
long handshakeTimeoutMillis,
WebSocketDecoderConfig decoderConfig) |
WebSocketServerProtocolHandler(String websocketPath,
String subprotocols,
boolean allowExtensions,
int maxFrameSize) |
WebSocketServerProtocolHandler(String websocketPath,
String subprotocols,
boolean allowExtensions,
int maxFrameSize,
boolean allowMaskMismatch) |
WebSocketServerProtocolHandler(String websocketPath,
String subprotocols,
boolean allowExtensions,
int maxFrameSize,
boolean allowMaskMismatch,
boolean checkStartsWith) |
WebSocketServerProtocolHandler(String websocketPath,
String subprotocols,
boolean allowExtensions,
int maxFrameSize,
boolean allowMaskMismatch,
boolean checkStartsWith,
boolean dropPongFrames) |
WebSocketServerProtocolHandler(String websocketPath,
String subprotocols,
boolean allowExtensions,
int maxFrameSize,
boolean allowMaskMismatch,
boolean checkStartsWith,
boolean dropPongFrames,
long handshakeTimeoutMillis) |
WebSocketServerProtocolHandler(String websocketPath,
String subprotocols,
boolean allowExtensions,
int maxFrameSize,
boolean allowMaskMismatch,
boolean checkStartsWith,
long handshakeTimeoutMillis) |
WebSocketServerProtocolHandler(String websocketPath,
String subprotocols,
boolean allowExtensions,
int maxFrameSize,
boolean allowMaskMismatch,
long handshakeTimeoutMillis) |
WebSocketServerProtocolHandler(String websocketPath,
String subprotocols,
boolean allowExtensions,
int maxFrameSize,
long handshakeTimeoutMillis) |
WebSocketServerProtocolHandler(String websocketPath,
String subprotocols,
boolean allowExtensions,
long handshakeTimeoutMillis) |
WebSocketServerProtocolHandler(String websocketPath,
String subprotocols,
long handshakeTimeoutMillis) |
WebSocketServerProtocolHandler(WebSocketServerProtocolConfig serverConfig)
Base constructor
|
Modifier and Type | Method and Description |
---|---|
void |
bind(ChannelHandlerContext ctx,
SocketAddress localAddress,
ChannelPromise promise)
Called once a bind operation is made.
|
protected WebSocketServerHandshakeException |
buildHandshakeException(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,
SocketAddress remoteAddress,
SocketAddress localAddress,
ChannelPromise promise)
Called once a connect operation is made.
|
protected void |
decode(ChannelHandlerContext ctx,
WebSocketFrame frame,
List<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,
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,
Object msg,
ChannelPromise promise)
Called once a write operation is made.
|
acceptInboundMessage, channelRead, channelReadComplete
channelActive, channelInactive, 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(String websocketPath)
public WebSocketServerProtocolHandler(String websocketPath, long handshakeTimeoutMillis)
public WebSocketServerProtocolHandler(String websocketPath, boolean checkStartsWith)
public WebSocketServerProtocolHandler(String websocketPath, boolean checkStartsWith, long handshakeTimeoutMillis)
public WebSocketServerProtocolHandler(String websocketPath, String subprotocols)
public WebSocketServerProtocolHandler(String websocketPath, String subprotocols, long handshakeTimeoutMillis)
public WebSocketServerProtocolHandler(String websocketPath, String subprotocols, boolean allowExtensions)
public WebSocketServerProtocolHandler(String websocketPath, String subprotocols, boolean allowExtensions, long handshakeTimeoutMillis)
public WebSocketServerProtocolHandler(String websocketPath, String subprotocols, boolean allowExtensions, int maxFrameSize)
public WebSocketServerProtocolHandler(String websocketPath, String subprotocols, boolean allowExtensions, int maxFrameSize, long handshakeTimeoutMillis)
public WebSocketServerProtocolHandler(String websocketPath, String subprotocols, boolean allowExtensions, int maxFrameSize, boolean allowMaskMismatch)
public WebSocketServerProtocolHandler(String websocketPath, String subprotocols, boolean allowExtensions, int maxFrameSize, boolean allowMaskMismatch, long handshakeTimeoutMillis)
public WebSocketServerProtocolHandler(String websocketPath, String subprotocols, boolean allowExtensions, int maxFrameSize, boolean allowMaskMismatch, boolean checkStartsWith)
public WebSocketServerProtocolHandler(String websocketPath, String subprotocols, boolean allowExtensions, int maxFrameSize, boolean allowMaskMismatch, boolean checkStartsWith, long handshakeTimeoutMillis)
public WebSocketServerProtocolHandler(String websocketPath, String subprotocols, boolean allowExtensions, int maxFrameSize, boolean allowMaskMismatch, boolean checkStartsWith, boolean dropPongFrames)
public WebSocketServerProtocolHandler(String websocketPath, String subprotocols, boolean allowExtensions, int maxFrameSize, boolean allowMaskMismatch, boolean checkStartsWith, boolean dropPongFrames, long handshakeTimeoutMillis)
public WebSocketServerProtocolHandler(String websocketPath, String subprotocols, boolean checkStartsWith, boolean dropPongFrames, long handshakeTimeoutMillis, WebSocketDecoderConfig decoderConfig)
public void handlerAdded(ChannelHandlerContext ctx)
ChannelHandlerAdapter
handlerAdded
in interface ChannelHandler
handlerAdded
in class ChannelHandlerAdapter
protected void decode(ChannelHandlerContext ctx, WebSocketFrame frame, List<Object> out) throws 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 addedException
- is thrown if an error occursprotected WebSocketServerHandshakeException buildHandshakeException(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, Throwable cause) throws Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireExceptionCaught(Throwable)
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.exceptionCaught
in interface ChannelHandler
exceptionCaught
in interface ChannelInboundHandler
Exception
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
ChannelOutboundHandler
close
in interface ChannelOutboundHandler
ctx
- the ChannelHandlerContext
for which the close operation is madepromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error occurspublic void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
ChannelOutboundHandler
ChannelPipeline
. Those are then ready to be flushed to the actual Channel
once
Channel.flush()
is calledwrite
in interface ChannelOutboundHandler
ctx
- the ChannelHandlerContext
for which the write operation is mademsg
- the message to writepromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error occurspublic void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception
ChannelOutboundHandler
bind
in interface 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 completesException
- thrown if an error occurspublic void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception
ChannelOutboundHandler
connect
in interface 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 completesException
- thrown if an error occurspublic void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
ChannelOutboundHandler
disconnect
in interface ChannelOutboundHandler
ctx
- the ChannelHandlerContext
for which the disconnect operation is madepromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error occurspublic void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
ChannelOutboundHandler
EventLoop
.deregister
in interface ChannelOutboundHandler
ctx
- the ChannelHandlerContext
for which the close operation is madepromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error occurspublic void read(ChannelHandlerContext ctx) throws Exception
ChannelOutboundHandler
ChannelHandlerContext.read()
.read
in interface ChannelOutboundHandler
Exception
public void flush(ChannelHandlerContext ctx) throws Exception
ChannelOutboundHandler
flush
in interface ChannelOutboundHandler
ctx
- the ChannelHandlerContext
for which the flush operation is madeException
- thrown if an error occursCopyright © 2008–2024 The Netty Project. All rights reserved.