public class ProtocolCodecFilter extends IoFilterAdapter
IoFilter which translates binary or protocol specific data into
message objects and vice versa using ProtocolCodecFactory,
ProtocolEncoder, or ProtocolDecoder.IoFilter.NextFilter| 构造器和说明 |
|---|
ProtocolCodecFilter(java.lang.Class<? extends ProtocolEncoder> encoderClass,
java.lang.Class<? extends ProtocolDecoder> decoderClass)
Creates a new instance of ProtocolCodecFilter, without any factory.
|
ProtocolCodecFilter(ProtocolCodecFactory factory)
Creates a new instance of ProtocolCodecFilter, associating a factory
for the creation of the encoder and decoder.
|
ProtocolCodecFilter(ProtocolEncoder encoder,
ProtocolDecoder decoder)
Creates a new instance of ProtocolCodecFilter, without any factory.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
filterWrite(IoFilter.NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest)
Filters
IoSession.write(Object) method invocation. |
ProtocolEncoder |
getEncoder(IoSession session)
Get the encoder instance from a given session.
|
void |
messageReceived(IoFilter.NextFilter nextFilter,
IoSession session,
java.lang.Object message)
Process the incoming message, calling the session decoder.
|
void |
messageSent(IoFilter.NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest)
Filters
IoHandler.messageSent(IoSession,Object) event. |
void |
onPostRemove(IoFilterChain parent,
java.lang.String name,
IoFilter.NextFilter nextFilter)
Invoked after this filter is removed from the specified parent.
|
void |
onPreAdd(IoFilterChain parent,
java.lang.String name,
IoFilter.NextFilter nextFilter)
Invoked before this filter is added to the specified parent.
|
void |
sessionClosed(IoFilter.NextFilter nextFilter,
IoSession session)
Filters
IoHandler.sessionClosed(IoSession) event. |
destroy, exceptionCaught, filterClose, init, inputClosed, onPostAdd, onPreRemove, sessionCreated, sessionIdle, sessionOpened, toStringpublic ProtocolCodecFilter(ProtocolCodecFactory factory)
factory - The associated factorypublic ProtocolCodecFilter(ProtocolEncoder encoder, ProtocolDecoder decoder)
encoder - The class responsible for encoding the messagedecoder - The class responsible for decoding the messagepublic ProtocolCodecFilter(java.lang.Class<? extends ProtocolEncoder> encoderClass, java.lang.Class<? extends ProtocolDecoder> decoderClass)
encoderClass - The class responsible for encoding the messagedecoderClass - The class responsible for decoding the messagepublic ProtocolEncoder getEncoder(IoSession session)
session - The associated session we will get the encoder frompublic void onPreAdd(IoFilterChain parent, java.lang.String name, IoFilter.NextFilter nextFilter) throws java.lang.Exception
IoFilterAdapterIoFilter.init() is invoked.onPreAdd 在接口中 IoFilteronPreAdd 在类中 IoFilterAdapterparent - the parent who called this methodname - the name assigned to this filternextFilter - the IoFilter.NextFilter for this filter. You can reuse
this object until this filter is removed from the chain.java.lang.Exception - If an error occurred while processing the eventpublic void onPostRemove(IoFilterChain parent, java.lang.String name, IoFilter.NextFilter nextFilter) throws java.lang.Exception
IoFilterAdapterIoFilter.destroy() is invoked.onPostRemove 在接口中 IoFilteronPostRemove 在类中 IoFilterAdapterparent - the parent who called this methodname - the name assigned to this filternextFilter - the IoFilter.NextFilter for this filter. You can reuse
this object until this filter is removed from the chain.java.lang.Exception - If an error occurred while processing the eventpublic void messageReceived(IoFilter.NextFilter nextFilter, IoSession session, java.lang.Object message) throws java.lang.Exception
messageReceived 在接口中 IoFiltermessageReceived 在类中 IoFilterAdapternextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventmessage - The received messagejava.lang.Exception - If an error occurred while processing the eventpublic void messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws java.lang.Exception
IoFilterAdapterIoHandler.messageSent(IoSession,Object) event.messageSent 在接口中 IoFiltermessageSent 在类中 IoFilterAdapternextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventwriteRequest - The WriteRequest that contains the sent messagejava.lang.Exception - If an error occurred while processing the eventpublic void filterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws java.lang.Exception
IoFilterAdapterIoSession.write(Object) method invocation.filterWrite 在接口中 IoFilterfilterWrite 在类中 IoFilterAdapternextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has to process this invocationwriteRequest - The WriteRequest to processjava.lang.Exception - If an error occurred while processing the eventpublic void sessionClosed(IoFilter.NextFilter nextFilter, IoSession session) throws java.lang.Exception
IoFilterAdapterIoHandler.sessionClosed(IoSession) event.sessionClosed 在接口中 IoFiltersessionClosed 在类中 IoFilterAdapternextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventjava.lang.Exception - If an error occurred while processing the event