public int Send(OscPacket packet)
        {
            int byteNum = 0;

            byte[] data = packet.BinaryData;
            try
            {
                byteNum = this.udpClient.Send(data, data.Length);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.Message);
                Console.Error.WriteLine(e.StackTrace);
            }

            return(byteNum);
        }
        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);
        }
Esempio n. 3
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);
        }