func sendZDate(nnzbus *nn.Socket) { // Create Zdate and Write to nnzbus. // // Z is our universal type, a discriminated union. // Hence Z provides run-time type identification // for all message types defined in zbus.capnp // s := capn.NewBuffer(nil) z := gozbus.NewRootZ(s) d := gozbus.NewRootZdate(s) z.SetZdate(d) d.SetYear(2004) d.SetMonth(12) d.SetDay(7) buf := bytes.Buffer{} s.WriteTo(&buf) nnzbus.Send(buf.Bytes(), 0) fmt.Printf("[pid %d] sendZDate sent ZDate message: year %d, month %d, day %d\n", os.Getpid(), d.Year(), d.Month(), d.Day()) }
func sayHello(nnzbus *nn.Socket) { pid := os.Getpid() msg := "hello from pid " + strconv.Itoa(pid) nnzbus.Send([]byte(msg), 0) fmt.Printf("[pid %d] gozbus client: sayHello sent msg '%s'.\n", pid, msg) }