public class WebSocketClientProtocolHandler extends MessageToMessageDecoder<WebSocketFrame>
handleCloseFrames is false, default is true.
This implementation will establish the websocket connection once the connection to the remote server was complete.
To know once a handshake was done you can intercept the
ChannelInboundHandler.userEventTriggered(ChannelHandlerContext, Object) and check if the event was of type
WebSocketClientProtocolHandler.ClientHandshakeStateEvent.HANDSHAKE_ISSUED or WebSocketClientProtocolHandler.ClientHandshakeStateEvent.HANDSHAKE_COMPLETE.| 限定符和类型 | 类和说明 |
|---|---|
static class |
WebSocketClientProtocolHandler.ClientHandshakeStateEvent
Events that are fired to notify about handshake status
|
ChannelHandler.Sharable| 构造器和说明 |
|---|
WebSocketClientProtocolHandler(java.net.URI webSocketURL,
WebSocketVersion version,
java.lang.String subprotocol,
boolean allowExtensions,
HttpHeaders customHeaders,
int maxFramePayloadLength)
Base constructor
|
WebSocketClientProtocolHandler(java.net.URI webSocketURL,
WebSocketVersion version,
java.lang.String subprotocol,
boolean allowExtensions,
HttpHeaders customHeaders,
int maxFramePayloadLength,
boolean handleCloseFrames)
Base constructor
|
WebSocketClientProtocolHandler(WebSocketClientHandshaker handshaker)
Base constructor
|
WebSocketClientProtocolHandler(WebSocketClientHandshaker handshaker,
boolean handleCloseFrames)
Base constructor
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
decode(ChannelHandlerContext ctx,
WebSocketFrame frame,
java.util.List<java.lang.Object> out)
Decode from one message to an other.
|
void |
exceptionCaught(ChannelHandlerContext ctx,
java.lang.Throwable cause)
Calls
ChannelHandlerContext.fireExceptionCaught(Throwable) to forward
to the next ChannelHandler in the ChannelPipeline. |
void |
handlerAdded(ChannelHandlerContext ctx)
Do nothing by default, sub-classes may override this method.
|
WebSocketClientHandshaker |
handshaker()
Returns the used handshaker
|
acceptInboundMessage, channelReadchannelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredensureNotSharable, handlerRemoved, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlerRemovedpublic WebSocketClientProtocolHandler(java.net.URI webSocketURL,
WebSocketVersion version,
java.lang.String subprotocol,
boolean allowExtensions,
HttpHeaders customHeaders,
int maxFramePayloadLength,
boolean handleCloseFrames)
webSocketURL - URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be
sent to this URL.version - Version of web socket specification to use to connect to the serversubprotocol - Sub protocol request sent to the server.customHeaders - Map of custom headers to add to the client requestmaxFramePayloadLength - Maximum length of a frame's payloadhandleCloseFrames - true if close frames should not be forwarded and just close the channelpublic WebSocketClientProtocolHandler(java.net.URI webSocketURL,
WebSocketVersion version,
java.lang.String subprotocol,
boolean allowExtensions,
HttpHeaders customHeaders,
int maxFramePayloadLength)
webSocketURL - URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be
sent to this URL.version - Version of web socket specification to use to connect to the serversubprotocol - Sub protocol request sent to the server.customHeaders - Map of custom headers to add to the client requestmaxFramePayloadLength - Maximum length of a frame's payloadpublic WebSocketClientProtocolHandler(WebSocketClientHandshaker handshaker, boolean handleCloseFrames)
handshaker - The WebSocketClientHandshaker which will be used to issue the handshake once the connection
was established to the remote peer.handleCloseFrames - true if close frames should not be forwarded and just close the channelpublic WebSocketClientProtocolHandler(WebSocketClientHandshaker handshaker)
handshaker - The WebSocketClientHandshaker which will be used to issue the handshake once the connection
was established to the remote peer.public WebSocketClientHandshaker handshaker()
protected void decode(ChannelHandlerContext ctx, WebSocketFrame frame, java.util.List<java.lang.Object> out) throws java.lang.Exception
MessageToMessageDecoderctx - 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 occurspublic void handlerAdded(ChannelHandlerContext ctx)
ChannelHandlerAdapterhandlerAdded 在接口中 ChannelHandlerhandlerAdded 在类中 ChannelHandlerAdapterpublic void exceptionCaught(ChannelHandlerContext ctx, java.lang.Throwable cause) throws java.lang.Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireExceptionCaught(Throwable) to forward
to the next ChannelHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.exceptionCaught 在接口中 ChannelHandlerexceptionCaught 在接口中 ChannelInboundHandlerexceptionCaught 在类中 ChannelInboundHandlerAdapterjava.lang.Exception