diff --git a/ElectronNET.API/BridgeConnector.cs b/ElectronNET.API/BridgeConnector.cs index 3f37e06..8c4d979 100644 --- a/ElectronNET.API/BridgeConnector.cs +++ b/ElectronNET.API/BridgeConnector.cs @@ -90,7 +90,22 @@ namespace ElectronNET.API BridgeConnector.Socket.On(eventCompletedString, (value) => { BridgeConnector.Socket.Off(eventCompletedString); - taskCompletionSource.SetResult( ((JObject)value).ToObject() ); + + if (value == null) + { + Console.WriteLine($"ERROR: BridgeConnector (event: '{eventString}') returned null. Socket loop hang."); + taskCompletionSource.SetCanceled(); + return; + } + + try + { + taskCompletionSource.SetResult( ((JObject)value).ToObject() ); + } + catch (Exception e) + { + Console.WriteLine($"ERROR: BridgeConnector (event: '{eventString}') exception: {e.Message}. Socket loop hung."); + } }); BridgeConnector.Socket.Emit(eventString); @@ -110,7 +125,21 @@ namespace ElectronNET.API BridgeConnector.Socket.On(eventCompletedString, (value) => { BridgeConnector.Socket.Off(eventCompletedString); - taskCompletionSource.SetResult( ((JArray)value).ToObject() ); + if (value == null) + { + Console.WriteLine($"ERROR: BridgeConnector (event: '{eventString}') returned null. Socket loop hang."); + taskCompletionSource.SetCanceled(); + return; + } + + try + { + taskCompletionSource.SetResult( ((JArray)value).ToObject() ); + } + catch (Exception e) + { + Console.WriteLine($"ERROR: BridgeConnector (event: '{eventString}') exception: {e.Message}. Socket loop hung."); + } }); BridgeConnector.Socket.Emit(eventString); diff --git a/ElectronNET.API/Entities/Versions.cs b/ElectronNET.API/Entities/ProcessVersions.cs similarity index 82% rename from ElectronNET.API/Entities/Versions.cs rename to ElectronNET.API/Entities/ProcessVersions.cs index 254a62c..ce61fcb 100644 --- a/ElectronNET.API/Entities/Versions.cs +++ b/ElectronNET.API/Entities/ProcessVersions.cs @@ -3,7 +3,7 @@ namespace ElectronNET.API /// /// /// - public class Versions + public class ProcessVersions { /// /// Gets or sets a value representing Chrome's version string. @@ -13,6 +13,6 @@ namespace ElectronNET.API /// /// Gets or sets a value representing Electron's version string. /// - public bool Electron { get; set; } + public string Electron { get; set; } } } \ No newline at end of file diff --git a/ElectronNET.API/Process.cs b/ElectronNET.API/Process.cs index 0976d20..3a25b44 100644 --- a/ElectronNET.API/Process.cs +++ b/ElectronNET.API/Process.cs @@ -82,11 +82,11 @@ namespace ElectronNET.API /// /// /// - public Task VersionsAsync + public Task VersionsAsync { get { - return BridgeConnector.GetValueOverSocketAsync( + return BridgeConnector.GetObjectOverSocketAsync( "process-versions", "process-versions-Completed"); } }