本文整理汇总了Golang中github.com/pebbe/zmq2.Socket.Recv方法的典型用法代码示例。如果您正苦于以下问题:Golang Socket.Recv方法的具体用法?Golang Socket.Recv怎么用?Golang Socket.Recv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pebbe/zmq2.Socket
的用法示例。
在下文中一共展示了Socket.Recv方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: zmqToWebsocket
// listen on a zmq SUB socket
// and shovel messages from it out to the websockets
func zmqToWebsocket(subsocket zmq.Socket) {
for {
address, _ := subsocket.Recv(0)
content, _ := subsocket.Recv(0)
fmt.Println("received a zmq message")
fmt.Println(string(address))
fmt.Println(string(content))
runningRoom.SendMessage(envelope{string(address), string(content)})
}
}
示例2: zmqToWebsocket
// listen on a zmq SUB socket
// and shovel messages from it out to the websockets
func zmqToWebsocket(subsocket zmq.Socket) {
for {
address, _ := subsocket.Recv(0)
content, _ := subsocket.Recv(0)
log.WithFields(log.Fields{
"address": string(address),
"content": string(content),
}).Info("received a zmq message")
runningRoom.SendMessage(envelope{string(address), string(content)})
}
}
示例3: dump
func dump(soc *zmq.Socket) {
fmt.Println("----------------------------------------")
for {
// Process all parts of the message
message, _ := soc.Recv(0)
// Dump the message as text or binary
fmt.Printf("[%03d] ", len(message))
if all_char.MatchString(message) {
fmt.Print(message)
} else {
for i := 0; i < len(message); i++ {
fmt.Printf("%02X ", message[i])
}
}
fmt.Println()
more, _ := soc.GetRcvmore()
if !more {
break
}
}
}
示例4: 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)
}