|
|
@@ -2,6 +2,7 @@ package broadcast
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
+ "goseg/config"
|
|
|
"goseg/structs"
|
|
|
"log/slog"
|
|
|
"os"
|
|
|
@@ -21,7 +22,13 @@ var (
|
|
|
|
|
|
func init(){
|
|
|
// initialize broadcastState global var
|
|
|
- return
|
|
|
+ config := config.Conf()
|
|
|
+ broadcast, err := bootstrapBroadcastState(config)
|
|
|
+ if err != nil {
|
|
|
+ errmsg := fmt.Sprintf("Unable to initialize broadcast: %v",err)
|
|
|
+ panic(errmsg)
|
|
|
+ }
|
|
|
+ broadcastState = broadcast
|
|
|
}
|
|
|
|
|
|
// adds ws client
|
|
|
@@ -34,8 +41,14 @@ func UnregisterClient(conn *websocket.Conn) {
|
|
|
delete(clients, conn)
|
|
|
}
|
|
|
|
|
|
+// take in config file and addt'l info to initialize broadcast
|
|
|
+func bootstrapBroadcastState(config structs.SysConfig) (structs.AuthBroadcast, error) {
|
|
|
+ var res structs.AuthBroadcast
|
|
|
+ return res, nil
|
|
|
+}
|
|
|
+
|
|
|
// update broadcastState with a map of items
|
|
|
-func UpdateStateWithMap(values map[string]interface{}) error {
|
|
|
+func UpdateBroadcastState(values map[string]interface{}) error {
|
|
|
mu.Lock()
|
|
|
defer mu.Unlock()
|
|
|
v := reflect.ValueOf(&broadcastState).Elem()
|