IMessageReader

Handler for reading messages


struct IMessageReader
{
    virtual void ReleaseReader() = 0;
    virtual OsErrorCode ReadMessage(const octet_t* payload, ssize_t payloadSize, MessageId id) = 0;
};


void ReleaseReader()

Called from the implementation of Close() on the MultiplexedMsgConnection Guaranteed to be called exactly once and after every other method in this interface. Therefore this is a good opportunity to delete this IMessageReader


OsErrorCode ReadMessage(const octet_t* payload, ssize_t payloadSize, MessageId id)

Deserialise and process a single message stored in a contiguous buffer in memory.

'payload' points at the the payload of the message (i.e. not including the message size or the MessageId). It is assumed the MessageId has already been deserialised and the offset subtracted away so that it is in the range [0,n) where n is returned by a call to GetNumMessages()

'payloadSize' is the size of the message payload in bytes.

Note that if payloadSize == 0 then payload might be nullptr.

Return OEC_ok to indicate that the message was read successfully. Otherwise indicate a fatal error with reading from the stream.

Must not throw an exception.