Handle cases where the client won't be connected if OBS isn't running
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Tyler 2020-01-14 23:49:46 -05:00
parent c5db9d1f88
commit 0ee045f172
2 changed files with 9 additions and 7 deletions

View File

@ -42,7 +42,7 @@
"Icon": "images/pluginIcon", "Icon": "images/pluginIcon",
"CategoryIcon": "images/pluginIcon", "CategoryIcon": "images/pluginIcon",
"URL": "https://streamdeck.meow.tf/obsreplay", "URL": "https://streamdeck.meow.tf/obsreplay",
"Version": "1.0.1", "Version": "1.0.2",
"SDKVersion": 2, "SDKVersion": 2,
"OS": [ "OS": [
{ {

View File

@ -88,6 +88,14 @@ func clientForContext(context string) *obsws.Client {
return nil return nil
} }
if !c.Connected() {
err := c.Connect()
if err != nil {
return nil
}
}
return c return c
} }
@ -131,12 +139,6 @@ func checkClient(host string, port int, password string) string {
if !ok { if !ok {
client = &obsws.Client{Host: host, Port: port, Password: password} client = &obsws.Client{Host: host, Port: port, Password: password}
err := client.Connect()
if err != nil {
return ""
}
client.AddEventHandler("StreamStatus", streamStatusUpdate(key)) client.AddEventHandler("StreamStatus", streamStatusUpdate(key))
client.AddEventHandler("ReplayStarted", loopContextState(key, 1)) client.AddEventHandler("ReplayStarted", loopContextState(key, 1))
client.AddEventHandler("ReplayStopped", loopContextState(key, 0)) client.AddEventHandler("ReplayStopped", loopContextState(key, 0))