本文整理匯總了Golang中github.com/pebbe/zmq4.Socket.GetType方法的典型用法代碼示例。如果您正苦於以下問題:Golang Socket.GetType方法的具體用法?Golang Socket.GetType怎麽用?Golang Socket.GetType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pebbe/zmq4.Socket
的用法示例。
在下文中一共展示了Socket.GetType方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Send
// Sends marshaled data through 0mq socket.
func (g *Goodbye) Send(socket *zmq.Socket) (err error) {
frame, err := g.Marshal()
if err != nil {
return err
}
socType, err := socket.GetType()
if err != nil {
return err
}
// If we're sending to a ROUTER, we send the routingId first
if socType == zmq.ROUTER {
_, err = socket.SendBytes(g.routingId, zmq.SNDMORE)
if err != nil {
return err
}
}
// Now send the data frame
_, err = socket.SendBytes(frame, 0)
if err != nil {
return err
}
return err
}
示例2: Send
// Sends marshaled data through 0mq socket.
func (d *Deliver) Send(socket *zmq.Socket) (err error) {
frame, err := d.Marshal()
if err != nil {
return err
}
socType, err := socket.GetType()
if err != nil {
return err
}
// If we're sending to a ROUTER, we send the routingId first
if socType == zmq.ROUTER {
_, err = socket.SendBytes(d.routingId, zmq.SNDMORE)
if err != nil {
return err
}
}
// Now send the data frame
_, err = socket.SendBytes(frame, zmq.SNDMORE)
if err != nil {
return err
}
// Now send any frame fields, in order
_, err = socket.SendBytes(d.Content, 0)
return err
}
示例3: Send
// Send sends marshaled data through 0mq socket.
func (b *Binary) Send(socket *zmq.Socket) (err error) {
frame, err := b.Marshal()
if err != nil {
return err
}
socType, err := socket.GetType()
if err != nil {
return err
}
// If we're sending to a ROUTER, we send the routingID first
if socType == zmq.ROUTER {
_, err = socket.SendBytes(b.routingID, zmq.SNDMORE)
if err != nil {
return err
}
}
// Now send the data frame
_, err = socket.SendBytes(frame, zmq.SNDMORE)
if err != nil {
return err
}
// Now send any frame fields, in order
_, err = socket.SendBytes(b.Address, zmq.SNDMORE)
_, err = socket.SendBytes(b.Content, 0)
return err
}
示例4: recv
// Receives marshaled data from 0mq socket.
func recv(socket *zmq.Socket, flag zmq.Flag) (t Transit, err error) {
// Read all frames
frames, err := socket.RecvMessageBytes(flag)
if err != nil {
return nil, err
}
sType, err := socket.GetType()
if err != nil {
return nil, err
}
var routingId []byte
// If message came from a router socket, first frame is routingId
if sType == zmq.ROUTER {
if len(frames) <= 1 {
return nil, errors.New("no routingId")
}
routingId = frames[0]
frames = frames[1:]
}
t, err = Unmarshal(frames...)
if err != nil {
return nil, err
}
if sType == zmq.ROUTER {
t.SetRoutingId(routingId)
}
return t, err
}