public class WebSocketClientProtocolHandler extends io.netty.handler.codec.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
.Modifier and Type | Class and Description |
---|---|
static class |
WebSocketClientProtocolHandler.ClientHandshakeStateEvent
Events that are fired to notify about handshake status
|
Constructor and Description |
---|
WebSocketClientProtocolHandler(URI webSocketURL,
WebSocketVersion version,
String subprotocol,
boolean allowExtensions,
HttpHeaders customHeaders,
int maxFramePayloadLength)
Base constructor
|
WebSocketClientProtocolHandler(URI webSocketURL,
WebSocketVersion version,
String subprotocol,
boolean allowExtensions,
HttpHeaders customHeaders,
int maxFramePayloadLength,
boolean handleCloseFrames)
Base constructor
|
WebSocketClientProtocolHandler(WebSocketClientHandshaker handshaker)
Base constructor
|
WebSocketClientProtocolHandler(WebSocketClientHandshaker handshaker,
boolean handleCloseFrames)
Base constructor
|
Modifier and Type | Method and Description |
---|---|
protected void |
decode(io.netty.channel.ChannelHandlerContext ctx,
WebSocketFrame frame,
List<Object> out) |
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause) |
void |
handlerAdded(io.netty.channel.ChannelHandlerContext ctx) |
acceptInboundMessage, channelRead
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
public WebSocketClientProtocolHandler(URI webSocketURL, WebSocketVersion version, 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(URI webSocketURL, WebSocketVersion version, 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.protected void decode(io.netty.channel.ChannelHandlerContext ctx, WebSocketFrame frame, List<Object> out) throws Exception
Exception
public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
handlerAdded
in interface io.netty.channel.ChannelHandler
handlerAdded
in class io.netty.channel.ChannelHandlerAdapter
Copyright © 2008–2013 The Netty Project. All rights reserved.