本文整理汇总了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)
}