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