Class ConfigurableProtocolConverter
java.lang.Object
com.thecoderscorner.menu.remote.protocol.ConfigurableProtocolConverter
- All Implemented Interfaces:
MenuCommandProtocol
An implementation of the menu command protocol interface that is configurable, by default it can create all the regular
tag value message processors so that regular embedCONTROL messages can be parsed and written. It is also possible to
add extra command handlers for both TagVal protocol and also for binary format.
-
Field Summary
Fields inherited from interface com.thecoderscorner.menu.remote.MenuCommandProtocol
PROTO_END_OF_MSG, PROTO_START_OF_MSG -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRawInProcessor(MessageField field, RawProtocolIncomingMsgConverter processor) This method adds an additional binary message processor that can convert an incoming wire message into a command.<T extends MenuCommand>
voidaddRawOutProcessor(MessageField field, ProtocolOutgoingMsgConverter<T, ByteBuffer> processor, Class<T> clazz) This method adds an addition binary message processor that can convert aMenuCommandinto binary wire format, you must write 4 bytes containing the length first.voidaddTagValInProcessor(MessageField field, TagValProtocolIncomingMsgConverter processor) This method adds an additional tag value message processor that can convert an incoming wire message into a command.<T extends MenuCommand>
voidaddTagValOutProcessor(MessageField field, ProtocolOutgoingMsgConverter<T, StringBuilder> processor, Class<T> clazz) This methods adds an additional tag value message processor that can convert aMenuCommandinto the appropriate wire format for sending.fromChannel(ByteBuffer buffer) Retrieves a message from the channel, or throws an exception if the message is not fully formed.getProtocolForCmd(MenuCommand command) Checks the message and sees which protocol it will be processed with.voidtoChannel(ByteBuffer buffer, MenuCommand cmd) Puts the command specified into the byte buffer, it is assumed that the callee will flip the channel once complete.
-
Constructor Details
-
ConfigurableProtocolConverter
public ConfigurableProtocolConverter(boolean includeDefaultProcessors)
-
-
Method Details
-
fromChannel
Description copied from interface:MenuCommandProtocolRetrieves a message from the channel, or throws an exception if the message is not fully formed. It is assumed that the buffer has been suitably flipped ready for reading- Specified by:
fromChannelin interfaceMenuCommandProtocol- Throws:
IOException