Пример #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 OSCPacket Parse(BinaryReader reader)
 {
     if (reader.PeekChar() == '#')
     {
         // OSC Bundle
         return(OSCBundle.Parse(reader));
     }
     else
     {
         return(OSCMessage.Parse(reader));
     }
 }
Пример #3
0
 private void OnBundleReceived(OSCBundle bundle)
 {
     foreach (OSCPacket packet in bundle.Contents)
     {
         if (packet is OSCBundle)
         {
             OSCBundle subBundle = packet as OSCBundle;
             OnBundleReceived(subBundle);
         }
         else
         {
             OSCMessage message = packet as OSCMessage;
             OnMessageReceived(message);
         }
     }
 }