void SendMessageWithStream(MessageSerializer messageSerializer, Stream stream, Message message) { //Clear the serializer messageSerializer.Clear(); //Prepare the data to send. messageSerializer.Write(TopicName); messageSerializer.SerializeMessageWithLength(message); //Send via the stream. messageSerializer.SendTo(stream); }
public void PopulateSysCommand(MessageSerializer messageSerializer) { messageSerializer.Clear(); // syscommands are sent as: // 4 byte command length, followed by that many bytes of the command // (all command names start with __ to distinguish them from ros topics) messageSerializer.Write(Command); // 4-byte json length, followed by a json string of that length string json = JsonUtility.ToJson(BuildParam()); messageSerializer.WriteUnaligned(json); }