From 0ee045f172036225e7306fcddb7ab126ade27703 Mon Sep 17 00:00:00 2001 From: Tyler Date: Tue, 14 Jan 2020 23:49:46 -0500 Subject: [PATCH] Handle cases where the client won't be connected if OBS isn't running --- plugin/manifest.json | 2 +- replay.go | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/plugin/manifest.json b/plugin/manifest.json index 3635dbf..b8d9698 100644 --- a/plugin/manifest.json +++ b/plugin/manifest.json @@ -42,7 +42,7 @@ "Icon": "images/pluginIcon", "CategoryIcon": "images/pluginIcon", "URL": "https://streamdeck.meow.tf/obsreplay", - "Version": "1.0.1", + "Version": "1.0.2", "SDKVersion": 2, "OS": [ { diff --git a/replay.go b/replay.go index c31ce12..f877850 100644 --- a/replay.go +++ b/replay.go @@ -88,6 +88,14 @@ func clientForContext(context string) *obsws.Client { return nil } + if !c.Connected() { + err := c.Connect() + + if err != nil { + return nil + } + } + return c } @@ -131,12 +139,6 @@ func checkClient(host string, port int, password string) string { if !ok { client = &obsws.Client{Host: host, Port: port, Password: password} - err := client.Connect() - - if err != nil { - return "" - } - client.AddEventHandler("StreamStatus", streamStatusUpdate(key)) client.AddEventHandler("ReplayStarted", loopContextState(key, 1)) client.AddEventHandler("ReplayStopped", loopContextState(key, 0))