func recvMsgOnZBus(nnzbus *nn.Socket) { pid := os.Getpid() // receive, synchronously so flags == 0 var flags int = 0 heardBuf, err := nnzbus.Recv(flags) if err != nil { log.Fatal(err) } fmt.Printf("[pid %d] gozbus server: I heard: '%s'.\n", pid, heardBuf) }
func recvZDate(nnzbus *nn.Socket) { // Read a Z message that is expected to be a Zdate from nnzbus myMsg, err := nnzbus.Recv(0) if err != nil { log.Fatal(err) } buf := bytes.NewBuffer(myMsg) capMsg, err := capn.ReadFromStream(buf, nil) if err != nil { log.Fatal(err) } z := gozbus.ReadRootZ(capMsg) mydate := z.Zdate() fmt.Printf("[pid %d] recvZDate got ZDate message: year %d, month %d, day %d\n", os.Getpid(), mydate.Year(), mydate.Month(), mydate.Day()) }