4.Maintaining the past send-receive operation method

If you have the previously made send-receive operation method (4.1 Example of program not using RMI) to ProudNet, we recommend you to switch to RMI. This prevents making any errors in making send-receive routine from the root and makes your life easier in development.

하지만 과거의 송수신 처리 방식을 굳이 필요한 경우를 위해 ProudNet은 대안을 제시하고 있습니다.

4.1Exchanging user-defined message without using RMI at all

Transmitting user-defined message without using 4. Remote Method Invocation can be done by the use of following functions.

Proud.CNetClient.SendUserMessage

Proud.CNetServer.SendUserMessage

• Proud.CLanClient.SendUserMessage

• Proud.CLanServer.SendUserMessage

Reception of user-defined message can be callback by the following functions.

Proud.INetClientEvent.OnReceiveUserMessage

Proud.INetServerEvent.OnReceiveUserMessage

• Proud.ILanClientEvent.OnReceiveUserMessage

• Proud.ILanServerEvent.OnReceiveUserMessage

4.2Send - receive user - defined message with RMI parameter

In ProudNet, you can use Proud.ByteArray type as RMI parameter.Which means you can send / receive memory block through RMI parameter as shown in below.

Foo([in] Proud::ByteArray something);

By utilizing this, you can use the previously made send - receive operation routine.

// Create a message object
Proud::CMessage msg;

/* If user hasn't assigned any buffer for user-defined message, UseInternalBuffer must be called to activate << operator.
UseInternalBuffer only works when a message object isn't assigned with any buffer.
Thus if buffer is already assigned, this method must not be called.
Please refer to Proud.CMessage.UseInternalBuffer for more details. */
msg.UseInternalBuffer();

msg << a << b;

Proud::ByteArray block;
block.SetCount(msg.GetLength());
memcpy(block.GetData(), msg.GetData(), block.Count);

Foo(Proud::HostID_Server, Proud::RmiContext::ReliableSend, block);
DEFRMI_MyPIDL_Foo(MyClass)
{
    // Parameter 'block' and the others are is given
    Proud::CMessage msg;
    msg.UseExternalBuffer(block.GetData(), block.Count);
    msg.SetLength(block.Count);
    msg >> a >> b;
    ...
}