本文整理匯總了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)
}