36 lines
574 B
Go
36 lines
574 B
Go
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)
|
|
}
|