MCPcopy Create free account
hub / github.com/DFHack/dfhack / sendRemoteMessage

Function sendRemoteMessage

library/RemoteClient.cpp:351–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349}
350
351bool sendRemoteMessage(CSimpleSocket *socket, int16_t id, const MessageLite *msg, bool size_ready)
352{
353 int size = size_ready ? msg->GetCachedSize() : msg->ByteSize();
354 int fullsz = size + sizeof(RPCMessageHeader);
355
356 uint8_t *data = new uint8_t[fullsz];
357 RPCMessageHeader *hdr = (RPCMessageHeader*)data;
358
359 hdr->id = id;
360 hdr->size = size;
361
362 uint8_t *pstart = data + sizeof(RPCMessageHeader);
363 uint8_t *pend = msg->SerializeWithCachedSizesToArray(pstart);
364 assert((pend - pstart) == size); (void)pend;
365
366 int got = socket->Send(data, fullsz);
367 delete[] data;
368 return (got == fullsz);
369}
370
371command_result RemoteFunctionBase::execute(color_ostream &out,
372 const message_type *input, message_type *output)

Callers 3

executeMethod · 0.85
flush_proxyMethod · 0.85
threadFnMethod · 0.85

Calls 3

GetCachedSizeMethod · 0.80
ByteSizeMethod · 0.45

Tested by

no test coverage detected