Esempio n. 1
0
        /**
         * Sets the remote end point for the Peer to communicate with
         * @param ipAddress the string remote end point
         */
        internal void SetRemoteEndpoint(string ipAddress)
        {
            this.remoteIp   = ipAddress;
            this.remotePort = StateListener.OSC_PORT_NUMBER;

            ShutdownTransmitter();
            this.stateTransmitter = new OscTransmitter(this.remoteIp, this.remotePort);
        }
Esempio n. 2
0
        /**
         * Overwrites the Awake method in ServerConnection.
         * Starts the connection interface and load/parse Info.plist
         *
         * @see Esc.GameInterface
         */
        public new void Awake()
        {
            gamesList = new Dictionary <string, string>();

            GameInterface.startLauncherInterface();
            GameInterface.setHidden();

            this.oscTransmitter = new OscTransmitter(MEDIALON_ENDPOINT_IP, MEDIALON_ENDPOINT_PORT);
        }
Esempio n. 3
0
        private bool ShutdownTransmitter()
        {
            bool shutdown = (null != this.stateTransmitter);

            if (shutdown)
            {
                this.stateTransmitter.Close();
                this.stateTransmitter = null;
            }

            return(shutdown);
        }
Esempio n. 4
0
        private void toolStripButtonConnect_Click(object sender, EventArgs e)
        {
            // Remove old wax manager
            if (waxManager != null)
            {
                waxManager.Dispose();
                waxManager = null;
            }

            if (!toolStripButtonConnect.Checked)
            {
                // Find port name
                if (PortName.Length != 0)
                {
                    string port = FindPort(PortName);
                    if (port != null)
                    {
                        PortName = port;
                    }
                }

                waxManager = new WaxManager();

                if (PortName.Length > 0)
                {
                    // Create WAX manager
                    try
                    {
                        string initiallySend = null;
                        if (checkBoxSetMode.Checked)
                        {
                            // Set SLIP mode... [0=NONE,1=SLIP,2=TEXT,3=OSC]
                            initiallySend = "\r\nMODE=1\r\n";
                        }
                        waxManager.AddPacketSource(new SlipSource <WaxPacket>(waxManager.WaxPacketConverter, SlipSource <WaxPacket> .OpenSerialPort(PortName, initiallySend)));
                        if (checkBoxBroadcast.Checked)
                        {
                            waxManager.AddPacketDest(new StompDest <WaxPacket>(waxManager.WaxPacketConverter, "localhost"));
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, "Error: " + ex.Message, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    //MessageBox.Show(this, "Error: Port not specified.", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    waxManager.AddPacketSource(new StompSource <WaxPacket>(waxManager.WaxPacketConverter, "localhost"));
                    if (OscReceive)
                    {
                        waxManager.AddPacketSource(new OscSource <WaxPacket>(waxManager.WaxPacketConverter, "localhost:" + OscPort + "/wax"));
                    }
                }



                if (waxManager != null)
                {
                    // Set log file
                    string file = LogFile;
                    if (file != null && file.Length > 0)
                    {
                        DateTime now  = DateTime.Now;
                        string   date = now.ToString(@"yyyy-MM-dd");
                        string   time = now.ToString(@"HH-mm-ss");
                        file = file.Replace("{date}", date);
                        file = file.Replace("{time}", time);
                        waxManager.AddPacketDest(new LogDest <WaxPacket>(waxManager.WaxPacketConverter, new StreamWriter(new FileStream(file, FileMode.Append))));
                    }

                    // Set WAX OSC transmission
                    if (OscHost != null && OscHost.Length > 0 && OscPort > 0)
                    {
                        OscTransmitter tinyOscTransmitter = new OscTransmitter(OscHost, OscPort);
                        waxManager.ReceivedPacket += (s, ea) =>
                        {
                            try
                            {
                                WaxSample[]  samples  = ea.Packet.Samples;
                                OscMessage[] messages = new OscMessage[samples.Length];
                                for (int i = 0; i < samples.Length; i++)
                                {
                                    messages[i] = new OscMessage("/wax", (int)ea.Packet.DeviceId, samples[i].Index, samples[i].X / 256.0f, samples[i].Y / 256.0f, samples[i].Z / 256.0f);
                                }
                                OscBundle bundle = new OscBundle(OscBundle.TIMESTAMP_NOW, messages);
                                tinyOscTransmitter.Send(bundle);
                            }
                            catch (Exception ex)
                            {
                                Console.Error.WriteLine("ERROR: Problem sending OSC packet - " + ex.Message);
                            }
                        };
                    }
                }

                // Set History panel to use WAX manager
                historyPanel.WaxManager = waxManager;

                // Update connection button
                toolStripButtonConnect.Checked = (waxManager != null);
            }
            else
            {
                // Update connection button
                toolStripButtonConnect.Checked = false;
            }

            // Update tool bar status
            bool connected = toolStripButtonConnect.Checked;

            toolStripLabelPort.Enabled        = !connected;
            toolStripComboBoxPort.Enabled     = !connected;
            toolStripLabelFile.Enabled        = !connected;
            toolStripTextBoxLogFile.Enabled   = !connected;
            toolStripButtonChooseFile.Enabled = !connected;
            // ...
        }