Live updating connected clients list
This commit is contained in:
parent
5255cc1e86
commit
0f66fff11d
@ -57,6 +57,7 @@ namespace MelonVPNCore
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Sending response: offline");
|
Console.WriteLine("Sending response: offline");
|
||||||
Client.SendDataMessage(DataMessage.Offline, true);
|
Client.SendDataMessage(DataMessage.Offline, true);
|
||||||
|
Client.SendCustomMessage(Messages.ClientListEmptyMsg, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (data == Messages.StartMsg)
|
else if (data == Messages.StartMsg)
|
||||||
@ -87,6 +88,7 @@ namespace MelonVPNCore
|
|||||||
Console.WriteLine("It looked like this: " + e);
|
Console.WriteLine("It looked like this: " + e);
|
||||||
currentVpnProcess = null;
|
currentVpnProcess = null;
|
||||||
Client.SendDataMessage(DataMessage.Error, true);
|
Client.SendDataMessage(DataMessage.Error, true);
|
||||||
|
Client.SendCustomMessage(Messages.ClientListEmptyMsg, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -106,6 +108,7 @@ namespace MelonVPNCore
|
|||||||
currentVpnProcess = null;
|
currentVpnProcess = null;
|
||||||
Console.WriteLine("Sending offline reply");
|
Console.WriteLine("Sending offline reply");
|
||||||
Client.SendDataMessage(DataMessage.Offline, true);
|
Client.SendDataMessage(DataMessage.Offline, true);
|
||||||
|
Client.SendCustomMessage(Messages.ClientListEmptyMsg, true);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -113,6 +116,7 @@ namespace MelonVPNCore
|
|||||||
Console.WriteLine("It looked like this: " + e);
|
Console.WriteLine("It looked like this: " + e);
|
||||||
currentVpnProcess = null;
|
currentVpnProcess = null;
|
||||||
Client.SendDataMessage(DataMessage.Error, true);
|
Client.SendDataMessage(DataMessage.Error, true);
|
||||||
|
Client.SendCustomMessage(Messages.ClientListEmptyMsg, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -45,10 +45,9 @@ namespace MelonVPNCore
|
|||||||
if (data.StartsWith(Messages.ClientListStartMsg, StringComparison.CurrentCulture))
|
if (data.StartsWith(Messages.ClientListStartMsg, StringComparison.CurrentCulture))
|
||||||
{
|
{
|
||||||
string jsonWithEof = data.Substring(Messages.ClientListStartMsg.Length);
|
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);
|
Console.WriteLine("clients: " + jsonData);
|
||||||
//ClientListParser.Parse(jsonData);
|
ConnectedClient[] clients = ClientListParser.Parse(jsonData);
|
||||||
ConnectedClient[] clients = new ConnectedClient[0];
|
|
||||||
ClientListUpdate?.Invoke(null, clients);
|
ClientListUpdate?.Invoke(null, clients);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +61,7 @@ namespace MelonVPNCore
|
|||||||
{
|
{
|
||||||
Console.WriteLine(e);
|
Console.WriteLine(e);
|
||||||
}
|
}
|
||||||
Console.WriteLine("GUI socket server reathed the end");
|
Console.WriteLine("GUI socket server reached the end");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
public static string StopMsg = "STOP::" + Code + EOF;
|
public static string StopMsg = "STOP::" + Code + EOF;
|
||||||
public static string ErrorMsg = "ERROR::" + Code + EOF;
|
public static string ErrorMsg = "ERROR::" + Code + EOF;
|
||||||
public static string ClientListStartMsg = "CLIENTLIST::" + Code + "::";
|
public static string ClientListStartMsg = "CLIENTLIST::" + Code + "::";
|
||||||
|
public static string ClientListEmptyMsg = ClientListStartMsg + "[]" + EOF;
|
||||||
|
|
||||||
public static string GetMessage(DataMessage a)
|
public static string GetMessage(DataMessage a)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user