# HG changeset patch
# User StephaneLenclud
# Date 1472484962 -7200
# Node ID 51b86efdc4487ce37f64cd8c2705e2f6faacb635
# Parent c57b8ac80fc63b8a03c96ef0a3f71262d0315b4a
Published V.1.0.5.
Providing Harmony Hub reconnect.
diff -r c57b8ac80fc6 -r 51b86efdc448 Server/Actions/ActionHarmonyCommand.cs
--- a/Server/Actions/ActionHarmonyCommand.cs Thu Aug 25 13:34:05 2016 +0200
+++ b/Server/Actions/ActionHarmonyCommand.cs Mon Aug 29 17:36:02 2016 +0200
@@ -74,13 +74,14 @@
//TODO: check if the harmony client connection is opened
if (Program.HarmonyClient!=null)
{
- Program.HarmonyClient.SendCommandAsync(DeviceId, FunctionName);
+ // Wait synchronously for now until we figure out how we could do async stuff in EAR.
+ // TODO: Have an abort option in EAR. For instance we don't want to keep sending Harmony command if one failed.
+ Program.HarmonyClient.TrySendCommandAsync(DeviceId, FunctionName).Wait(10*1000);
}
else
{
Trace.WriteLine("WARNING: No Harmony client connection.");
- }
-
+ }
}
diff -r c57b8ac80fc6 -r 51b86efdc448 Server/FormMain.cs
--- a/Server/FormMain.cs Thu Aug 25 13:34:05 2016 +0200
+++ b/Server/FormMain.cs Mon Aug 29 17:36:02 2016 +0200
@@ -2982,6 +2982,18 @@
}
///
+ /// Called whenever we loose connection with our HarmonyHub.
+ ///
+ ///
+ private void HarmonyConnectionClosedByServer(object aSender, bool aRequestWasCancelled)
+ {
+ //Try reconnect then
+#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
+ ResetHarmonyAsync();
+#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
+ }
+
+ ///
///
///
///
@@ -2997,16 +3009,24 @@
Program.HarmonyConfig = null;
Trace.WriteLine("Harmony: Connecting... ");
+ //First create our client and login
Program.HarmonyClient = new HarmonyHub.Client(iTextBoxHarmonyHubAddress.Text);
- //First create our client and login
+ Program.HarmonyClient.OnConnectionClosedByServer += HarmonyConnectionClosedByServer;
+
if (File.Exists("SessionToken") && !aForceAuth)
{
var sessionToken = File.ReadAllText("SessionToken");
Trace.WriteLine("Harmony: Reusing token: {0}", sessionToken);
- await Program.HarmonyClient.OpenAsync(sessionToken);
+ await Program.HarmonyClient.TryOpenAsync(sessionToken);
}
- else
+
+ if (!Program.HarmonyClient.IsReady)
{
+ //We failed to connect using our token
+ //Delete it then
+ File.Delete("SessionToken");
+
+ //Then try connect using our password
if (string.IsNullOrEmpty(iTextBoxLogitechPassword.Text))
{
Trace.WriteLine("Harmony: Credentials missing!");
@@ -3014,18 +3034,13 @@
}
Trace.WriteLine("Harmony: Authenticating with Logitech servers...");
- await Program.HarmonyClient.OpenAsync(iTextBoxLogitechUserName.Text, iTextBoxLogitechPassword.Text);
+ await Program.HarmonyClient.TryOpenAsync(iTextBoxLogitechUserName.Text, iTextBoxLogitechPassword.Text);
File.WriteAllText("SessionToken", Program.HarmonyClient.Token);
}
- Trace.WriteLine("Harmony: Fetching Harmony Hub configuration...");
-
//Fetch our config
Program.HarmonyConfig = await Program.HarmonyClient.GetConfigAsync();
PopulateTreeViewHarmony(Program.HarmonyConfig);
-
- Trace.WriteLine("Harmony: Ready");
-
//Make sure harmony command actions are showing device name instead of device id
PopulateEventsTreeView();
}
diff -r c57b8ac80fc6 -r 51b86efdc448 Server/SharpDisplayManager.csproj
--- a/Server/SharpDisplayManager.csproj Thu Aug 25 13:34:05 2016 +0200
+++ b/Server/SharpDisplayManager.csproj Mon Aug 29 17:36:02 2016 +0200
@@ -34,7 +34,7 @@
index.htm
false
0
- 1.0.2.0
+ 1.0.5.0
false
true
true
@@ -112,7 +112,7 @@
True
- ..\packages\SharpLibHarmony.0.5.0\lib\net451\HarmonyHub.dll
+ ..\packages\SharpLibHarmony.0.6.1\lib\net451\HarmonyHub.dll
True
diff -r c57b8ac80fc6 -r 51b86efdc448 Server/packages.config
--- a/Server/packages.config Thu Aug 25 13:34:05 2016 +0200
+++ b/Server/packages.config Mon Aug 29 17:36:02 2016 +0200
@@ -4,7 +4,7 @@
-
+