IMessageWriter

Handler for writing messages


struct IMessageWriter
{
    virtual void ReleaseWriter() = 0;
    virtual ssize_t GetNextMessage(MessageId& id) = 0;
    virtual void WritePayload(octet_t* payload, ssize_t payloadSize) = 0;
};


void ReleaseWriter()

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 IMessageWriter


ssize_t GetNextMessage(MessageId& id)

Returns either:

>= 0 The size of the payload of the next message

-1 There is currently no message ready to be sent.

-2 There is no message to be sent, and there never will be

If returns >= 0, then the MessageId must be returned in 'id'. It is assumed the framework will then call WritePayload() to have the payload actually written to a buffer in memory.

'id' must be in [0,numMessages) where numMessages was passed in the call to AddWriter().

Must not throw an exception.


void WritePayload(octet_t* payload, ssize_t payloadSize)

Called immediately after each successful call to GetNextMessage() (i.e. that returns >= 0), in order to write the payload to the given buffer.