Added headless build support
This commit is contained in:
+14
-15
@@ -9,13 +9,12 @@ import (
|
||||
"os"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
"strings"
|
||||
"slices"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"io/ioutil"
|
||||
/* external */
|
||||
"centrifuge.hectabit.org/HectaBit/webview_go" /* for UI launch */
|
||||
)
|
||||
|
||||
/* main chat message structure */
|
||||
@@ -31,7 +30,17 @@ type ChatMessage struct {
|
||||
var global_msg_id uint64 = 0 /* track global message ID */
|
||||
var message_transport chan ChatMessage /* global message channel */
|
||||
var sse_transports []chan string /* SSE output channels */
|
||||
var bro webview.WebView /* global browser instance handle */
|
||||
|
||||
/* headless behaviour by default */
|
||||
var goose_start_gui = func(config map[string]interface{}) {
|
||||
/* target server listening address */
|
||||
const fmt_str = "[headless] Connect to http://%s:%d in any browser to see the chat window"
|
||||
log.Printf(fmt_str, config["server_listen_ip"].(string), int(config["server_port"].(float64)))
|
||||
/* just do nothing except sleep in the main thread */
|
||||
for {
|
||||
time.Sleep(time.Duration(3600) * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
/* escape HTML entities in JS parameters */
|
||||
func esc(s string) string {
|
||||
@@ -157,7 +166,6 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
if _, ok := config["tw_backend_enabled"]; ok && config["tw_backend_enabled"].(bool) == true {
|
||||
go twitch_run(config) /* start the Twitch backend */
|
||||
@@ -175,16 +183,7 @@ func main() {
|
||||
go kick_run(config) /* start the Kick backend */
|
||||
}
|
||||
|
||||
/* start the GUI */
|
||||
debug := false
|
||||
if _, ok := config["debug"]; ok && config["debug"].(bool) == true {
|
||||
debug = true
|
||||
}
|
||||
bro = webview.New(debug) /* create a browser instance */
|
||||
bro.SetSize(320, 720, webview.HintNone)
|
||||
defer bro.Destroy()
|
||||
bro.SetTitle("StreamGoose v0.0.1")
|
||||
bro.Navigate("http://" + target_addr)
|
||||
bro.Run()
|
||||
/* start the GUI from gui.go file */
|
||||
goose_start_gui(config)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user