Pull flags from environment
This commit is contained in:
parent
4f0a2aeac8
commit
f6ee4bdfab
@ -3,6 +3,7 @@ package streamdeck
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
@ -10,6 +11,18 @@ import (
|
|||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var flagPort int
|
||||||
|
var flagEvent, flagInfo string
|
||||||
|
var UUID string // the UUID this plugin is assigned
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
flag.IntVar(&flagPort, "port", 0, "streamdeck sdk port")
|
||||||
|
flag.StringVar(&flagEvent, "registerEvent", "", "streamdeck sdk register event")
|
||||||
|
flag.StringVar(&flagInfo, "info", "", "streamdeck application info")
|
||||||
|
flag.StringVar(&UUID, "pluginUUID", "", "uuid")
|
||||||
|
flag.Parse()
|
||||||
|
}
|
||||||
|
|
||||||
type logger interface {
|
type logger interface {
|
||||||
Info(string, ...any)
|
Info(string, ...any)
|
||||||
Error(string, ...any)
|
Error(string, ...any)
|
||||||
@ -48,9 +61,9 @@ func NewWithLogger(l logger) Connection {
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conn *Connection) Connect(port int, openEvent string, uuid string) error {
|
func (conn *Connection) Connect() error {
|
||||||
|
|
||||||
c, _, err := websocket.DefaultDialer.Dial(fmt.Sprintf("ws://localhost:%d", port), nil)
|
c, _, err := websocket.DefaultDialer.Dial(fmt.Sprintf("ws://localhost:%d", flagPort), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -58,9 +71,9 @@ func (conn *Connection) Connect(port int, openEvent string, uuid string) error {
|
|||||||
conn.ws = c
|
conn.ws = c
|
||||||
msg := ESOpenMessage{
|
msg := ESOpenMessage{
|
||||||
ESCommonNoContext: ESCommonNoContext{
|
ESCommonNoContext: ESCommonNoContext{
|
||||||
Event: openEvent,
|
Event: flagEvent,
|
||||||
},
|
},
|
||||||
UUID: uuid,
|
UUID: UUID,
|
||||||
}
|
}
|
||||||
conn.logger.Debug(fmt.Sprintf("writing openMessage: %+v", msg))
|
conn.logger.Debug(fmt.Sprintf("writing openMessage: %+v", msg))
|
||||||
err = c.WriteJSON(msg)
|
err = c.WriteJSON(msg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user