fix: make reconnect look better

This commit is contained in:
Anna 2022-07-10 14:11:30 -04:00
parent 4221e53f2e
commit 51a088d8a3
2 changed files with 5 additions and 1 deletions

View File

@ -86,6 +86,7 @@ internal class Client : IDisposable {
internal void StopLoop() {
this._active = false;
this.WebSocket.Abort();
this.Status = State.Disconnected;
}
internal void StartLoop() {

View File

@ -104,11 +104,14 @@ internal class PluginUi : IDisposable {
var status = this.Plugin.Client.Status;
ImGui.TextUnformatted($"Status: {status}");
ImGui.SameLine();
if (ImGuiUtil.IconButton(FontAwesomeIcon.Wifi, tooltip: "Reconnect")) {
if (ImGuiUtil.IconButton(FontAwesomeIcon.Wifi, tooltip: "Reconnect") && !this._busy) {
this._busy = true;
Task.Run(async () => {
this.Plugin.Client.StopLoop();
await Task.Delay(TimeSpan.FromSeconds(5));
this.Plugin.Client.StartLoop();
this._busy = false;
});
}