예제 #1
0
        public OscPacket Receive()
        {
            try
            {
                IPEndPoint ip    = null;
                byte[]     bytes = this.udpClient.Receive(ref ip);
                if (bytes != null && bytes.Length > 0)
                {
                    return(OscPacket.Unpack(bytes));
                }
            } catch (Exception e) {
                Console.WriteLine(e.Message);
                return(null);
            }

            return(null);
        }
예제 #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);
        }