Inheritance: OscPacket
Ejemplo n.º 1
0
        // To prevent "ExecutionEngineException: Attempting to JIT compile method" error on iOS we use a non-generic method version.
        public override int Append(object value)
        {
            if (!(value is OscPacket))
            {
                throw new ArgumentException();
            }

            OscBundle nestedBundle = value as OscBundle;

            if (nestedBundle != null)
            {
                if (nestedBundle.timeStamp < timeStamp)
                {
                    throw new Exception("Nested bundle's timestamp must be >= than parent bundle's timestamp.");
                }
            }

            data.Add(value);

            return(data.Count - 1);
        }
Ejemplo n.º 2
0
        public static new OscBundle FromByteArray(byte[] data, ref int start, int end)
        {
            string address = ValueFromByteArray <string>(data, ref start);

            if (address != BUNDLE_PREFIX)
            {
                throw new ArgumentException();
            }

            OscTimeTag timeStamp = ValueFromByteArray <OscTimeTag>(data, ref start);
            OscBundle  bundle    = new OscBundle(timeStamp);

            while (start < end)
            {
                int length    = ValueFromByteArray <int>(data, ref start);
                int packetEnd = start + length;
                bundle.Append(OscPacket.FromByteArray(data, ref start, packetEnd));
            }

            return(bundle);
        }
Ejemplo n.º 3
0
 public OscBundleReceivedEventArgs(OscBundle bundle)
 {
     Bundle = bundle;
 }
Ejemplo n.º 4
0
        public static new OscBundle FromByteArray(byte[] data, ref int start, int end)
        {
            string address = ValueFromByteArray<string>(data, ref start);
            if (address != BUNDLE_PREFIX) throw new ArgumentException();

            OscTimeTag timeStamp = ValueFromByteArray<OscTimeTag>(data, ref start);
            OscBundle bundle = new OscBundle(timeStamp);

            while (start < end)
            {
                int length = ValueFromByteArray<int>(data, ref start);
                int packetEnd = start + length;
                bundle.Append(OscPacket.FromByteArray(data, ref start, packetEnd));
            }

            return bundle;
        }
Ejemplo n.º 5
0
        private void onBundleReceived(OscBundle bundle)
        {
            if (BundleReceived != null) BundleReceived(this, new OscBundleReceivedEventArgs(bundle));

            var count = bundle.Data.Count;
            for (var i = 0; i < count; i++)
            {
                object value = bundle.Data[i];
                if (value is OscBundle)
                {
                    // Raise events for nested bundles
                    onBundleReceived((OscBundle)value);
                } else if (value is OscMessage)
                {
                    // Raised events for contained messages
                    OscMessage message = (OscMessage)value;
                    onMessageReceived(message);
                }
            }
        }