Esempio n. 1
0
 public static OSCPacket Unpack(byte[] bytes, ref int start, int end)
 {
     if (bytes[start] == '#')
     {
         return(OSCBundle.Unpack(bytes, ref start, end));
     }
     else
     {
         return(OSCMessage.Unpack(bytes, ref start));
     }
 }
Esempio n. 2
0
        public static Dictionary<int, Tuio2DCursor> GetCursors(OSCBundle pack)
        {
            Dictionary<int, Tuio2DCursor> result = new Dictionary<int, Tuio2DCursor>();

            List<OSCMessage> cursors = FindByCommand(pack, "/tuio/2Dcur", "set");
            foreach (OSCMessage msg in cursors)
            {
                Tuio2DCursor cur = new Tuio2DCursor(msg);
                result.Add(cur.SessionID, cur);
            }
            return result;
        }
Esempio n. 3
0
        public static int GetSequenceNumber(OSCBundle pack)
        {
            int result = -1;

            List<OSCMessage> msgs = FindByCommand(pack, "/tuio/2Dcur","fseq");
            if (msgs.Count > 0)
            {
                result = Convert.ToInt32((int)msgs[0].Values[1]);
            }

            return result;
        }
Esempio n. 4
0
        public static List<int> GetAliveCursors(OSCBundle pack)
        {
            List<int> result = new List<int>();

            List<OSCMessage> alivecmd = FindByCommand(pack, "/tuio/2Dcur", "alive");
            if (alivecmd.Count > 0)
            {
                for (int i = 1; i < alivecmd[0].Values.Count; i++)
                {
                    int id = (int)alivecmd[0].Values[i];
                    result.Add(id);

                }
            }

            return result;
        }
Esempio n. 5
0
 static List<OSCMessage> FindByCommand(OSCBundle bundle, string address, string cmd)
 {
     List<OSCMessage> result = new List<OSCMessage>();
     foreach (object o in bundle.Values)
     {
         OSCMessage msg = (OSCMessage)o;
         if (msg.Address == address)
         {
             if (msg.Values.Count > 0)
             {
                 if (msg.Values[0].ToString() == cmd)
                 {
                     result.Add(msg);
                 }
             }
         }
     }
     return result;
 }
Esempio n. 6
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);
        }
Esempio n. 7
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;
		}