本文整理汇总了Golang中github.com/pebbe/zmq3.Socket.SendMessage方法的典型用法代码示例。如果您正苦于以下问题:Golang Socket.SendMessage方法的具体用法?Golang Socket.SendMessage怎么用?Golang Socket.SendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pebbe/zmq3.Socket
的用法示例。
在下文中一共展示了Socket.SendMessage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: echo
// Echo service
func echo(socket *zmq.Socket) (err error) {
msg, err := socket.RecvMessage(0)
if err != nil {
return
}
_, err = socket.SendMessage(msg)
return
}
示例2: ProcessEvents
func ProcessEvents(self string, statebe, statefe *zmq.Socket) {
poller := zmq.NewPoller()
poller.Add(statefe, zmq.POLLIN)
for {
// Poll for activity, or 1 second timeout
sockets, err := poller.Poll(time.Second)
if err != nil {
break
}
// Handle incoming status messages
if len(sockets) == 1 {
msg, _ := statefe.RecvMessage(0)
peerName := msg[0]
available := msg[1]
fmt.Printf("%s - %s workers free\n", peerName, available)
} else {
statebe.SendMessage(self, rand.Intn(10))
}
}
}
示例3: Send
// Send key-value message to socket; any empty frames are sent as such.
func (kvmsg *Kvmsg) Send(socket *zmq.Socket) (err error) {
//fmt.Printf("Send to %s: %q\n", socket, kvmsg.frame)
kvmsg.encode_props()
_, err = socket.SendMessage(kvmsg.frame)
return
}
示例4: ping
func (server *server_t) ping(socket *zmq.Socket) {
if time.Now().After(server.ping_at) {
socket.SendMessage(server.endpoint, "PING")
server.ping_at = time.Now().Add(PING_INTERVAL)
}
}