Class SpdyFrameCodec
- java.lang.Object
-
- org.jboss.netty.channel.SimpleChannelUpstreamHandler
-
- org.jboss.netty.handler.codec.frame.FrameDecoder
-
- org.jboss.netty.handler.codec.spdy.SpdyFrameCodec
-
- All Implemented Interfaces:
ChannelDownstreamHandler
,ChannelHandler
,ChannelUpstreamHandler
,LifeCycleAwareChannelHandler
,SpdyFrameDecoderDelegate
public class SpdyFrameCodec extends FrameDecoder implements SpdyFrameDecoderDelegate, ChannelDownstreamHandler
AChannelHandler
that encodes and decodes SPDY Frames.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
-
Fields inherited from class org.jboss.netty.handler.codec.frame.FrameDecoder
cumulation, DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS
-
-
Constructor Summary
Constructors Modifier Constructor Description SpdyFrameCodec(SpdyVersion version)
Creates a new instance with the specifiedversion
and the default decoder and encoder options (maxChunkSize (8192)
,maxHeaderSize (16384)
,compressionLevel (6)
,windowBits (15)
, andmemLevel (8)
).SpdyFrameCodec(SpdyVersion version, int maxChunkSize, int maxHeaderSize, int compressionLevel, int windowBits, int memLevel)
Creates a new instance with the specified decoder and encoder options.protected
SpdyFrameCodec(SpdyVersion version, int maxChunkSize, org.jboss.netty.handler.codec.spdy.SpdyHeaderBlockDecoder spdyHeaderBlockDecoder, org.jboss.netty.handler.codec.spdy.SpdyHeaderBlockEncoder spdyHeaderBlockEncoder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beforeAdd(ChannelHandlerContext ctx)
protected void
cleanup(ChannelHandlerContext ctx, ChannelStateEvent e)
protected Object
decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer)
Decodes the received packets so far into a frame.void
handleDownstream(ChannelHandlerContext ctx, ChannelEvent evt)
Handles the specified downstream event.void
readDataFrame(int streamId, boolean last, ChannelBuffer data)
Called when a DATA frame is received.void
readFrameError(String message)
Called when an unrecoverable session error has occurred.void
readGoAwayFrame(int lastGoodStreamId, int statusCode)
Called when a GOAWAY frame is received.void
readHeaderBlock(ChannelBuffer headerBlock)
Called when the header block within a SYN_STREAM, SYN_REPLY, or HEADERS frame is received.void
readHeaderBlockEnd()
Called when an entire header block has been received.void
readHeadersFrame(int streamId, boolean last)
Called when a HEADERS frame is received.void
readPingFrame(int id)
Called when a PING frame is received.void
readRstStreamFrame(int streamId, int statusCode)
Called when a RST_STREAM frame is received.void
readSetting(int id, int value, boolean persistValue, boolean persisted)
Called when an individual setting within a SETTINGS frame is received.void
readSettingsEnd()
Called when the entire SETTINGS frame has been received.void
readSettingsFrame(boolean clearPersisted)
Called when a SETTINGS frame is received.void
readSynReplyFrame(int streamId, boolean last)
Called when a SYN_REPLY frame is received.void
readSynStreamFrame(int streamId, int associatedToStreamId, byte priority, boolean last, boolean unidirectional)
Called when a SYN_STREAM frame is received.void
readWindowUpdateFrame(int streamId, int deltaWindowSize)
Called when a WINDOW_UPDATE frame is received.-
Methods inherited from class org.jboss.netty.handler.codec.frame.FrameDecoder
actualReadableBytes, afterAdd, afterRemove, appendToCumulation, beforeRemove, channelClosed, channelDisconnected, decodeLast, exceptionCaught, extractFrame, getMaxCumulationBufferCapacity, getMaxCumulationBufferComponents, internalBuffer, isUnfold, messageReceived, newCumulationBuffer, replace, setMaxCumulationBufferCapacity, setMaxCumulationBufferComponents, setUnfold, unfoldAndFireMessageReceived, updateCumulation
-
Methods inherited from class org.jboss.netty.channel.SimpleChannelUpstreamHandler
channelBound, channelConnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream, writeComplete
-
-
-
-
Constructor Detail
-
SpdyFrameCodec
public SpdyFrameCodec(SpdyVersion version)
Creates a new instance with the specifiedversion
and the default decoder and encoder options (maxChunkSize (8192)
,maxHeaderSize (16384)
,compressionLevel (6)
,windowBits (15)
, andmemLevel (8)
).
-
SpdyFrameCodec
public SpdyFrameCodec(SpdyVersion version, int maxChunkSize, int maxHeaderSize, int compressionLevel, int windowBits, int memLevel)
Creates a new instance with the specified decoder and encoder options.
-
SpdyFrameCodec
protected SpdyFrameCodec(SpdyVersion version, int maxChunkSize, org.jboss.netty.handler.codec.spdy.SpdyHeaderBlockDecoder spdyHeaderBlockDecoder, org.jboss.netty.handler.codec.spdy.SpdyHeaderBlockEncoder spdyHeaderBlockEncoder)
-
-
Method Detail
-
beforeAdd
public void beforeAdd(ChannelHandlerContext ctx) throws Exception
- Specified by:
beforeAdd
in interfaceLifeCycleAwareChannelHandler
- Overrides:
beforeAdd
in classFrameDecoder
- Throws:
Exception
-
decode
protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception
Description copied from class:FrameDecoder
Decodes the received packets so far into a frame. If an sub-class wants to extract a frame out of the buffer it should use theFrameDecoder.extractFrame(ChannelBuffer, int, int)
method, to make optimizations easier later.- Specified by:
decode
in classFrameDecoder
- Parameters:
ctx
- the context of this handlerchannel
- the current channelbuffer
- the cumulative buffer of received packets so far. Note that the buffer might be empty, which means you should not make an assumption that the buffer contains at least one byte in your decoder implementation.- Returns:
- the decoded frame if a full frame was received and decoded.
null
if there's not enough data in the buffer to decode a frame. - Throws:
Exception
-
cleanup
protected void cleanup(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception
Description copied from class:FrameDecoder
Gets called onFrameDecoder.channelDisconnected(ChannelHandlerContext, ChannelStateEvent)
andFrameDecoder.channelClosed(ChannelHandlerContext, ChannelStateEvent)
- Overrides:
cleanup
in classFrameDecoder
- Throws:
Exception
-
handleDownstream
public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent evt) throws Exception
Description copied from interface:ChannelDownstreamHandler
Handles the specified downstream event.- Specified by:
handleDownstream
in interfaceChannelDownstreamHandler
- Parameters:
ctx
- the context object for this handlerevt
- the downstream event to process or intercept- Throws:
Exception
-
readDataFrame
public void readDataFrame(int streamId, boolean last, ChannelBuffer data)
Description copied from interface:SpdyFrameDecoderDelegate
Called when a DATA frame is received.- Specified by:
readDataFrame
in interfaceSpdyFrameDecoderDelegate
-
readSynStreamFrame
public void readSynStreamFrame(int streamId, int associatedToStreamId, byte priority, boolean last, boolean unidirectional)
Description copied from interface:SpdyFrameDecoderDelegate
Called when a SYN_STREAM frame is received. The Name/Value Header Block is not included. See readHeaderBlock().- Specified by:
readSynStreamFrame
in interfaceSpdyFrameDecoderDelegate
-
readSynReplyFrame
public void readSynReplyFrame(int streamId, boolean last)
Description copied from interface:SpdyFrameDecoderDelegate
Called when a SYN_REPLY frame is received. The Name/Value Header Block is not included. See readHeaderBlock().- Specified by:
readSynReplyFrame
in interfaceSpdyFrameDecoderDelegate
-
readRstStreamFrame
public void readRstStreamFrame(int streamId, int statusCode)
Description copied from interface:SpdyFrameDecoderDelegate
Called when a RST_STREAM frame is received.- Specified by:
readRstStreamFrame
in interfaceSpdyFrameDecoderDelegate
-
readSettingsFrame
public void readSettingsFrame(boolean clearPersisted)
Description copied from interface:SpdyFrameDecoderDelegate
Called when a SETTINGS frame is received. Settings are not included. See readSetting().- Specified by:
readSettingsFrame
in interfaceSpdyFrameDecoderDelegate
-
readSetting
public void readSetting(int id, int value, boolean persistValue, boolean persisted)
Description copied from interface:SpdyFrameDecoderDelegate
Called when an individual setting within a SETTINGS frame is received.- Specified by:
readSetting
in interfaceSpdyFrameDecoderDelegate
-
readSettingsEnd
public void readSettingsEnd()
Description copied from interface:SpdyFrameDecoderDelegate
Called when the entire SETTINGS frame has been received.- Specified by:
readSettingsEnd
in interfaceSpdyFrameDecoderDelegate
-
readPingFrame
public void readPingFrame(int id)
Description copied from interface:SpdyFrameDecoderDelegate
Called when a PING frame is received.- Specified by:
readPingFrame
in interfaceSpdyFrameDecoderDelegate
-
readGoAwayFrame
public void readGoAwayFrame(int lastGoodStreamId, int statusCode)
Description copied from interface:SpdyFrameDecoderDelegate
Called when a GOAWAY frame is received.- Specified by:
readGoAwayFrame
in interfaceSpdyFrameDecoderDelegate
-
readHeadersFrame
public void readHeadersFrame(int streamId, boolean last)
Description copied from interface:SpdyFrameDecoderDelegate
Called when a HEADERS frame is received. The Name/Value Header Block is not included. See readHeaderBlock().- Specified by:
readHeadersFrame
in interfaceSpdyFrameDecoderDelegate
-
readWindowUpdateFrame
public void readWindowUpdateFrame(int streamId, int deltaWindowSize)
Description copied from interface:SpdyFrameDecoderDelegate
Called when a WINDOW_UPDATE frame is received.- Specified by:
readWindowUpdateFrame
in interfaceSpdyFrameDecoderDelegate
-
readHeaderBlock
public void readHeaderBlock(ChannelBuffer headerBlock)
Description copied from interface:SpdyFrameDecoderDelegate
Called when the header block within a SYN_STREAM, SYN_REPLY, or HEADERS frame is received.- Specified by:
readHeaderBlock
in interfaceSpdyFrameDecoderDelegate
-
readHeaderBlockEnd
public void readHeaderBlockEnd()
Description copied from interface:SpdyFrameDecoderDelegate
Called when an entire header block has been received.- Specified by:
readHeaderBlockEnd
in interfaceSpdyFrameDecoderDelegate
-
readFrameError
public void readFrameError(String message)
Description copied from interface:SpdyFrameDecoderDelegate
Called when an unrecoverable session error has occurred.- Specified by:
readFrameError
in interfaceSpdyFrameDecoderDelegate
-
-