change ping pong handler and fix blocking channel

This commit is contained in:
Adrian Zuercher
2025-07-23 08:56:43 +02:00
parent de4758c563
commit 239e0050a1
3 changed files with 31 additions and 53 deletions

View File

@@ -102,15 +102,18 @@ func (d *ArtNetDriver) Connect(ip, id string, port uint) error {
}
client.OnMessage = func(data []byte) {
request := json_data.NewResponse()
err = json.Unmarshal(data, &request)
if err != nil {
return
}
if request.Subscribe != nil {
d.Subscribe(request.Subscribe...)
}
if request.Publish != nil {
d.Publish(request.Publish...)
}
@@ -138,6 +141,9 @@ func (d *ArtNetDriver) Connect(ip, id string, port uint) error {
// send data to all buses that the send flage is true
func (d *ArtNetDriver) SendData() {
for _, bus := range d.Buses {
if !bus.Reachable {
continue
}
bus.Send <- bus.Data
}
}