public class EasyProtocolFormatter extends java.lang.Object implements IProtocolFormatter
// Instantiate protocol formatter.
IProtocolFormatter aFormatter = new EasyProtocolFormatter();
// Provide the protocol formatter into the messaging constructor.
// Note: It can be only TCP or WebSocket messaging.
IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory(aFormatter);
...
// Then use can use the messaging to create channels.
IDuplexOutputChannel anOutputChannel = aMessaging.CreateDuplexOutputChannel("tcp://127.0.0.1:8084/");
...
| Constructor and Description |
|---|
EasyProtocolFormatter()
Constructs the protocol formatter with default little endian encoding.
|
EasyProtocolFormatter(boolean isLittleEndian)
Constructs the protocol formatter with specified endianess.
|
| Modifier and Type | Method and Description |
|---|---|
ProtocolMessage |
decodeMessage(java.io.InputStream readStream)
Decodes message from the stream.
|
ProtocolMessage |
decodeMessage(java.lang.Object readMessage)
Decodes message from the given object.
|
java.lang.Object |
encodeCloseConnectionMessage(java.lang.String responseReceiverId)
Returns null.
|
void |
encodeCloseConnectionMessage(java.lang.String responseReceiverId,
java.io.OutputStream outputSream)
Does nothing.
|
java.lang.Object |
encodeMessage(java.lang.String responseReceiverId,
java.lang.Object message)
Encodes the data message.
|
void |
encodeMessage(java.lang.String responseReceiverId,
java.lang.Object message,
java.io.OutputStream outputSream)
Encodes the data message into the stream.
|
java.lang.Object |
encodeOpenConnectionMessage(java.lang.String responseReceiverId)
Returns null.
|
void |
encodeOpenConnectionMessage(java.lang.String responseReceiverId,
java.io.OutputStream outputSream)
Does nothing.
|
public EasyProtocolFormatter()
public EasyProtocolFormatter(boolean isLittleEndian)
isLittleEndian - true - little endian, false - big endian.public java.lang.Object encodeOpenConnectionMessage(java.lang.String responseReceiverId)
throws java.lang.Exception
encodeOpenConnectionMessage in interface IProtocolFormatterresponseReceiverId - id of the client opening the connection.java.lang.Exceptionpublic void encodeOpenConnectionMessage(java.lang.String responseReceiverId,
java.io.OutputStream outputSream)
throws java.lang.Exception
encodeOpenConnectionMessage in interface IProtocolFormatterresponseReceiverId - id of the client opening the connection.outputSream - output where the encoded open connection message is writtenjava.lang.Exceptionpublic java.lang.Object encodeCloseConnectionMessage(java.lang.String responseReceiverId)
throws java.lang.Exception
encodeCloseConnectionMessage in interface IProtocolFormatterresponseReceiverId - id of the client that wants to disconnect or that will be disconnectedjava.lang.Exceptionpublic void encodeCloseConnectionMessage(java.lang.String responseReceiverId,
java.io.OutputStream outputSream)
throws java.lang.Exception
encodeCloseConnectionMessage in interface IProtocolFormatterresponseReceiverId - id of the client that wants to disconnect or that will be disconnectedoutputSream - output where the encoded close connection message is writtenjava.lang.Exceptionpublic java.lang.Object encodeMessage(java.lang.String responseReceiverId,
java.lang.Object message)
throws java.lang.Exception
IProtocolFormatterencodeMessage in interface IProtocolFormatterresponseReceiverId - client id.message - serialized message to be sent.java.lang.Exceptionpublic void encodeMessage(java.lang.String responseReceiverId,
java.lang.Object message,
java.io.OutputStream outputSream)
throws java.lang.Exception
IProtocolFormatterencodeMessage in interface IProtocolFormatterresponseReceiverId - id of the client that wants to send the message.message - serialized message to be sent.outputSream - output where the encoded message is writtenjava.lang.Exceptionpublic ProtocolMessage decodeMessage(java.lang.Object readMessage)
IProtocolFormatterdecodeMessage in interface IProtocolFormatterreadMessage - reference to the object.public ProtocolMessage decodeMessage(java.io.InputStream readStream)
IProtocolFormatterdecodeMessage in interface IProtocolFormatterreadStream - stream to be read