Class Frame.
This is the base class of arbitrary frames that can be easily sent and received with the help of FrameEndpoint entities. The serializer and deserializer methods are purely virtual and have to be implemented in the derived class. Besides that, all members, getters and setters related to the specific fields of a user-defined frame also have to be provided in the derived class.
Thus, if creating a derived frame for a specific frame, one solely has to concentrate on the relevant stuff:
- which data has to be communicated via this frame (members) and
- how are the data arranged in the frame, i.e., the frame format, by specifying the serializer and deserializer.
- All sending / receiving / creation of incoming frames entities is performed "under the hood" by a FrameEndpoint entity.
Definition at line 59 of file Frame.h.
size_t Frame::BytesNeeded |
( |
| ) |
const |
|
inline |
Query the amount of outstanding data during reception for frame assembly.
This method is called by a FrameEndpoint entity in the phase of reception. It is used to query the amount of bytes that are required to assemble a full frame of the specific type by reading from a TCP socket. Depending on the internal structure of a frame it is possible that it read in multiple stages, e.g., if at first a length field of a known length has to be read followed by the remainder containing a dynamic amount of bytes. Such a logic has to be implemented in the Deserialize() method of the derived class.
- Returns
- size_t the amount subsequent bytes required to assemble the frame
Definition at line 91 of file Frame.h.
bool Frame::ParseBytes |
( |
const unsigned char * |
a_ReadBuffer, |
|
|
size_t & |
a_ReadBufferOffset, |
|
|
size_t & |
a_BytesAvailable |
|
) |
| |
|
inline |
Deliver a chunk of received bytes in the phase of deserialization.
This method is called by a FrameEndpoint entity in the phase of reception. Here, a chunk of data is copied to an internal buffer for later evaluation within the Deserialze() method. The Deserialize() method is called automatically if the required amount of bytes is available.
- Parameters
-
a_ReadBuffer | the incoming buffer of bytes containing the raw byte stream read from the TCP socket |
a_ReadBufferOffset | the read offset within the provided incoming byte buffer to start with |
a_BytesAvailable | the remaining amount of bytes in the read buffer to evaluate |
- Return values
-
true | no error occured |
false | a protocol violation was detected. The stream is invalid now and the TCP socket must be closed |
- Returns
- Indicates success or failure of parsing the provided chunk of bytes
Definition at line 107 of file Frame.h.