示例#1
0
 public OSCServer(int port)
 {
     AddressOnMessageReceived = new Dictionary <string, EventHandler <OSCMessageReceivedArgs> >();
     client = new UdpClient(port);
     Task.Factory.StartNew(async() =>
     {
         while (client != null)
         {
             while (client.Available == 0)
             {
                 await Task.Delay(10);
             }
             UdpReceiveResult result = await client.ReceiveAsync();
             OSCPacket packet        = OSCPacket.Parse(result.Buffer);
             if (packet is OSCBundle)
             {
                 OSCBundle bundle = packet as OSCBundle;
                 OnBundleReceived(bundle);
             }
             else
             {
                 OSCMessage message = packet as OSCMessage;
                 OnMessageReceived(message);
             }
         }
     });
 }
示例#2
0
        public static new OSCBundle Parse(BinaryReader reader)
        {
            OSCString  bundleString = OSCString.Parse(reader);
            OSCTimeTag timeTag      = OSCTimeTag.Parse(reader);

            List <OSCPacket> contents = new List <OSCPacket>();

            while (reader.BaseStream.Position < reader.BaseStream.Length)
            {
                OSCInt    size   = OSCInt.Parse(reader);
                OSCPacket packet = OSCPacket.Parse(reader);
                contents.Add(packet);
            }

            return(new OSCBundle(timeTag.Contents, contents));
        }