change ping pong handler and fix blocking channel
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user