• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang protorpc.Client类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/Terry-Mao/protorpc.Client的典型用法代码示例。如果您正苦于以下问题:Golang Client类的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Client类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: genSubKey

func genSubKey(userId int64) (res map[int32][]string) {
	var (
		i      int
		ok     bool
		key    string
		keys   []string
		client *rpc.Client
		err    error
		arg    = &rproto.GetArg{UserId: userId}
		reply  = &rproto.GetReply{}
	)
	res = make(map[int32][]string)
	if client, err = getRouterByUID(userId); err != nil {
		return
	}
	if err = client.Call(routerServiceGet, arg, reply); err != nil {
		log.Error("client.Call(\"%s\",\"%v\") error(%s)", routerServiceGet, arg, err)
		return
	}
	for i = 0; i < len(reply.Servers); i++ {
		key = encode(userId, reply.Seqs[i])
		if keys, ok = res[reply.Servers[i]]; !ok {
			keys = []string{}
		}
		keys = append(keys, key)
		res[reply.Servers[i]] = keys
	}
	return
}
开发者ID:nevermatch,项目名称:goim,代码行数:29,代码来源:router.go


示例2: testSendDeadlock

func testSendDeadlock(client *protorpc.Client) {
	defer func() {
		recover()
	}()
	args := &Args{7, 8}
	reply := new(Reply)
	client.Call("Arith.Add", args, reply)
}
开发者ID:scabwort,项目名称:protorpc,代码行数:8,代码来源:server_test.go


示例3: broadcastRoomComet

func broadcastRoomComet(c *protorpc.Client, roomId int32, msg []byte) {
	var (
		args = &cproto.BoardcastRoomArg{Ver: 0, Operation: define.OP_SEND_SMS_REPLY, Msg: msg, RoomId: roomId}
		err  error
	)
	if err = c.Call(CometServiceBroadcastRoom, args, nil); err != nil {
		log.Error("c.Call(\"%s\", %v, reply) error(%v)", CometServiceBroadcastRoom, *args, err)
	}
}
开发者ID:dulumao,项目名称:goim,代码行数:9,代码来源:comet.go


示例4: mpushComet

func mpushComet(c *protorpc.Client, subkeys []string, body []byte) {
	var (
		args = &cproto.MPushMsgArg{Keys: subkeys, Operation: define.OP_SEND_SMS_REPLY, Msg: body}
		rep  = &cproto.MPushMsgReply{}
		err  error
	)
	if err = c.Call(CometServiceMPushMsg, args, rep); err != nil {
		log.Error("c.Call(\"%s\", %v, reply) error(%v)", CometServiceMPushMsg, *args, err)
	}
}
开发者ID:dulumao,项目名称:goim,代码行数:10,代码来源:comet.go


示例5: roomsComet

func roomsComet(c *protorpc.Client) map[int32]bool {
	var (
		reply = &cproto.RoomsReply{}
		err   error
	)
	if err = c.Call(CometServiceRooms, nil, reply); err != nil {
		log.Error("c.Call(\"%s\", nil, reply) error(%v)", CometServiceRooms, err)
		return nil
	}
	return reply.Rooms
}
开发者ID:dulumao,项目名称:goim,代码行数:11,代码来源:comet.go


示例6: getAllSubkeys

func getAllSubkeys(serverId string) (reply *rproto.GetAllReply, err error) {
	var client *rpc.Client
	if client, err = getRouterByServer(serverId); err != nil {
		return
	}
	reply = &rproto.GetAllReply{}
	if err = client.Call(routerServiceGetAll, nil, reply); err != nil {
		log.Error("client.Call(\"%s\") error(%s)", routerServiceGetAll, err)
	}
	return
}
开发者ID:huweixuan,项目名称:goim,代码行数:11,代码来源:router.go


示例7: allRoomCount

func allRoomCount(client *rpc.Client) (counter map[int32]int32, err error) {
	var (
		reply = &rproto.AllRoomCountReply{}
	)
	if err = client.Call(routerServiceAllRoomCount, nil, reply); err != nil {
		log.Error("c.Call(\"%s\", nil) error(%v)", routerServiceAllRoomCount, err)
	} else {
		counter = reply.Counter
	}
	return
}
开发者ID:james4e,项目名称:goim,代码行数:11,代码来源:router.go


示例8: getSubkeys

func getSubkeys(serverId string, userIds []int64) (reply *rproto.MGetReply, err error) {
	var client *rpc.Client
	if client, err = getRouterByServer(serverId); err != nil {
		return
	}
	arg := &rproto.MGetArg{UserIds: userIds}
	reply = &rproto.MGetReply{}
	if err = client.Call(routerServiceMGet, arg, reply); err != nil {
		log.Error("client.Call(\"%s\",\"%v\") error(%s)", routerServiceMGet, arg, err)
	}
	return
}
开发者ID:swallowing0619,项目名称:goim,代码行数:12,代码来源:router.go


示例9: broadcastRoomComet

func broadcastRoomComet(c *protorpc.Client, roomId int32, msg []byte) {
	var (
		now  = time.Now()
		args = &cproto.BoardcastRoomArg{Ver: 0, Operation: define.OP_SEND_SMS_REPLY, Msg: msg, RoomId: roomId}
		err  error
	)
	if err = c.Call(CometServiceBroadcastRoom, args, nil); err != nil {
		log.Error("c.Call(\"%s\", %v, reply) error(%v)", CometServiceBroadcastRoom, *args, err)
	} else {
		log.Info("broadcast msg to msg:%s room:%d(%f)", msg, roomId, time.Now().Sub(now).Seconds())
	}
}
开发者ID:1d7500,项目名称:goim,代码行数:12,代码来源:comet.go


示例10: pushToComet

func pushToComet(serverId int32, c *protorpc.Client, subkeys []string, body []byte, wg *sync.WaitGroup) {
	now := time.Now()
	args := &cproto.MPushMsgArg{Keys: subkeys, Operation: OP_SEND_SMS_REPLY, Msg: body}
	rep := &cproto.MPushMsgReply{}
	if err := c.Call(CometServiceMPushMsg, args, rep); err != nil {
		log.Error("c.Call(\"%s\", %v, reply) error(%v)", CometServiceMPushMsg, *args, err)
		goto done
	}
	log.Info("push msg to serverId:%d index:%d", serverId, rep.Index)
	log.Debug("push seconds %f", time.Now().Sub(now).Seconds())
done:
	wg.Done()
}
开发者ID:huweixuan,项目名称:goim,代码行数:13,代码来源:push_job.go


示例11: mpushComet

func mpushComet(c *protorpc.Client, subkeys []string, body []byte) {
	var (
		now  = time.Now()
		args = &cproto.MPushMsgArg{Keys: subkeys, Operation: define.OP_SEND_SMS_REPLY, Msg: body}
		rep  = &cproto.MPushMsgReply{}
		err  error
	)
	if err = c.Call(CometServiceMPushMsg, args, rep); err != nil {
		log.Error("c.Call(\"%s\", %v, reply) error(%v)", CometServiceMPushMsg, *args, err)
	} else {
		log.Info("push msg to index:%d(%f)", rep.Index, time.Now().Sub(now).Seconds())
	}
}
开发者ID:1d7500,项目名称:goim,代码行数:13,代码来源:comet.go


示例12: disconnect

func disconnect(userID int64, seq int32) (has bool, err error) {
	var client *rpc.Client
	if client, err = getRouterByUID(userID); err != nil {
		return
	}
	arg := &rproto.DisconnArg{UserId: userID, Seq: seq}
	reply := &rproto.DisconnReply{}
	if err = client.Call(routerServiceDisconnect, arg, reply); err != nil {
		log.Error("c.Call(\"%s\",\"%v\") error(%s)", routerServiceDisconnect, *arg, err)
	} else {
		has = reply.Has
	}
	return
}
开发者ID:nevermatch,项目名称:goim,代码行数:14,代码来源:router.go


示例13: connect

func connect(userID int64, server int32) (seq int32, err error) {
	var client *rpc.Client
	if client, err = getRouterByUID(userID); err != nil {
		return
	}
	arg := &rproto.ConnArg{UserId: userID, Server: server}
	reply := &rproto.ConnReply{}
	if err = client.Call(routerServiceConnect, arg, reply); err != nil {
		log.Error("c.Call(\"%s\",\"%v\") error(%s)", routerServiceConnect, arg, err)
	} else {
		seq = reply.Seq
	}
	return
}
开发者ID:nevermatch,项目名称:goim,代码行数:14,代码来源:router.go


示例14: disconnect

func disconnect(userID int64, seq, roomId int32) (has bool, err error) {
	var (
		client *rpc.Client
		arg    = &rproto.DelArg{UserId: userID, Seq: seq, RoomId: roomId}
		reply  = &rproto.DelReply{}
	)
	if client, err = getRouterByUID(userID); err != nil {
		return
	}
	if err = client.Call(routerServiceDel, arg, reply); err != nil {
		log.Error("c.Call(\"%s\",\"%v\") error(%v)", routerServiceDel, *arg, err)
	} else {
		has = reply.Has
	}
	return
}
开发者ID:dulumao,项目名称:goim,代码行数:16,代码来源:router.go


示例15: rpcPing

func rpcPing(addr string, c *protorpc.Client, retry time.Duration) {
	var err error
	for {
		if err = c.Call(logicServicePing, nil, nil); err != nil {
			log.Error("c.Call(\"%s\", nil, nil) error(%v), retry after:%ds", logicServicePing, err, retry/time.Second)
			rpcTmp, err := protorpc.Dial("tcp", addr)
			if err != nil {
				log.Error("protorpc.Dial(\"tcp\", %s) error(%v)", addr, err)
				time.Sleep(retry)
				continue
			}
			c = rpcTmp
			time.Sleep(retry)
			continue
		}
		log.Debug("rpc ping:%s ok", addr)
		time.Sleep(retry)
		continue
	}
}
开发者ID:sf100,项目名称:goim,代码行数:20,代码来源:logic.go


示例16: testHTTPRPC

func testHTTPRPC(t *testing.T, path string) {
	var client *protorpc.Client
	var err error
	if path == "" {
		client, err = protorpc.DialHTTP("tcp", httpServerAddr)
	} else {
		client, err = protorpc.DialHTTPPath("tcp", httpServerAddr, path)
	}
	if err != nil {
		t.Fatal("dialing", err)
	}
	defer client.Close()

	// Synchronous calls
	args := &Args{7, 8}
	reply := new(Reply)
	err = client.Call("Arith.Add", args, reply)
	if err != nil {
		t.Errorf("Add: expected no error but got string %q", err.Error())
	}
	if reply.C != args.A+args.B {
		t.Errorf("Add: expected %d got %d", reply.C, args.A+args.B)
	}
}
开发者ID:scabwort,项目名称:protorpc,代码行数:24,代码来源:server_test.go



注:本文中的github.com/Terry-Mao/protorpc.Client类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang aws.Bool函数代码示例发布时间:2022-05-28
下一篇:
Golang protorpc.Dial函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap