コード例 #1
0
        /// <summary>
        /// Serialize the packet.
        /// </summary>
        /// <returns>The newly serialized packet.</returns>
        public override byte[] ToByteArray()
        {
            List <byte> data = new List <byte>();

            data.AddRange(OscPacket.ValueToByteArray(mAddress));
            OscPacket.PadNull(data);

            data.AddRange(OscPacket.ValueToByteArray(mTypeTag));
            OscPacket.PadNull(data);

            foreach (object value in mData)
            {
                byte[] bytes = OscPacket.ValueToByteArray(value);
                if (bytes != null)
                {
                    data.AddRange(bytes);
                    if (value is string || value is byte[])
                    {
                        OscPacket.PadNull(data);
                    }
                }
            }

            return(data.ToArray());
        }
コード例 #2
0
        /// <summary>
        /// Serialize the packet.
        /// </summary>
        /// <returns>The newly serialized packet.</returns>
        public override byte[] ToByteArray()
        {
            List <byte> data = new List <byte>();

            data.AddRange(OscPacket.ValueToByteArray(mAddress));
            OscPacket.PadNull(data);

            data.AddRange(OscPacket.ValueToByteArray(mTimeStamp));

            foreach (object value in mData)
            {
                if ((value is OscPacket) && (value is OscBundle == false))
                {
                    byte[] packetBytes = ((OscPacket)value).ToByteArray();
                    data.AddRange(OscPacket.ValueToByteArray(packetBytes.Length));
                    data.AddRange(packetBytes);
                }
            }

            return(data.ToArray());
        }