From cb8464f4a8ffa2ae288c64c20ff2ae97939d0dfc Mon Sep 17 00:00:00 2001 From: ffdfgdfg Date: Thu, 8 Apr 2021 02:09:46 +0800 Subject: [PATCH] add android auto reconnect --- gui/npc/npc.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gui/npc/npc.go b/gui/npc/npc.go index b579377..9be47d5 100644 --- a/gui/npc/npc.go +++ b/gui/npc/npc.go @@ -107,8 +107,14 @@ func onclick(s, v, c string) { if sp != s || vk != v || ct != c { saveConfig(s, v, c) } - cl = client.NewRPClient(s, v, c, "", nil, 60) - go cl.Start() + go func() { + for { + cl = client.NewRPClient(s, v, c, "", nil, 60) + cl.Start() + logs.Info("client disconnected, reconnecting in 5 seconds...") + time.Sleep(time.Second * 5) + } + }() } else { // close the npc status = "Start!"