public class WebSocketFrameAggregator extends MessageAggregator<WebSocketFrame,WebSocketFrame,ContinuationWebSocketFrame,WebSocketFrame>
WebSocketFrame
they will
just get forwarded to the next handler in the pipeline.ChannelHandler.Sharable, ChannelHandler.Skip
Constructor and Description |
---|
WebSocketFrameAggregator(int maxContentLength)
Creates a new instance
|
Modifier and Type | Method and Description |
---|---|
protected WebSocketFrame |
beginAggregation(WebSocketFrame start,
ByteBuf content)
Creates a new aggregated message from the specified start message and the specified content.
|
protected long |
contentLength(WebSocketFrame start)
Retrieves the length of the whole content from the specified start message.
|
protected boolean |
hasContentLength(WebSocketFrame start)
Returns
true if and only if the specified start message already contains the information about the
length of the whole content. |
protected boolean |
isAggregated(WebSocketFrame msg)
Returns
true if and only if the specified message is already aggregated. |
protected boolean |
isContentMessage(WebSocketFrame msg)
Returns
true if and only if the specified message is a content message. |
protected boolean |
isLastContentMessage(ContinuationWebSocketFrame msg)
Returns
true if and only if the specified message is the last content message. |
protected boolean |
isStartMessage(WebSocketFrame msg)
Returns
true if and only if the specified message is a start message. |
protected Object |
newContinueResponse(WebSocketFrame start)
Returns the 'continue response' for the specified start message if necessary.
|
acceptInboundMessage, aggregate, channelInactive, ctx, decode, finishAggregation, handleOversizedMessage, handlerAdded, handlerRemoved, isHandlingOversizedMessage, maxContentLength, maxCumulationBufferComponents, setMaxCumulationBufferComponents
channelRead
bind, channelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, exceptionCaught, flush, isSharable, read, userEventTriggered, write
public WebSocketFrameAggregator(int maxContentLength)
maxContentLength
- If the size of the aggregated frame exceeds this value,
a TooLongFrameException
is thrown.protected boolean isStartMessage(WebSocketFrame msg) throws Exception
MessageAggregator
true
if and only if the specified message is a start message. Typically, this method is
implemented as a single return
statement with instanceof
:
return msg instanceof MyStartMessage;
isStartMessage
in class MessageAggregator<WebSocketFrame,WebSocketFrame,ContinuationWebSocketFrame,WebSocketFrame>
Exception
protected boolean isContentMessage(WebSocketFrame msg) throws Exception
MessageAggregator
true
if and only if the specified message is a content message. Typically, this method is
implemented as a single return
statement with instanceof
:
return msg instanceof MyContentMessage;
isContentMessage
in class MessageAggregator<WebSocketFrame,WebSocketFrame,ContinuationWebSocketFrame,WebSocketFrame>
Exception
protected boolean isLastContentMessage(ContinuationWebSocketFrame msg) throws Exception
MessageAggregator
true
if and only if the specified message is the last content message. Typically, this method is
implemented as a single return
statement with instanceof
:
return msg instanceof MyLastContentMessage;or with
instanceof
and boolean field check:
return msg instanceof MyContentMessage && msg.isLastFragment();
isLastContentMessage
in class MessageAggregator<WebSocketFrame,WebSocketFrame,ContinuationWebSocketFrame,WebSocketFrame>
Exception
protected boolean isAggregated(WebSocketFrame msg) throws Exception
MessageAggregator
true
if and only if the specified message is already aggregated. If this method returns
true
, this handler will simply forward the message to the next handler as-is.isAggregated
in class MessageAggregator<WebSocketFrame,WebSocketFrame,ContinuationWebSocketFrame,WebSocketFrame>
Exception
protected boolean hasContentLength(WebSocketFrame start) throws Exception
MessageAggregator
true
if and only if the specified start message already contains the information about the
length of the whole content.hasContentLength
in class MessageAggregator<WebSocketFrame,WebSocketFrame,ContinuationWebSocketFrame,WebSocketFrame>
Exception
protected long contentLength(WebSocketFrame start) throws Exception
MessageAggregator
MessageAggregator.hasContentLength(Object)
returned true
.contentLength
in class MessageAggregator<WebSocketFrame,WebSocketFrame,ContinuationWebSocketFrame,WebSocketFrame>
Exception
protected Object newContinueResponse(WebSocketFrame start) throws Exception
MessageAggregator
newContinueResponse
in class MessageAggregator<WebSocketFrame,WebSocketFrame,ContinuationWebSocketFrame,WebSocketFrame>
null
if there's no message to sendException
protected WebSocketFrame beginAggregation(WebSocketFrame start, ByteBuf content) throws Exception
MessageAggregator
ByteBufHolder
, its content is appended to the specified content
.
This aggregator will continue to append the received content to the specified content
.beginAggregation
in class MessageAggregator<WebSocketFrame,WebSocketFrame,ContinuationWebSocketFrame,WebSocketFrame>
Exception
Copyright © 2008–2015 The Netty Project. All rights reserved.