Unpack() public static method

public static Unpack ( byte bytes ) : OSCPacket
bytes byte
return OSCPacket
Example #1
0
        public static new OSCBundle Unpack(byte[] bytes, ref int start, int end)
        {
            OSCBundle bundle = new OSCBundle();

            string address = unpackString(bytes, ref start);

            if (!address.Equals(BUNDLE))
            {
                return(null);                                    // TODO
            }
            long time = unpackLong(bytes, ref start);

            while (start < end)
            {
                int subEnd = unpackInt(bytes, ref start);
                bundle.Append(OSCPacket.Unpack(bytes, ref start, subEnd));
            }


            return(bundle);
        }
Example #2
0
        public static new OSCBundle Unpack(byte[] bytes, ref int start, int end)
        {
            string address = unpackString(bytes, ref start);

            //Console.WriteLine("bundle: " + address);
            if (!address.Equals(BUNDLE))
            {
                return(null);                                    // TODO
            }
            long      timestamp = unpackLong(bytes, ref start);
            OSCBundle bundle    = new OSCBundle(timestamp);

            while (start < end)
            {
                int length  = unpackInt(bytes, ref start);
                int sub_end = start + length;
                //Console.WriteLine(bytes.Length +" "+ start+" "+length+" "+sub_end);
                bundle.Append(OSCPacket.Unpack(bytes, ref start, sub_end));
            }

            return(bundle);
        }
Example #3
0
        /// <summary>
        /// EndReceive paired call.
        /// </summary>
        /// <param name="asyncResult">Paired result object from the BeginReceive call.</param>
        private void EndReceive(IAsyncResult asyncResult)
        {
            try
            {
                UdpState   udpState   = (UdpState)asyncResult.AsyncState;
                UdpClient  udpClient  = udpState.Client;
                IPEndPoint ipEndPoint = udpState.IPEndPoint;

                byte[] data = udpClient.EndReceive(asyncResult, ref ipEndPoint);
                if (data != null && data.Length > 0)
                {
                    if (cb != null)
                    {
                        cb(OSCPacket.Unpack(data));
                    }
                }
                udpClient.BeginReceive(mAsyncCallback, udpState);
            }
            catch (ObjectDisposedException)
            {
                // Suppress error
            }
        }