1.1.6 Added TryEnter to VTC room routing to prevent multiple source routes from accidentally running simultaneously (NYU bug); Restructuring MOBILEHTTPREQUEST to do post and get

This commit is contained in:
Heath Volmer
2018-05-01 10:27:16 -06:00
parent 4defea55f0
commit 4b0f8abd9f
6 changed files with 67 additions and 30 deletions

View File

@@ -4,6 +4,6 @@
[assembly: AssemblyCompany("PepperDash Technology Corp")] [assembly: AssemblyCompany("PepperDash Technology Corp")]
[assembly: AssemblyProduct("PepperDashEssentials")] [assembly: AssemblyProduct("PepperDashEssentials")]
[assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2017")] [assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2017")]
[assembly: AssemblyVersion("1.1.4.*")] [assembly: AssemblyVersion("1.1.6.*")]

View File

@@ -79,30 +79,7 @@ namespace PepperDash.Essentials
CrestronConsole.ConsoleCommandResponse("HTTP Debug {0}", HttpDebugEnabled ? "Enabled" : "Disabled"); CrestronConsole.ConsoleCommandResponse("HTTP Debug {0}", HttpDebugEnabled ? "Enabled" : "Disabled");
}, },
"mobilehttpdebug", "1 enables more verbose HTTP response debugging", ConsoleAccessLevelEnum.AccessOperator); "mobilehttpdebug", "1 enables more verbose HTTP response debugging", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.AddNewConsoleCommand(TestHttpRequest,
{
s = s.Trim();
if (string.IsNullOrEmpty(s))
{
CrestronConsole.ConsoleCommandResponse("Command must include http URL");
return;
}
try
{
var resp = new HttpClient().Get(s);
CrestronConsole.ConsoleCommandResponse("RESPONSE:\r{0}", resp);
}
catch (HttpException e)
{
CrestronConsole.ConsoleCommandResponse("Exception in request:");
CrestronConsole.ConsoleCommandResponse("Response URL: {0}", e.Response.ResponseUrl);
CrestronConsole.ConsoleCommandResponse("Response Error Code: {0}", e.Response.Code);
CrestronConsole.ConsoleCommandResponse("Response body: {0}", e.Response.ContentString);
}
},
"mobilehttprequest", "Tests an HTTP get to URL given", ConsoleAccessLevelEnum.AccessOperator); "mobilehttprequest", "Tests an HTTP get to URL given", ConsoleAccessLevelEnum.AccessOperator);
} }
@@ -253,10 +230,10 @@ namespace PepperDash.Essentials
/// <param name="url">URL of the server, including the port number, if not 80. Format: "serverUrlOrIp:port"</param> /// <param name="url">URL of the server, including the port number, if not 80. Format: "serverUrlOrIp:port"</param>
void RegisterSystemToServer() void RegisterSystemToServer()
{ {
var ready = RegisterLockEvent.Wait(2000); var ready = RegisterLockEvent.Wait(20000);
if (!ready) if (!ready)
{ {
Debug.Console(1, this, "RegisterSystemToServer failed to enter after 2 seconds. Ignoring"); Debug.Console(1, this, "RegisterSystemToServer failed to enter after 20 seconds. Ignoring");
return; return;
} }
RegisterLockEvent.Reset(); RegisterLockEvent.Reset();
@@ -274,7 +251,7 @@ namespace PepperDash.Essentials
if (string.IsNullOrEmpty(postBody)) if (string.IsNullOrEmpty(postBody))
{ {
Debug.Console(1, this, "ERROR: Config post body is empty. Cannot register with server."); Debug.Console(1, this, "ERROR: Config body is empty. Cannot register with server.");
} }
else else
{ {
@@ -299,6 +276,7 @@ namespace PepperDash.Essentials
{ {
Debug.Console(0, this, "ERROR: Initilizing Room: {0}", e); Debug.Console(0, this, "ERROR: Initilizing Room: {0}", e);
RegisterLockEvent.Set(); RegisterLockEvent.Set();
StartReconnectTimer();
} }
} }
@@ -361,6 +339,7 @@ namespace PepperDash.Essentials
ServerReconnectTimer = null; ServerReconnectTimer = null;
} }
// Success here!
ConnectStreamClient(); ConnectStreamClient();
} }
else else
@@ -371,11 +350,13 @@ namespace PepperDash.Essentials
{ {
Debug.Console(1, this, "Null response received from server."); Debug.Console(1, this, "Null response received from server.");
} }
StartReconnectTimer();
} }
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Console(1, this, "Error Initializing Stream Client: {0}", e); Debug.Console(1, this, "Error Initializing Stream Client: {0}", e);
StartReconnectTimer();
} }
RegisterLockEvent.Set(); RegisterLockEvent.Set();
} }
@@ -637,5 +618,56 @@ namespace PepperDash.Essentials
Debug.Console(1, this, "Unable to parse message: {0}", err); Debug.Console(1, this, "Unable to parse message: {0}", err);
} }
} }
void TestHttpRequest(string s)
{
{
s = s.Trim();
if (string.IsNullOrEmpty(s))
{
PrintTestHttpRequestUsage();
return;
}
var tokens = s.Split(' ');
if (tokens.Length < 2)
{
PrintTestHttpRequestUsage();
return;
}
try
{
var url = tokens[1];
if (tokens[0].ToLower() == "get")
{
var resp = new HttpClient().Get(url);
CrestronConsole.ConsoleCommandResponse("RESPONSE:\r{0}", resp);
}
else if (tokens[1].ToLower() == "post")
{
var resp = new HttpClient().Post(url, new byte[] { });
CrestronConsole.ConsoleCommandResponse("RESPONSE:\r{0}", resp);
}
else
{
PrintTestHttpRequestUsage();
}
}
catch (HttpException e)
{
CrestronConsole.ConsoleCommandResponse("Exception in request:");
CrestronConsole.ConsoleCommandResponse("Response URL: {0}", e.Response.ResponseUrl);
CrestronConsole.ConsoleCommandResponse("Response Error Code: {0}", e.Response.Code);
CrestronConsole.ConsoleCommandResponse("Response body: {0}", e.Response.ContentString);
}
}
}
void PrintTestHttpRequestUsage()
{
CrestronConsole.ConsoleCommandResponse("Usage: mobilehttprequest:N get/post url ");
}
} }
} }

View File

@@ -191,6 +191,8 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
public IHasScheduleAwareness ScheduleSource { get { return VideoCodec as IHasScheduleAwareness; } } public IHasScheduleAwareness ScheduleSource { get { return VideoCodec as IHasScheduleAwareness; } }
CCriticalSection SourceSelectLock = new CCriticalSection();
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@@ -316,6 +318,9 @@ namespace PepperDash.Essentials
// Run this on a separate thread // Run this on a separate thread
new CTimer(o => new CTimer(o =>
{ {
// try to prevent multiple simultaneous selections
SourceSelectLock.TryEnter();
try try
{ {
@@ -374,11 +379,9 @@ namespace PepperDash.Essentials
(item.SourceDevice as IUsageTracking).UsageTracker.StartDeviceUsage(); (item.SourceDevice as IUsageTracking).UsageTracker.StartDeviceUsage();
} }
// See if this can be moved into common, base-class method ------------- // See if this can be moved into common, base-class method -------------
// Set volume control, using default if non provided // Set volume control, using default if non provided
IBasicVolumeControls volDev = null; IBasicVolumeControls volDev = null;
// Handle special cases for volume control // Handle special cases for volume control
@@ -443,6 +446,7 @@ namespace PepperDash.Essentials
Debug.Console(1, this, "ERROR in routing: {0}", e); Debug.Console(1, this, "ERROR in routing: {0}", e);
} }
SourceSelectLock.Leave();
}, 0); // end of CTimer }, 0); // end of CTimer
} }

View File

@@ -995,6 +995,7 @@ namespace PepperDash.Essentials
var srcList = config[_CurrentRoom.SourceListKey].OrderBy(kv => kv.Value.Order); var srcList = config[_CurrentRoom.SourceListKey].OrderBy(kv => kv.Value.Order);
// Setup sources list // Setup sources list
SourceStagingSrl.Clear();
uint i = 1; // counter for UI list uint i = 1; // counter for UI list
foreach (var kvp in srcList) foreach (var kvp in srcList)
{ {