本文整理汇总了Golang中github.com/pebbe/zmq2.Socket.RecvMessage方法的典型用法代码示例。如果您正苦于以下问题:Golang Socket.RecvMessage方法的具体用法?Golang Socket.RecvMessage怎么用?Golang Socket.RecvMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pebbe/zmq2.Socket
的用法示例。
在下文中一共展示了Socket.RecvMessage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: echo
// Echo service
func echo(socket *zmq.Socket) (err error) {
msg, err := socket.RecvMessage(0)
if err != nil {
return
}
_, err = socket.SendMessage(msg)
return
}
示例3: voter_ready
// Application wants to speak to us, see if it's possible
func (bstar *Bstar) voter_ready(socket *zmq.Socket) error {
// If server can accept input now, call appl handler
bstar.event = client_REQUEST
err := bstar.execute_fsm()
if err == nil {
bstar.voter_fn(socket)
} else {
// Destroy waiting message, no-one to read it
socket.RecvMessage(0)
}
return nil
}
示例4: RecvKvmsg
// The RecvKvmsg function reads a key-value message from socket, and returns a new
// Kvmsg instance.
func RecvKvmsg(socket *zmq.Socket) (kvmsg *Kvmsg, err error) {
kvmsg = &Kvmsg{
present: make([]bool, kvmsg_FRAMES),
frame: make([]string, kvmsg_FRAMES),
}
msg, err := socket.RecvMessage(0)
if err != nil {
return
}
//fmt.Printf("Recv from %s: %q\n", socket, msg)
for i := 0; i < kvmsg_FRAMES && i < len(msg); i++ {
kvmsg.frame[i] = msg[i]
kvmsg.present[i] = true
}
return
}