當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Socket.GetType方法代碼示例

本文整理匯總了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
}
開發者ID:hintjens,項目名稱:zccp,代碼行數:28,代碼來源:goodbye.go

示例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
}
開發者ID:hintjens,項目名稱:zccp,代碼行數:30,代碼來源:deliver.go

示例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
}
開發者ID:asokoloski,項目名稱:zproto,代碼行數:31,代碼來源:binary.go

示例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
}
開發者ID:hintjens,項目名稱:zccp,代碼行數:33,代碼來源:server.go


注:本文中的github.com/pebbe/zmq4.Socket.GetType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。