本文整理汇总了Golang中github.com/pebbe/zmq2.Socket.Send方法的典型用法代码示例。如果您正苦于以下问题:Golang Socket.Send方法的具体用法?Golang Socket.Send怎么用?Golang Socket.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pebbe/zmq2.Socket
的用法示例。
在下文中一共展示了Socket.Send方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: snapshots
func snapshots(socket *zmq.Socket, srv *clonesrv_t) (err error) {
msg, err := socket.RecvMessage(0)
if err != nil {
return
}
identity := msg[0]
// Request is in second frame of message
request := msg[1]
if request != "ICANHAZ?" {
err = errors.New("E: bad request, aborting")
return
}
subtree := msg[2]
// Send state socket to client
for _, kvmsg := range srv.kvmap {
if key, _ := kvmsg.GetKey(); strings.HasPrefix(key, subtree) {
socket.Send(identity, zmq.SNDMORE)
kvmsg.Send(socket)
}
}
// Now send END message with sequence number
log.Println("I: sending shapshot =", srv.sequence)
socket.Send(identity, zmq.SNDMORE)
kvmsg := kvmsg.NewKvmsg(srv.sequence)
kvmsg.SetKey("KTHXBAI")
kvmsg.SetBody(subtree)
kvmsg.Send(socket)
return
}
示例2: sendMessage
// send a message to the zmq PUB socket
func sendMessage(reqsocket zmq.Socket, e envelope) {
serialized_envelope, _ := json.Marshal(e)
reqsocket.Send(string(serialized_envelope), 0)
// wait for a reply
reqsocket.Recv(0)
}