本文整理匯總了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() + "]")
}
示例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))
}
示例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)
}
示例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))
}
示例5: clientPacketDispatcher
func clientPacketDispatcher(rclient *client.RemotingClient, resp *packet.Packet) {
clientf.ReadFlow.Incr(1)
clientf.DispatcherFlow.Incr(1)
rclient.Attach(resp.Opaque, resp.Data)
}