add resubscribe (in progress)
fix crash when no bus found in map
This commit is contained in:
13
main.go
13
main.go
@@ -21,6 +21,7 @@ func main() {
|
||||
serverPort := flag.Uint("serverPort", 8100, "port of server")
|
||||
wsPort := flag.Uint("port", 8200, "websocket port")
|
||||
debug := flag.Bool("debug", false, "debug logging")
|
||||
start := flag.Bool("start", false, "starts all buses on startup")
|
||||
flag.Parse()
|
||||
|
||||
//change working directory only if value is given
|
||||
@@ -47,6 +48,7 @@ func main() {
|
||||
s.Routes.POST("/buses/start", artNetDriver.Start)
|
||||
s.Routes.POST("/buses/status", artNetDriver.Status)
|
||||
s.Routes.POST("/buses/stop", artNetDriver.Stop)
|
||||
s.Routes.POST("/buses/resubscribe", artNetDriver.Resubscribe)
|
||||
|
||||
s.Routes.GET("/", func(c *gin.Context) {
|
||||
c.String(200, "ArtNet Driver WebSocket Server is running!")
|
||||
@@ -58,7 +60,16 @@ func main() {
|
||||
}
|
||||
}()
|
||||
|
||||
artNetDriver.Log.Info("main", fmt.Sprintf("connect to server ws://%s:%d with id %s", *serverIp, serverPort, DriverName))
|
||||
artNetDriver.Log.Info("main", fmt.Sprintf("connect to server ws://%s:%d with id %s", *serverIp, *serverPort, DriverName))
|
||||
|
||||
if *start {
|
||||
for busName, bus := range artNetDriver.Buses {
|
||||
artNetDriver.Log.Info("main", fmt.Sprintf("starting bus %s", busName))
|
||||
// start bus and listen to subscriptions
|
||||
bus.Start(artNetDriver.Log)
|
||||
}
|
||||
}
|
||||
|
||||
// connect to server
|
||||
for {
|
||||
artNetDriver.Log.Error("main", artNetDriver.Connect(*serverIp, DriverName, *serverPort))
|
||||
|
Reference in New Issue
Block a user