diff --git a/MelonVPNCore/DaemonSocketServer.cs b/MelonVPNCore/DaemonSocketServer.cs index b8dc53f..1522de6 100644 --- a/MelonVPNCore/DaemonSocketServer.cs +++ b/MelonVPNCore/DaemonSocketServer.cs @@ -57,6 +57,7 @@ namespace MelonVPNCore { Console.WriteLine("Sending response: offline"); Client.SendDataMessage(DataMessage.Offline, true); + Client.SendCustomMessage(Messages.ClientListEmptyMsg, true); } } else if (data == Messages.StartMsg) @@ -87,6 +88,7 @@ namespace MelonVPNCore Console.WriteLine("It looked like this: " + e); currentVpnProcess = null; Client.SendDataMessage(DataMessage.Error, true); + Client.SendCustomMessage(Messages.ClientListEmptyMsg, true); } } else @@ -106,6 +108,7 @@ namespace MelonVPNCore currentVpnProcess = null; Console.WriteLine("Sending offline reply"); Client.SendDataMessage(DataMessage.Offline, true); + Client.SendCustomMessage(Messages.ClientListEmptyMsg, true); } catch (Exception e) { @@ -113,6 +116,7 @@ namespace MelonVPNCore Console.WriteLine("It looked like this: " + e); currentVpnProcess = null; Client.SendDataMessage(DataMessage.Error, true); + Client.SendCustomMessage(Messages.ClientListEmptyMsg, true); } } else diff --git a/MelonVPNCore/GUISocketServer.cs b/MelonVPNCore/GUISocketServer.cs index d4cbd31..6621902 100644 --- a/MelonVPNCore/GUISocketServer.cs +++ b/MelonVPNCore/GUISocketServer.cs @@ -45,10 +45,9 @@ namespace MelonVPNCore if (data.StartsWith(Messages.ClientListStartMsg, StringComparison.CurrentCulture)) { string jsonWithEof = data.Substring(Messages.ClientListStartMsg.Length); - string jsonData = data.Substring(0, jsonWithEof.Length - Messages.EOF.Length); + string jsonData = jsonWithEof.Substring(0, jsonWithEof.Length - Messages.EOF.Length); Console.WriteLine("clients: " + jsonData); - //ClientListParser.Parse(jsonData); - ConnectedClient[] clients = new ConnectedClient[0]; + ConnectedClient[] clients = ClientListParser.Parse(jsonData); ClientListUpdate?.Invoke(null, clients); } @@ -62,7 +61,7 @@ namespace MelonVPNCore { Console.WriteLine(e); } - Console.WriteLine("GUI socket server reathed the end"); + Console.WriteLine("GUI socket server reached the end"); } } } diff --git a/MelonVPNCore/Messages.cs b/MelonVPNCore/Messages.cs index 159e19e..57896cf 100644 --- a/MelonVPNCore/Messages.cs +++ b/MelonVPNCore/Messages.cs @@ -11,6 +11,7 @@ public static string StopMsg = "STOP::" + Code + EOF; public static string ErrorMsg = "ERROR::" + Code + EOF; public static string ClientListStartMsg = "CLIENTLIST::" + Code + "::"; + public static string ClientListEmptyMsg = ClientListStartMsg + "[]" + EOF; public static string GetMessage(DataMessage a) {