Skip to content

Commit d6fecda

Browse files
committed
Fix Eventlistener not restarting
1 parent e84fdc6 commit d6fecda

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

API/Communication.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -634,13 +634,12 @@ public static void StopEventListener()
634634
eventCleanLoop = null;
635635
}
636636

637-
public static async Task<bool> StartEventListener(string ip, string port, string auth_token)
637+
public static async Task StartEventListener(string ip, string port, string auth_token)
638638
{
639639
string address = $"http://{ip}:{port}/api/v1/{auth_token}/events?id=1,2,3,4";
640640
WebClient wc = new WebClient();
641641
wc.Headers.Add("TouchEventsPort", _touchEventsPort.ToString());
642642
wc.OpenReadAsync(new Uri(address));
643-
bool restart = false;
644643
bool isListening = true;
645644
wc.OpenReadCompleted += (sender, args) =>
646645
{
@@ -660,9 +659,7 @@ public static async Task<bool> StartEventListener(string ip, string port, string
660659
}
661660
catch (Exception e) when (e is IOException || e is WebException)//Timeout! Restart Listener without Logging
662661
{
663-
restart = true;
664-
isListening = false;
665-
return;
662+
NanoleafPlugin.Log.Debug("Restarting EventListener because of:" + Environment.NewLine, e);
666663
}
667664
catch (Exception e) when (e is TargetInvocationException)
668665
{
@@ -683,7 +680,6 @@ public static async Task<bool> StartEventListener(string ip, string port, string
683680
};
684681
while (isListening)
685682
await Task.Delay(10);
686-
return restart;
687683
}
688684

689685
private static async Task FireEvent(string ip, string eventData)

0 commit comments

Comments
 (0)