Fix restarting status stating online.
This commit is contained in:
parent
b59d2727f3
commit
499d86bed3
@ -12,6 +12,7 @@ namespace MelonVPNCore
|
|||||||
private static Process currentVpnProcess = null;
|
private static Process currentVpnProcess = null;
|
||||||
private static bool shouldBeRunning = false;
|
private static bool shouldBeRunning = false;
|
||||||
private static bool shouldRestart = false;
|
private static bool shouldRestart = false;
|
||||||
|
private static bool isRestarting = false;
|
||||||
private static int startingTime = 3000;
|
private static int startingTime = 3000;
|
||||||
private static int restartDelay = 250;
|
private static int restartDelay = 250;
|
||||||
|
|
||||||
@ -63,11 +64,20 @@ namespace MelonVPNCore
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Status requested");
|
Console.WriteLine("Status requested");
|
||||||
if (isProcessOnline(currentVpnProcess) || shouldBeRunning)
|
if (isProcessOnline(currentVpnProcess) || shouldBeRunning)
|
||||||
|
{
|
||||||
|
if (isRestarting)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Sending response: restarting");
|
||||||
|
Client.SendDataMessage(DataMessage.Restarting, true);
|
||||||
|
Client.SendCustomMessage(lastClientUpdate, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("Sending response: online");
|
Console.WriteLine("Sending response: online");
|
||||||
Client.SendDataMessage(DataMessage.Online, true);
|
Client.SendDataMessage(DataMessage.Online, true);
|
||||||
Client.SendCustomMessage(lastClientUpdate, true);
|
Client.SendCustomMessage(lastClientUpdate, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("Sending response: offline");
|
Console.WriteLine("Sending response: offline");
|
||||||
@ -190,6 +200,7 @@ namespace MelonVPNCore
|
|||||||
currentVpnProcess = null;
|
currentVpnProcess = null;
|
||||||
Thread.Sleep(restartDelay);
|
Thread.Sleep(restartDelay);
|
||||||
bool imonline = false;
|
bool imonline = false;
|
||||||
|
isRestarting = true;
|
||||||
while (shouldRestart && shouldBeRunning)
|
while (shouldRestart && shouldBeRunning)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Sending restarting reply");
|
Console.WriteLine("Sending restarting reply");
|
||||||
@ -209,6 +220,7 @@ namespace MelonVPNCore
|
|||||||
Thread.Sleep(restartDelay);
|
Thread.Sleep(restartDelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
isRestarting = false;
|
||||||
if (! imonline)
|
if (! imonline)
|
||||||
{
|
{
|
||||||
shouldBeRunning = false;
|
shouldBeRunning = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user