Message Object(Proud.CMessage)

ProudNet uses Proud.CMessage object type to handle a message object.In normal cases of using Remote Method Invocation, you won't even need to bother yourself using Proud.CMessage

Proud.CMessage is a high performance data stream object.Through data stream, user can save various data into one data block or call them at a finger - tip.

Proud.CMessage refers to memory buffer.The memory buffer can turn into an internal memory block(called internal buffer) owned by Proud.CMessage object and can refer to another memory block(called external buffer) since it is not directly owned by Proud.CMessage. To handle Proud.CMessage object, you need to assign which memory buffer the Proud.CMessage object will use through Proud.CMessage.UseInternalBuffer or Proud.CMessage.UseExternalBuffer. When a memory buffer is assigned and you want it to refer to another memory buffer, you must initialize the memory buffer in use first.Initialization can be done by Proud.CMessage.UninitBuffer.The sample for assigning a memory buffer can be found at Selecting a message buffer.

In normal circumstances, you can use an internal buffer but it is much effective and fast if you set to read messages as directly referring to the memory block storing those messages rather then read after Proud.CMessage object separately copies them over.This is the case where you can utilize an external buffer.

In case of Proud.CMessage using internal buffer, the maximum size of message is Proud.CNetConfig.MessageMaxLength. In another hand of using external buffer, its maximum size is limited to the size of buffer itself.You can assign the length limit of message by Proud.CMessage.SetCount. You can also write or read data on message object via Proud.CMessage.Write or Proud.CMessage.Read.Because a message object is a data stream, its size stretches out as more data is written.Inside Proud.CMessage, there is a read offset which its value gets increased when data is being read.You can override this offset with Proud.CMessage.SetReadOffset.

message_class.png
Message Object Type