コード例 #1
0
        private void connect_Click(object sender, EventArgs e)
        {
            TreelistView.Node node = hosts.SelectedNode;
            if (node == null)
            {
                return;
            }

            if (node.Tag is RemoteConnect)
            {
                ConnectToApp(node);
            }
            else if (node.Tag is RemoteHost)
            {
                RemoteHost host = node.Tag as RemoteHost;

                if (host.ServerRunning)
                {
                    DialogResult res = MessageBox.Show(String.Format("Are you sure you wish to shut down running remote server on {0}?", host.Hostname),
                                                       "Remote server shutdown", MessageBoxButtons.YesNoCancel);

                    if (res == DialogResult.Cancel || res == DialogResult.No)
                    {
                        return;
                    }

                    // shut down
                    try
                    {
                        RemoteServer server = StaticExports.CreateRemoteServer(host.Hostname, 0);
                        server.ShutdownServerAndConnection();
                        hosts.BeginUpdate();
                        SetRemoteServerLive(node, false, false);
                        hosts.EndUpdate();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error shutting down remote server", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    updateConnectButton();
                }
                else
                {
                    // try to run
                    refreshOne.Enabled = refreshAll.Enabled = false;

                    Thread th = Helpers.NewThread(new ParameterizedThreadStart(RunRemoteServer));
                    th.Start(node);

                    UpdateLookupsStatus();
                }
            }
        }
コード例 #2
0
ファイル: RenderManager.cs プロジェクト: krig/renderdoc
        public void ConnectToRemoteServer(RemoteHost host)
        {
            InitException = null;

            try
            {
                m_Remote               = StaticExports.CreateRemoteServer(host.Hostname, 0);
                m_RemoteHost           = host;
                m_RemoteHost.Connected = true;
            }
            catch (ReplayCreateException ex)
            {
                InitException = ex;
            }
        }
コード例 #3
0
        public void CheckStatus()
        {
            // special case - this is the local context
            if (Hostname == "localhost")
            {
                ServerRunning   = false;
                VersionMismatch = Busy = false;
                return;
            }

            try
            {
                RemoteServer server = StaticExports.CreateRemoteServer(Hostname, 0);
                ServerRunning   = true;
                VersionMismatch = Busy = false;
                server.ShutdownConnection();

                // since we can only have one active client at once on a remote server, we need
                // to avoid DDOS'ing by doing multiple CheckStatus() one after the other so fast
                // that the active client can't be properly shut down. Sleeping here for a short
                // time gives that breathing room.
                // Not the most elegant solution, but it is simple

                Thread.Sleep(15);
            }
            catch (ReplayCreateException ex)
            {
                if (ex.Status == ReplayCreateStatus.NetworkRemoteBusy)
                {
                    ServerRunning = true;
                    Busy          = true;
                }
                else if (ex.Status == ReplayCreateStatus.NetworkVersionMismatch)
                {
                    ServerRunning   = true;
                    Busy            = true;
                    VersionMismatch = true;
                }
                else
                {
                    ServerRunning = false;
                    Busy          = false;
                }
            }
        }