streamdeck-obs-replay/client.go

36 lines
574 B
Go
Raw Normal View History

2020-01-16 05:19:22 +00:00
package main
import (
"io"
"io/ioutil"
"net/http"
"strconv"
)
type Client interface {
Connect() error
Disconnect() error
Connected() bool
ToggleReplay() error
SaveReplay() error
}
func NewClient(key, host string, port int, password string) Client {
res, err := http.Get("http://" + host + ":" + strconv.Itoa(port) + "/api/info")
if err != nil {
return nil
}
defer res.Body.Close()
io.Copy(ioutil.Discard, res.Body)
if res.StatusCode == 200 {
return NewSlobsClient(key, host, port, password)
}
return NewOBSWSClient(key, host, port, password)
}