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


Golang client.RemotingClient類代碼示例

本文整理匯總了Golang中github.com/blackbeans/turbo/client.RemotingClient的典型用法代碼示例。如果您正苦於以下問題:Golang RemotingClient類的具體用法?Golang RemotingClient怎麽用?Golang RemotingClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了RemotingClient類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: handshake

//握手包
func handshake(ga *c.GroupAuth, remoteClient *c.RemotingClient) (bool, error) {

	for i := 0; i < 3; i++ {
		p := protocol.MarshalConnMeta(ga.GroupId, ga.SecretKey)
		rpacket := packet.NewPacket(protocol.CMD_CONN_META, p)
		resp, err := remoteClient.WriteAndGet(*rpacket, 5*time.Second)
		if nil != err {
			//兩秒後重試
			time.Sleep(2 * time.Second)
			log.Warn("kiteClient|handShake|FAIL|%s|%s\n", ga.GroupId, err)
		} else {
			authAck, ok := resp.(*protocol.ConnAuthAck)
			if !ok {
				return false, errors.New("Unmatches Handshake Ack Type! ")
			} else {
				if authAck.GetStatus() {
					log.Info("kiteClient|handShake|SUCC|%s|%s\n", ga.GroupId, authAck.GetFeedback())
					return true, nil
				} else {
					log.Warn("kiteClient|handShake|FAIL|%s|%s\n", ga.GroupId, authAck.GetFeedback())
					return false, errors.New("Auth FAIL![" + authAck.GetFeedback() + "]")
				}
			}
		}
	}

	return false, errors.New("handshake fail! [" + remoteClient.RemoteAddr() + "]")
}
開發者ID:hawkchch,項目名稱:kiteq,代碼行數:29,代碼來源:kite_client_handshake.go

示例2: packetDispatcher

func packetDispatcher(rclient *client.RemotingClient, p *packet.Packet) {

	resp := packet.NewRespPacket(p.Header.Opaque, p.Header.CmdType, p.Data)
	//直接回寫回去
	rclient.Write(*resp)
	// log.Printf("packetDispatcher|WriteResponse|%s\n", string(resp.Data))
}
開發者ID:materone,項目名稱:turbo,代碼行數:7,代碼來源:turbo_server_demo.go

示例3: packetDispatcher

func packetDispatcher(rclient *client.RemotingClient, p *packet.Packet) {
	flow.ReadFlow.Incr(1)
	flow.DispatcherFlow.Incr(1)

	resp := packet.NewRespPacket(p.Opaque, p.CmdType, p.Data)
	//直接回寫回去
	rclient.Write(*resp)
	flow.WriteFlow.Incr(1)
}
開發者ID:markman101,項目名稱:turbo,代碼行數:9,代碼來源:remoting_server_test.go

示例4: clientPacketDispatcher

func clientPacketDispatcher(rclient *client.RemotingClient, resp *packet.Packet) {
	rclient.Attach(resp.Header.Opaque, resp.Data)
	// log.Printf("clientPacketDispatcher|%s\n", string(resp.Data))
}
開發者ID:materone,項目名稱:turbo,代碼行數:4,代碼來源:turbo_client_demo.go

示例5: clientPacketDispatcher

func clientPacketDispatcher(rclient *client.RemotingClient, resp *packet.Packet) {
	clientf.ReadFlow.Incr(1)
	clientf.DispatcherFlow.Incr(1)
	rclient.Attach(resp.Opaque, resp.Data)
}
開發者ID:markman101,項目名稱:turbo,代碼行數:5,代碼來源:remoting_server_test.go


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