commit db176a4acd5fde3bf46a9ed934b08d07d554c57f
parent a25eb6ed10ba8ad498b79d984feea5a1cf174653
Author: bsandro <[email protected]>
Date: Fri, 30 Jul 2021 02:34:37 +0300
Preliminary work for OBS-websocket support has begun
Diffstat:
6 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/app.go b/app.go
@@ -7,6 +7,7 @@ import (
type TApp struct {
Connection *websocket.Conn
+ Obs *websocket.Conn
WaitGroup sync.WaitGroup
Config TConfig
User *TUser
diff --git a/client.go b/client.go
@@ -37,11 +37,15 @@ func ListenJob() {
App.WaitGroup.Done()
}
-func CloseConn() {
+func CloseConnections() {
if App.Connection != nil {
App.Connection.Close()
App.Connection = nil
}
+ if App.Obs != nil {
+ App.Obs.Close()
+ App.Obs = nil
+ }
}
func main() {
@@ -58,7 +62,10 @@ func main() {
if err != nil {
log.Fatal(err)
}
- defer CloseConn()
+ App.Obs, err = websocket.Dial(fmt.Sprintf("wss://%s:%s/", App.Config.Obs.Host, App.Config.Obs.Port), "", "http://localhost")
+ if err != nil {
+ log.Fatal(err)
+ }
App.WaitGroup.Add(3)
go ListenJob()
@@ -66,4 +73,5 @@ func main() {
go LocalServerJob()
App.WaitGroup.Wait()
+ CloseConnections()
}
diff --git a/config.go b/config.go
@@ -13,10 +13,11 @@ type TConfig struct {
ClientId string `json:"client_id"`
ClientSecret string `json:"client_secret"`
} `json:"twitch"`
- ObsWebsocket struct {
+ Obs struct {
+ Host string `json:"host"`
Port string `json:"port"`
Password string `json:"password"`
- } `json:"obs_websocket"`
+ } `json:"obs"`
}
func (conf *TConfig) Init() error {
@@ -58,6 +59,7 @@ func (conf *TConfig) InitSample() {
conf.Twitch.UserName = "twitch-username"
conf.Twitch.ClientId = "xxxxxxxxxxxxxxx"
conf.Twitch.ClientSecret = "xxxxxxxxxxx"
- conf.ObsWebsocket.Port = "4444"
- conf.ObsWebsocket.Password = "xxxxxxxxx"
+ conf.Obs.Host = "127.0.0.1"
+ conf.Obs.Port = "4444"
+ conf.Obs.Password = "xxxxxxxxx"
}
diff --git a/config_sample.json b/config_sample.json
@@ -5,7 +5,8 @@
"client_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"client_secret": "zzzzzzzzzzzzzzzzzzzzzzzzzzzz"
},
- "obs_websocket": {
+ "obs": {
+ "host": "127.0.0.1",
"port": "4444",
"password": "xxxxxxxx"
}
diff --git a/go.mod b/go.mod
@@ -1,4 +1,4 @@
-module twitchapon
+module bsandro.tech/git/twitchapon
go 1.16
diff --git a/obs_client.go b/obs_client.go
@@ -0,0 +1,6 @@
+package main
+
+import (
+ _ "fmt"
+ _ "golang.org/x/net/websocket"
+)