NetSendData() custom data/messages

On 10/11/2015 at 14:53, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   16 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------
Is it possible to send custom messages with NetSendData()? It seems like when I pass my own plugin
ID, I always get MESSAGERESULT_UNKNOWN error and the message is not sent to the TR server. Small
example:

struct NetRenderMsgVbGi
{
  UInt size;
  Bool compute, wait;
};
  
NetRenderBuffer msg, result;
msg.id = MSG_NETRENDER_VB_GI;
msg.job = vps->net->_renderJob->GetUuid();
msg.size = 0;  
msg.data = nullptr;
  
MESSAGERESULT res = NetSendData(
  vps->net->_service, vps->net->_renderJob->GetServerUuid(), &msg, &result, vps->thread);

Thanks in advance,
-Niklas

On 11/11/2015 at 02:30, xxxxxxxx wrote:

Hello,

using R17 I have no problems using this code to send a message:

  
Int32* payload = NewObjClear(Int32, 1);  
*payload = 123;  
  
// prepare message  
NetRenderBuffer requestMessage;  
requestMessage.id                        = MSG_CUSTOM;  
requestMessage.job                    = data->_vps->net->_renderJob->GetUuid();  
requestMessage.size                    = SIZEOF(Int32);  
requestMessage.data                    = payload;  
  
NetRenderBuffer requestResult;  
requestResult.id                    = MSG_CUSTOM;  
requestResult.job                    = data->_vps->net->_renderJob->GetUuid();  
requestResult.size                = 0;  
requestResult.data                = nullptr;  
  
NetSendData(data->_vps->net->_service, data->_vps->net->_renderJob->GetServerUuid(), &requestMessage, &requestResult, data->_vps->thread);  
  
if(requestResult.data)  
{  
 Int32* res = (Int32* )requestResult.data;  
 GePrint("Got data from server: " + String::IntToString(*res));  
}  

best wishes,
Sebastian

On 11/11/2015 at 03:29, xxxxxxxx wrote:

Hi Sebastian, thanks for the example. Seems like you really need a payload, it doesn't work without here
in R16. Strangely, it works without payload for sending standard Net messages (eg. MSG_NETRENDER_BUCKET_INFO or ~_INDEX).

One thing I'm still wondering about though is about byte order. Won't there be issues with
machines that communicate with this interface and use a different byte order?

Thanks,
-Niklas

On 13/11/2015 at 00:25, xxxxxxxx wrote:

Hello,

according to the developers, you are responsible for the endianess of the data chunk stored in NetRenderBuffer::data.

Best wishes,
Sebastian