At construction, the passed message is first appended to the WriteBuffer object passed to CreateAsync. Afterwards, when data is written to this stream then it is first encoded and the encoded form is then appended to the WriteBuffer object.
Caution: DisposeAsync must be called in the end.
If necessary, the message plus payload is automatically partitioned into multiple packets such that the unencoded length of each packet does not exceed 1024 bytes.