40 lines
731 B
Go
40 lines
731 B
Go
package main
|
|
|
|
import (
|
|
zmq "github.com/pebbe/zmq4"
|
|
dinetpb "src.dualinventive.com/innovation/go-dinetrpc-pb"
|
|
"github.com/davecgh/go-spew/spew"
|
|
|
|
"encoding/json"
|
|
"log"
|
|
)
|
|
|
|
func main() {
|
|
// First, connect our subscriber socket
|
|
subscriber, _ := zmq.NewSocket(zmq.SUB)
|
|
defer subscriber.Close()
|
|
subscriber.Connect("tcp://dev02:6000")
|
|
subscriber.SetSubscribe("")
|
|
|
|
// Third, get our updates and report how many we got
|
|
for {
|
|
data, e := subscriber.RecvBytes(0)
|
|
if e != nil {
|
|
log.Println(e)
|
|
break
|
|
}
|
|
|
|
msg := &dinetpb.Msg{}
|
|
_ = json.Unmarshal(data, msg)
|
|
|
|
if msg.DeviceUID != "001fc23157ff67065265525221130187" {
|
|
continue
|
|
}
|
|
if msg.Type == dinetpb.MsgType_Publish {
|
|
continue
|
|
}
|
|
|
|
spew.Println(msg)
|
|
}
|
|
}
|