Example #1
0
        protected void onWaitMessages()
        {
            workerRunning = true;
            while (workerRunning)
            {
                bool rd = false;
                for (int k = 0; k < oscTypes.NUM_SCENES; k++)
                {
                    OSCMsg msg = new OSCMsg();
                    if (ipc.Read(k, ref msg))
                    {
                        rd = true;
                        sendToOsc(ref msg);
                    }

                    if (!workerRunning)
                    {
                        break;
                    }
                }
                if (!rd && workerRunning)
                {
                    Thread.Sleep(20);
                }
            }
        }
Example #2
0
        private void sendToOsc(ref OSCMsg msg)
        {
            string     addr        = new string(msg.address).Replace("\0", "");
            string     realAddress = $"/scene{msg.scene}{addr}";
            OscMessage oscmsg      = new OscMessage(realAddress, msg.value);

#if DEBUG
            System.Diagnostics.Debug.WriteLine($"from cli {oscmsg.Address}");
            foreach (object par in oscmsg.Arguments)
            {
                System.Diagnostics.Debug.WriteLine($"  arg: {par.ToString()}");
            }
#endif
            oscSrv.Write(oscmsg);
        }
Example #3
0
        public void FromBytes(byte[] fromBytes)
        {
            IntPtr ptr = Marshal.AllocHGlobal(Size);

            Marshal.Copy(fromBytes, 0, ptr, Size);
            OSCMsg tmp = (OSCMsg)Marshal.PtrToStructure(ptr, typeof(OSCMsg));

            scene   = tmp.scene;
            address = new char[40];
            for (int k = 0; k < 40; k++)
            {
                address[k] = tmp.address[k];
            }
            value = tmp.value;
            Marshal.FreeHGlobal(ptr);
        }