mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-12 21:10:42 +00:00
Check remote server status at startup to pre-populate context chooser
This commit is contained in:
@@ -29,6 +29,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using renderdoc;
|
||||
@@ -44,13 +45,35 @@ namespace renderdocui.Code
|
||||
|
||||
[XmlIgnore]
|
||||
public bool ServerRunning = false;
|
||||
|
||||
[XmlIgnore]
|
||||
public bool Connected = false;
|
||||
|
||||
[XmlIgnore]
|
||||
public bool Busy = false;
|
||||
|
||||
public void CheckStatus()
|
||||
{
|
||||
try
|
||||
{
|
||||
RemoteServer server = StaticExports.CreateRemoteServer(Hostname, 0);
|
||||
ServerRunning = true;
|
||||
Busy = false;
|
||||
server.ShutdownConnection();
|
||||
}
|
||||
catch (ReplayCreateException ex)
|
||||
{
|
||||
if (ex.Status == ReplayCreateStatus.NetworkRemoteBusy)
|
||||
{
|
||||
ServerRunning = true;
|
||||
Busy = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerRunning = false;
|
||||
Busy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Launch()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -170,23 +170,9 @@ namespace renderdocui.Windows.Dialogs
|
||||
|
||||
string hostname = node["hostname"] as string;
|
||||
|
||||
RemoteHost host = node.Tag as RemoteHost;
|
||||
|
||||
string username = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
|
||||
|
||||
try
|
||||
{
|
||||
RemoteServer server = StaticExports.CreateRemoteServer(hostname, 0);
|
||||
SetRemoteServerLive(node, true, false);
|
||||
server.ShutdownConnection();
|
||||
}
|
||||
catch (ReplayCreateException ex)
|
||||
{
|
||||
if (ex.Status == ReplayCreateStatus.NetworkRemoteBusy)
|
||||
SetRemoteServerLive(node, true, true);
|
||||
else
|
||||
SetRemoteServerLive(node, false, false);
|
||||
}
|
||||
(node.Tag as RemoteHost).CheckStatus();
|
||||
|
||||
StaticExports.EnumerateRemoteTargets(hostname, (UInt32 i) => {
|
||||
try
|
||||
|
||||
@@ -175,6 +175,13 @@ namespace renderdocui.Windows
|
||||
|
||||
CheckUpdates();
|
||||
|
||||
Thread remoteStatusThread = Helpers.NewThread(new ThreadStart(() =>
|
||||
{
|
||||
for (int i = 0; i < m_Core.Config.RemoteHosts.Count; i++)
|
||||
m_Core.Config.RemoteHosts[i].CheckStatus();
|
||||
}));
|
||||
remoteStatusThread.Start();
|
||||
|
||||
sendErrorReportToolStripMenuItem.Enabled = OfficialVersion || BetaVersion;
|
||||
|
||||
// create default layout if layout failed to load
|
||||
@@ -912,13 +919,13 @@ namespace renderdocui.Windows
|
||||
|
||||
private void switchContext(object sender, EventArgs e)
|
||||
{
|
||||
m_Core.Renderer.DisconnectFromRemoteServer();
|
||||
|
||||
if(sender == localContext)
|
||||
{
|
||||
contextChooser.Image = global::renderdocui.Properties.Resources.house;
|
||||
contextChooser.Text = "Replay Context: Local";
|
||||
|
||||
m_Core.Renderer.DisconnectFromRemoteServer();
|
||||
|
||||
injectIntoProcessToolStripMenuItem.Enabled = true;
|
||||
|
||||
statusText.Text = "";
|
||||
@@ -945,17 +952,7 @@ namespace renderdocui.Windows
|
||||
Thread th = Helpers.NewThread(new ThreadStart(() =>
|
||||
{
|
||||
// see if the server is up
|
||||
try
|
||||
{
|
||||
RemoteServer server = StaticExports.CreateRemoteServer(host.Hostname, 0);
|
||||
server.ShutdownConnection();
|
||||
|
||||
// if we got this far without an exception, the server is running
|
||||
host.ServerRunning = true;
|
||||
}
|
||||
catch (ReplayCreateException)
|
||||
{
|
||||
}
|
||||
host.CheckStatus();
|
||||
|
||||
if (!host.ServerRunning && host.RunCommand != "")
|
||||
{
|
||||
@@ -964,35 +961,35 @@ namespace renderdocui.Windows
|
||||
host.Launch();
|
||||
|
||||
// check if it's running now
|
||||
try
|
||||
{
|
||||
RemoteServer server = StaticExports.CreateRemoteServer(host.Hostname, 0);
|
||||
server.ShutdownConnection();
|
||||
|
||||
// if we got this far without an exception, the server is running
|
||||
host.ServerRunning = true;
|
||||
}
|
||||
catch (ReplayCreateException)
|
||||
{
|
||||
}
|
||||
host.CheckStatus();
|
||||
}
|
||||
|
||||
if (host.ServerRunning)
|
||||
if (host.ServerRunning && !host.Busy)
|
||||
{
|
||||
m_Core.Renderer.DisconnectFromRemoteServer();
|
||||
m_Core.Renderer.ConnectToRemoteServer(host);
|
||||
}
|
||||
|
||||
this.BeginInvoke(new Action(() =>
|
||||
{
|
||||
contextChooser.Image = host.ServerRunning
|
||||
contextChooser.Image = (host.ServerRunning && !host.Busy)
|
||||
? global::renderdocui.Properties.Resources.connect
|
||||
: global::renderdocui.Properties.Resources.disconnect;
|
||||
|
||||
if (host.ServerRunning)
|
||||
if (host.Busy)
|
||||
{
|
||||
statusText.Text = "Remote server in use elsewhere";
|
||||
}
|
||||
else if (host.ServerRunning)
|
||||
{
|
||||
statusText.Text = "Remote server ready";
|
||||
}
|
||||
else
|
||||
statusText.Text = "Remote server not running or failed";
|
||||
{
|
||||
if(host.RunCommand != "")
|
||||
statusText.Text = "Remote server not running or failed to start";
|
||||
else
|
||||
statusText.Text = "Remote server not running - no start command configured";
|
||||
}
|
||||
|
||||
contextChooser.Enabled = true;
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user