Exemplo n.º 1
0
        static void Main(string[] args)
        {
            m_Listener = new OscAddressManager();

            m_Listener.Attach("/testA", TestMethodA);
            m_Listener.Attach("/testB", TestMethodB);

            m_Receiver = new OscReceiver(IPAddress.IPv6Any, IPAddress.Parse("FF02::2"), 12345);

            m_Sender = new OscSender(IPAddress.Parse("FF02::2"), 12345);

            m_Thread = new Thread(new ThreadStart(ListenLoop));

            Console.WriteLine("Connecting");
            m_Receiver.Connect();
            m_Sender.Connect();
            m_Thread.Start();

            Console.WriteLine();
            Console.WriteLine("Sending message to A");
            Console.WriteLine();

            m_Sender.Send(new OscMessage("/testA", "Hello from sender (test1)"));

            Thread.CurrentThread.Join(100);
            Console.WriteLine();
            Console.WriteLine("Press any key to send the next message");
            Console.ReadKey(true);



            Console.WriteLine();
            Console.WriteLine("Sending message to B");
            Console.WriteLine();

            m_Sender.Send(new OscMessage("/testB", "Hello from sender (test2)"));

            Thread.CurrentThread.Join(100);
            Console.WriteLine();
            Console.WriteLine("Press any key to send the next message");
            Console.ReadKey(true);



            Console.WriteLine();
            Console.WriteLine("Sending message to A and B");
            Console.WriteLine();

            m_Sender.Send(new OscMessage("/*", "Hello from sender (test3)"));

            Thread.CurrentThread.Join(100);
            Console.WriteLine();
            Console.WriteLine("Press any key to exit");
            Console.ReadKey(true);

            Console.WriteLine("Shutting down");
            m_Receiver.Close();
            m_Thread.Join();
            m_Sender.Close();
        }
Exemplo n.º 2
0
 public void OscListenerManagerConstructorTest()
 {
     try
     {
         using (OscAddressManager target = new OscAddressManager())
         {
         }
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }
Exemplo n.º 3
0
        static StaticObjects()
        {
            #region Parsed_Addresses

            Parsed_Addresses = new OscAddress[StaticObjects.Good_AddressPatterns.Length];

            for (int i = 0; i < Parsed_Addresses.Length; i++)
            {
                Parsed_Addresses[i] = new OscAddress(StaticObjects.Good_AddressPatterns[i]);
            }

            #endregion

            #region Parsed_AddressPatternMatches

            Parsed_AddressPatternMatches = new OscAddress[StaticObjects.Good_AddressPatternMatches.Length];

            for (int i = 0; i < Parsed_AddressPatternMatches.Length; i++)
            {
                Parsed_AddressPatternMatches[i] = new OscAddress(StaticObjects.Good_AddressPatternMatches[i]);
            }

            #endregion

            All_Addresses = new string[StaticObjects.Good_AddressPatterns.Length + StaticObjects.Good_AddressPatternMatches.Length];

            for (int i = 0; i < Good_AddressPatterns.Length; i++)
            {
                All_Addresses[i] = StaticObjects.Good_AddressPatterns[i];
            }

            for (int i = 0; i < Good_AddressPatternMatches.Length; i++)
            {
                All_Addresses[StaticObjects.Good_AddressPatterns.Length + i] = StaticObjects.Good_AddressPatternMatches[i];
            }

            Parsed_Messages = new OscMessage[All_Addresses.Length];

            for (int i = 0; i < All_Addresses.Length; i++)
            {
                Parsed_Messages[i] = new OscMessage(StaticObjects.All_Addresses[i]);
            }

            Mananger = new OscAddressManager();

            for (int i = 0; i < Good_AddressPatterns.Length; i++)
            {
                Mananger.Attach(StaticObjects.Good_AddressPatterns[i], DummyMethod);
            }
        }
Exemplo n.º 4
0
        public void AttachTest()
        {
            try
            {
                using (OscAddressManager target = new OscAddressManager())
                {
                    string address = "/test";

                    OscMessageEvent @event = new OscMessageEvent((OscMessage message) => { Debug.WriteLine(message.ToString()); });

                    target.Attach(address, @event);
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
        void PopulateData()
        {
            m_Manager = new OscAddressManager();

            m_Data.Columns.Add("MethodID", typeof(int), null);
            m_Data.Columns.Add("Address", typeof(string), null);
            m_Data.Columns.Add("Count", typeof(int), null);

            for (int j = 0; j < 3; j++)
            {
                for (int i = 0; i < 2; i++)
                {
                    string address = "/test/" + (char)(j + (int)'a') + "/thing_" + i;

                    AddEvent(address);
                }
            }

            AddEvent("/test/*/thing_[0-9]");
            AddEvent("//thing_[0-9]");

            m_DataView.DataSource = m_Data;
        }
Exemplo n.º 6
0
        public void InvokeTest1_Bad()
        {
            try
            {
                using (OscAddressManager target = new OscAddressManager())
                {
                    string          address = "/test";
                    OscMessageEvent @event  = new OscMessageEvent((OscMessage msg) => { Debug.WriteLine(msg.ToString()); });
                    target.Attach(address, @event);

                    OscBundle bundle   = new OscBundle(DateTime.Now, new OscMessage("/foo"));
                    bool      expected = false;
                    bool      actual;

                    actual = target.Invoke(bundle);

                    Assert.AreEqual(expected, actual);
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Exemplo n.º 7
0
        public void InvokeTest_Good()
        {
            try
            {
                using (OscAddressManager target = new OscAddressManager())
                {
                    string          address = "/test";
                    OscMessageEvent @event  = new OscMessageEvent((OscMessage msg) => { Debug.WriteLine(msg.ToString()); });
                    target.Attach(address, @event);

                    OscMessage message  = new OscMessage("/test");
                    bool       expected = true;
                    bool       actual;

                    actual = target.Invoke(message);

                    Assert.AreEqual(expected, actual);
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
        public void Load(string filePath, IReporter reporter = null)
        {
            lock (readWriteLock)
            {
                using (OscFileReader fileReader = new OscFileReader(Helper.ResolvePath(filePath), OscPacketFormat.String))
                    using (OscAddressManager manager = new OscAddressManager())
                    {
                        foreach (ISettingValue value in AllValues)
                        {
                            if (value.IsReadOnly == true)
                            {
                                continue;
                            }

                            manager.Attach(value.OscAddress, value.OnLocalMessage);
                        }

                        fileReader.PacketRecived += delegate(OscPacket packet)
                        {
                            if (packet.Error != OscPacketError.None)
                            {
                                if (reporter != null)
                                {
                                    reporter.OnError(this, new MessageEventArgs(packet.ErrorMessage));
                                }

                                return;
                            }

                            manager.Invoke(packet);
                        };

                        fileReader.ReadToEnd();
                    }
            }
        }
    void Start()
    {
        reciever = new OscReceiver(port);
        reciever.Connect();

        listener = new OscAddressManager();
        foreach(OscRecieveData data in recieveDatas)
        {
            data.value = OscNull.Value;
            data.valueString = data.value.ToString();
            listener.Attach(data.address, OnRecieved);
        }

        thread = new Thread(new ThreadStart(ListenLoop));
        thread.Start();
    }
Exemplo n.º 10
0
 private OscPackageListener()
 {
     OscAddressManager = new OscAddressManager();
     OscAddressManager.UnknownAddress += new EventHandler <UnknownAddressEventArgs>(this.OnUnknownAddress);
 }