Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
0172144b47
@ -221,6 +221,7 @@ const ( //Rpc
|
||||
Rpc_ModuleChatPushChat core.Rpc_Key = "Rpc_ModuleChatPushChat" //推送聊天消息
|
||||
//Moonfantasy 月之秘境
|
||||
Rpc_ModuleMoonfantasyTrigger core.Rpc_Key = "Rpc_ModuleMoonfantasyTrigger" //月之秘境触发消息
|
||||
Rpc_ModuleMoonfantasyTriggerMF core.Rpc_Key = "Rpc_ModuleMoonfantasyTriggerMF" //月之秘境触发消息
|
||||
//rtask 上传随机任务代码
|
||||
Rpc_ModuleRtaskSendTask core.Rpc_Key = "Rpc_ModuleRtaskSendTask" //随机任务触发
|
||||
// friend
|
||||
@ -228,6 +229,7 @@ const ( //Rpc
|
||||
|
||||
// arena
|
||||
Rpc_ModuleArenaRaceSettlement core.Rpc_Key = "Rpc_ModuleArenaRaceSettlement" //竞技场比赛结算信息
|
||||
Rpc_ModuleArenaModifyIntegral core.Rpc_Key = "Rpc_ModuleArenaModifyIntegral" //竞技场修改积分
|
||||
|
||||
// 充值发货
|
||||
Rpc_ModulePayDelivery core.Rpc_Key = "Rpc_ModulePayDelivery" //充值发货
|
||||
|
@ -85,6 +85,9 @@ type (
|
||||
CheckJuexingHeroNum(uid string, juexingLv int32, star int32) int32
|
||||
//拥有共鸣至N级的英雄 Rtype124
|
||||
CheckResonaceHeroNum(uid string, resonaceLv int32) int32
|
||||
|
||||
// 获取所有满星满级满觉醒的英雄
|
||||
GetAllMaxHero(session IUserSession) (code pb.ErrorCode)
|
||||
}
|
||||
|
||||
//玩家
|
||||
@ -234,6 +237,8 @@ type (
|
||||
IMoonFantasy interface {
|
||||
//触发月之秘境
|
||||
Trigger(session IUserSession, source *pb.BattleReport)
|
||||
//GM触发月之秘境
|
||||
TriggerMF(session IUserSession, Boosid string) (err error)
|
||||
}
|
||||
IViking interface {
|
||||
CheckUserBaseVikingInfo(uid string) (data []*pb.DBVikingRank) // 查询玩家最佳通关记录
|
||||
@ -295,6 +300,8 @@ type (
|
||||
IArena interface {
|
||||
///红点
|
||||
IReddot
|
||||
//设置用户积分
|
||||
SetUserIntegral(session IUserSession, Integral int32) (err error)
|
||||
}
|
||||
IGourmet interface {
|
||||
///红点
|
||||
|
@ -131,6 +131,27 @@ func (this *modelArena) updateArenaUserInfo(info *pb.DBArenaUser) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (this *modelArena) modifyIntegral(uid string, integral int32) (err error) {
|
||||
var (
|
||||
dan int32
|
||||
player *pb.ArenaPlayer
|
||||
)
|
||||
if dan, err = this.computedan(integral); err != nil {
|
||||
return
|
||||
}
|
||||
player = &pb.ArenaPlayer{Uid: uid, Integral: integral}
|
||||
if err = this.module.modelRank.updateArenaRank(player); err != nil {
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
this.Change(uid, map[string]interface{}{
|
||||
"integral": integral,
|
||||
"dan": dan,
|
||||
"rank": player.Rank,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (this *modelArena) computedan(integral int32) (dan int32, err error) {
|
||||
var (
|
||||
active *cfg.GameArenaActiveRewardData
|
||||
|
@ -54,6 +54,7 @@ func (this *Arena) Start() (err error) {
|
||||
}
|
||||
this.mail = module.(comm.Imail)
|
||||
this.service.RegisterFunctionName(string(comm.Rpc_ModuleArenaRaceSettlement), this.Rpc_ModuleArenaRaceSettlement)
|
||||
this.service.RegisterFunctionName(string(comm.Rpc_ModuleArenaModifyIntegral), this.Rpc_ModuleArenaModifyIntegral)
|
||||
return
|
||||
}
|
||||
|
||||
@ -67,9 +68,17 @@ func (this *Arena) OnInstallComp() {
|
||||
}
|
||||
|
||||
//比赛结算
|
||||
func (this *Arena) Rpc_ModuleArenaRaceSettlement(ctx context.Context, args *pb.EmptyReq, reply *pb.EmptyResp) {
|
||||
func (this *Arena) Rpc_ModuleArenaRaceSettlement(ctx context.Context, args *pb.EmptyReq, reply *pb.EmptyResp) (err error) {
|
||||
this.Debug("Rpc_ModuleArenaRaceSettlement", log.Fields{"args": args.String()})
|
||||
this.modelRank.raceSettlement()
|
||||
return
|
||||
}
|
||||
|
||||
//修改用户积分
|
||||
func (this *Arena) Rpc_ModuleArenaModifyIntegral(ctx context.Context, args *pb.RPCModifyIntegralReq, reply *pb.EmptyResp) (err error) {
|
||||
this.Debug("Rpc_ModuleArenaModifyIntegral", log.Fields{"args": args.String()})
|
||||
err = this.modelArena.modifyIntegral(args.Uid, args.Integral)
|
||||
return
|
||||
}
|
||||
|
||||
//红点需求
|
||||
@ -84,3 +93,20 @@ func (this *Arena) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (re
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Arena) SetUserIntegral(session comm.IUserSession, Integral int32) (err error) {
|
||||
if this.IsCross() {
|
||||
err = this.modelArena.modifyIntegral(session.GetUserId(), Integral)
|
||||
} else {
|
||||
if _, err = this.service.AcrossClusterRpcGo(
|
||||
context.Background(),
|
||||
this.GetCrossTag(),
|
||||
comm.Service_Worker,
|
||||
string(comm.Rpc_ModuleChatPushChat),
|
||||
&pb.RPCModifyIntegralReq{Uid: session.GetUserId(), Integral: Integral},
|
||||
nil); err != nil {
|
||||
this.Errorln(err)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
5、跳过随机任务 bingo:worldtask,1,1001
|
||||
6、bingo:Iamyoudad
|
||||
7、bingo:vip,yueka_1,1 // 月卡类型
|
||||
8、bingo:manhero
|
||||
*/
|
||||
//参数校验
|
||||
func (this *apiComp) CmdCheck(session comm.IUserSession, req *pb.GMCmdReq) (code pb.ErrorCode) {
|
||||
|
@ -146,7 +146,14 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
|
||||
this.Error("bingo 世界任务", log.Fields{"params": datas, "err": err.Error()})
|
||||
}
|
||||
}
|
||||
} else if len(datas) == 2 && (datas[0] == "manhero") { // 获取满星、等级、觉醒、共鸣技能
|
||||
module1, err := this.service.GetModule(comm.ModuleHero)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
code = module1.(comm.IHero).GetAllMaxHero(session)
|
||||
this.Debug("使用bingo命令:uid = %s ", log.Fields{"uid": session.GetUserId(), "0": datas[1]})
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -486,3 +486,15 @@ func (this *configureComp) GetShopItemsConfigureByGroups(groupid int32, user *pb
|
||||
}
|
||||
return
|
||||
}
|
||||
func (this *configureComp) GetHeroStargrowConfigByStar(star int32) int32 {
|
||||
|
||||
if v, err := this.GetConfigure(hero_stargrow); err == nil {
|
||||
if configure, ok := v.(*cfg.GameHeroStargrow); ok {
|
||||
return configure.Get(star).Maxlevel
|
||||
}
|
||||
} else {
|
||||
err = fmt.Errorf("%T no is *cfg.GameHero", v)
|
||||
}
|
||||
|
||||
return 1
|
||||
}
|
||||
|
@ -603,3 +603,74 @@ func (this *Hero) CheckResonaceHeroNum(uid string, resonaceLv int32) int32 {
|
||||
}
|
||||
return int32(len(tmp))
|
||||
}
|
||||
|
||||
// 获取所有满星满级满觉醒的英雄
|
||||
func (this *Hero) GetAllMaxHero(session comm.IUserSession) (code pb.ErrorCode) {
|
||||
data := this.modelHero.moduleHero.configure.GetHeroConfigData()
|
||||
for _, v := range data {
|
||||
if v.Handbook != -1 {
|
||||
cid := v.Hid
|
||||
maxStar := v.Star
|
||||
starConf := this.configure.GetHeroStarupConfig(cid, v.Star)
|
||||
if starConf == nil {
|
||||
continue // 走到这里说明配置表没有配置数据
|
||||
}
|
||||
// 获取最大星级
|
||||
for i := 1; ; i++ {
|
||||
starConf := this.configure.GetHeroStarupConfig(cid, v.Star+int32(i))
|
||||
if starConf == nil {
|
||||
break
|
||||
}
|
||||
if starConf != nil && starConf.Gold == 0 {
|
||||
maxStar = v.Star + int32(i)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
maxLv := this.configure.GetHeroStargrowConfigByStar(maxStar) // 最大等级
|
||||
|
||||
maxJux := 1 // 最大觉醒等级
|
||||
for i := 1; ; i++ {
|
||||
data := this.configure.GetHeroAwakenConfig(cid, int32(i))
|
||||
if data == nil {
|
||||
maxJux = i
|
||||
break
|
||||
}
|
||||
}
|
||||
var maxGongm int32
|
||||
conf := this.configure.GetHeroResonanceConfig(cid, v.Star)
|
||||
if conf != nil {
|
||||
maxGongm = int32(conf.Maxnum)
|
||||
}
|
||||
this.modelHero.moduleHero.Debugf("%d", maxStar, maxLv, maxJux, maxGongm)
|
||||
// 开始创建英雄
|
||||
hero, err := this.modelHero.createOneHero(session.GetUserId(), v.Hid)
|
||||
if err != nil {
|
||||
return pb.ErrorCode_HeroCreate
|
||||
}
|
||||
hero.Lv = maxLv
|
||||
hero.Star = maxStar
|
||||
hero.JuexingLv = int32(maxJux)
|
||||
hero.ResonateNum = maxGongm
|
||||
hero.SameCount = 1
|
||||
_heroMap := map[string]interface{}{
|
||||
"lv": hero.Lv,
|
||||
"star": hero.Star,
|
||||
"juexingLv": hero.JuexingLv,
|
||||
"resonateNum": hero.ResonateNum,
|
||||
"isOverlying": false,
|
||||
"sameCount": 1,
|
||||
}
|
||||
// 保存数据
|
||||
err = this.modelHero.ChangeList(session.GetUserId(), hero.Id, _heroMap)
|
||||
if err != nil {
|
||||
log.Errorf("GetSpecified failed:%v", err)
|
||||
return
|
||||
}
|
||||
this.modelHero.PropertyCompute(hero) // 重新计算属性
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
@ -138,6 +138,59 @@ func (this *modelDreamComp) trigger(session comm.IUserSession) {
|
||||
return
|
||||
}
|
||||
|
||||
//触发月之秘境
|
||||
func (this *modelDreamComp) triggerbyid(session comm.IUserSession, boosid string) (err error) {
|
||||
var (
|
||||
user *pb.DBUser
|
||||
umfantasy *pb.DBUserMFantasy
|
||||
globalconf *cfg.GameGlobalData
|
||||
boss *cfg.GameDreamlandBoosData
|
||||
mdata *pb.DBMoonFantasy
|
||||
chat *pb.DBChat
|
||||
)
|
||||
globalconf = this.module.configure.GetGlobalConf()
|
||||
|
||||
if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil {
|
||||
return
|
||||
}
|
||||
this.module.modelUserMF.recoverTicket(session, umfantasy)
|
||||
if umfantasy.TriggerNum >= globalconf.DreamlandTriggernum {
|
||||
return
|
||||
}
|
||||
|
||||
if boss, err = this.module.configure.GetMonsterById(boosid); err != nil {
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil {
|
||||
this.module.Errorf("no found uer:%d", session.GetUserId())
|
||||
return
|
||||
}
|
||||
|
||||
if mdata, err = this.module.modelDream.addDreamData(&pb.UserInfo{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar, Lv: user.Lv}, boss); err != nil {
|
||||
return
|
||||
}
|
||||
// umfantasy.Mfantasys = append(umfantasy.Mfantasys, mdata.Id)
|
||||
umfantasy.TriggerNum++
|
||||
umfantasy.LastTrigger = configure.Now().Unix()
|
||||
this.module.modelUserMF.updateUserInfo(umfantasy)
|
||||
chat = &pb.DBChat{
|
||||
Ctype: pb.ChatType_Moonfantasy,
|
||||
Suid: session.GetUserId(),
|
||||
Avatar: user.Avatar,
|
||||
Uname: user.Name,
|
||||
Slv: user.Lv,
|
||||
Ctime: configure.Now().Unix(),
|
||||
Stag: session.GetServiecTag(),
|
||||
Content: mdata.Monster,
|
||||
AppendStr: mdata.Id,
|
||||
}
|
||||
this.module.modelDream.noticeuserfriend(session, mdata.Id, chat)
|
||||
session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerPush{Issucc: true, Mid: mdata.Id, Monster: mdata.Monster})
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype87, 1)
|
||||
return
|
||||
}
|
||||
|
||||
///查询好友数据
|
||||
func (this *modelDreamComp) noticeuserfriend(session comm.IUserSession, mid string, chat *pb.DBChat) (code pb.ErrorCode) {
|
||||
var (
|
||||
|
@ -65,6 +65,7 @@ func (this *Moonfantasy) Start() (err error) {
|
||||
}
|
||||
this.battle = module.(comm.IBattle)
|
||||
this.service.RegisterFunctionName(string(comm.Rpc_ModuleMoonfantasyTrigger), this.Rpc_ModuleMoonfantasyTrigger)
|
||||
this.service.RegisterFunctionName(string(comm.Rpc_ModuleMoonfantasyTriggerMF), this.Rpc_ModuleMoonfantasyTriggerMF)
|
||||
return
|
||||
}
|
||||
|
||||
@ -119,3 +120,38 @@ func (this *Moonfantasy) Rpc_ModuleMoonfantasyTrigger(ctx context.Context, args
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//触发月之秘境
|
||||
func (this *Moonfantasy) Rpc_ModuleMoonfantasyTriggerMF(ctx context.Context, args *pb.RPCTargetMFReq, reply *pb.EmptyResp) (err error) {
|
||||
var (
|
||||
session comm.IUserSession
|
||||
ok bool
|
||||
)
|
||||
if session, ok = this.GetUserSession(args.Uid); !ok {
|
||||
err = fmt.Errorf("no found user%s", args.Uid)
|
||||
this.Errorln(err)
|
||||
return
|
||||
}
|
||||
if err = this.modelDream.triggerbyid(session, args.Boosid); err != nil {
|
||||
this.Errorln(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//触发月之秘境
|
||||
func (this *Moonfantasy) TriggerMF(session comm.IUserSession, Boosid string) (err error) {
|
||||
if this.IsCross() {
|
||||
err = this.modelDream.triggerbyid(session, Boosid)
|
||||
} else {
|
||||
if _, err = this.service.AcrossClusterRpcGo(context.Background(),
|
||||
this.GetCrossTag(),
|
||||
comm.Service_Worker,
|
||||
string(comm.Rpc_ModuleMoonfantasyTriggerMF),
|
||||
pb.RPCTargetMFReq{Uid: session.GetUserId(), Boosid: Boosid},
|
||||
nil,
|
||||
); err != nil {
|
||||
this.Errorln(err)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -8,10 +8,7 @@ import (
|
||||
const (
|
||||
TrollGetListResp = "getlist"
|
||||
TrollBuyOrSellResp = "buyorsell"
|
||||
GourmetCreateOrderResp = "createorder"
|
||||
GourmetSkillLvResp = "skilllv"
|
||||
TrollNpcRewardResp = "npcreward"
|
||||
GourmetGetRandUserResp = "getranduser"
|
||||
TrollRankListResp = "ranklist"
|
||||
TrollRecordListResp = "recordlist"
|
||||
TrollAfkSetResp = "afkset"
|
||||
|
@ -748,6 +748,62 @@ func (x *DBNpc) GetIndex() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
//修改用户积分
|
||||
type RPCModifyIntegralReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"`
|
||||
Integral int32 `protobuf:"varint,2,opt,name=integral,proto3" json:"integral"`
|
||||
}
|
||||
|
||||
func (x *RPCModifyIntegralReq) Reset() {
|
||||
*x = RPCModifyIntegralReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_arena_arena_db_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *RPCModifyIntegralReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RPCModifyIntegralReq) ProtoMessage() {}
|
||||
|
||||
func (x *RPCModifyIntegralReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_arena_arena_db_proto_msgTypes[6]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use RPCModifyIntegralReq.ProtoReflect.Descriptor instead.
|
||||
func (*RPCModifyIntegralReq) Descriptor() ([]byte, []int) {
|
||||
return file_arena_arena_db_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *RPCModifyIntegralReq) GetUid() string {
|
||||
if x != nil {
|
||||
return x.Uid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RPCModifyIntegralReq) GetIntegral() int32 {
|
||||
if x != nil {
|
||||
return x.Integral
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_arena_arena_db_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_arena_arena_db_proto_rawDesc = []byte{
|
||||
@ -854,18 +910,23 @@ var file_arena_arena_db_proto_rawDesc = []byte{
|
||||
0x4e, 0x70, 0x63, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x02, 0x69, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x63, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
|
||||
0x02, 0x63, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x03, 0x20, 0x01,
|
||||
0x28, 0x05, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2a, 0x9f, 0x01, 0x0a, 0x11, 0x42, 0x61,
|
||||
0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12,
|
||||
0x0d, 0x0a, 0x09, 0x41, 0x74, 0x74, 0x61, 0x63, 0x6b, 0x57, 0x69, 0x6e, 0x10, 0x00, 0x12, 0x0e,
|
||||
0x0a, 0x0a, 0x41, 0x74, 0x74, 0x61, 0x63, 0x6b, 0x4c, 0x6f, 0x73, 0x74, 0x10, 0x01, 0x12, 0x0e,
|
||||
0x0a, 0x0a, 0x44, 0x65, 0x66, 0x65, 0x6e, 0x64, 0x6b, 0x57, 0x69, 0x6e, 0x10, 0x02, 0x12, 0x0e,
|
||||
0x0a, 0x0a, 0x44, 0x65, 0x66, 0x65, 0x6e, 0x64, 0x4c, 0x6f, 0x73, 0x74, 0x10, 0x03, 0x12, 0x12,
|
||||
0x0a, 0x0e, 0x57, 0x61, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x67, 0x65,
|
||||
0x10, 0x04, 0x12, 0x11, 0x0a, 0x0d, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x67, 0x65, 0x46, 0x61, 0x69,
|
||||
0x6c, 0x65, 0x64, 0x10, 0x05, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x67, 0x65,
|
||||
0x53, 0x75, 0x63, 0x63, 0x65, 0x65, 0x64, 0x65, 0x64, 0x10, 0x06, 0x12, 0x0e, 0x0a, 0x0a, 0x52,
|
||||
0x65, 0x76, 0x65, 0x6e, 0x67, 0x65, 0x45, 0x6e, 0x64, 0x10, 0x07, 0x42, 0x06, 0x5a, 0x04, 0x2e,
|
||||
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x28, 0x05, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x22, 0x44, 0x0a, 0x14, 0x52, 0x50, 0x43,
|
||||
0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x52, 0x65,
|
||||
0x71, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
|
||||
0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x2a,
|
||||
0x9f, 0x01, 0x0a, 0x11, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64,
|
||||
0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0d, 0x0a, 0x09, 0x41, 0x74, 0x74, 0x61, 0x63, 0x6b, 0x57,
|
||||
0x69, 0x6e, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x41, 0x74, 0x74, 0x61, 0x63, 0x6b, 0x4c, 0x6f,
|
||||
0x73, 0x74, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x44, 0x65, 0x66, 0x65, 0x6e, 0x64, 0x6b, 0x57,
|
||||
0x69, 0x6e, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x44, 0x65, 0x66, 0x65, 0x6e, 0x64, 0x4c, 0x6f,
|
||||
0x73, 0x74, 0x10, 0x03, 0x12, 0x12, 0x0a, 0x0e, 0x57, 0x61, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x52,
|
||||
0x65, 0x76, 0x65, 0x6e, 0x67, 0x65, 0x10, 0x04, 0x12, 0x11, 0x0a, 0x0d, 0x52, 0x65, 0x76, 0x65,
|
||||
0x6e, 0x67, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10, 0x05, 0x12, 0x14, 0x0a, 0x10, 0x52,
|
||||
0x65, 0x76, 0x65, 0x6e, 0x67, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65, 0x65, 0x64, 0x65, 0x64, 0x10,
|
||||
0x06, 0x12, 0x0e, 0x0a, 0x0a, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x67, 0x65, 0x45, 0x6e, 0x64, 0x10,
|
||||
0x07, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -881,7 +942,7 @@ func file_arena_arena_db_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_arena_arena_db_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_arena_arena_db_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
||||
var file_arena_arena_db_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
var file_arena_arena_db_proto_goTypes = []interface{}{
|
||||
(BattleRecordState)(0), // 0: BattleRecordState
|
||||
(*DBPlayerBattleFormt)(nil), // 1: DBPlayerBattleFormt
|
||||
@ -890,18 +951,19 @@ var file_arena_arena_db_proto_goTypes = []interface{}{
|
||||
(*DBArenaBattleRecord)(nil), // 4: DBArenaBattleRecord
|
||||
(*DBArenaUser)(nil), // 5: DBArenaUser
|
||||
(*DBNpc)(nil), // 6: DBNpc
|
||||
nil, // 7: DBArenaUser.NpcEntry
|
||||
(*DBHero)(nil), // 8: DBHero
|
||||
(*RPCModifyIntegralReq)(nil), // 7: RPCModifyIntegralReq
|
||||
nil, // 8: DBArenaUser.NpcEntry
|
||||
(*DBHero)(nil), // 9: DBHero
|
||||
}
|
||||
var file_arena_arena_db_proto_depIdxs = []int32{
|
||||
8, // 0: DBPlayerBattleFormt.formt:type_name -> DBHero
|
||||
9, // 0: DBPlayerBattleFormt.formt:type_name -> DBHero
|
||||
1, // 1: ArenaPlayer.defend:type_name -> DBPlayerBattleFormt
|
||||
3, // 2: DBArenaBattleRecord.formt:type_name -> DBHeroBase
|
||||
0, // 3: DBArenaBattleRecord.State:type_name -> BattleRecordState
|
||||
1, // 4: DBArenaUser.attack:type_name -> DBPlayerBattleFormt
|
||||
1, // 5: DBArenaUser.defend:type_name -> DBPlayerBattleFormt
|
||||
4, // 6: DBArenaUser.record:type_name -> DBArenaBattleRecord
|
||||
7, // 7: DBArenaUser.npc:type_name -> DBArenaUser.NpcEntry
|
||||
8, // 7: DBArenaUser.npc:type_name -> DBArenaUser.NpcEntry
|
||||
6, // 8: DBArenaUser.NpcEntry.value:type_name -> DBNpc
|
||||
9, // [9:9] is the sub-list for method output_type
|
||||
9, // [9:9] is the sub-list for method input_type
|
||||
@ -989,6 +1051,18 @@ func file_arena_arena_db_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_arena_arena_db_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*RPCModifyIntegralReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@ -996,7 +1070,7 @@ func file_arena_arena_db_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_arena_arena_db_proto_rawDesc,
|
||||
NumEnums: 1,
|
||||
NumMessages: 7,
|
||||
NumMessages: 8,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
@ -292,6 +292,62 @@ func (x *DBUserMFantasy) GetLastrtickettime() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
//RPC 触发请求
|
||||
type RPCTargetMFReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` //用户id
|
||||
Boosid string `protobuf:"bytes,2,opt,name=boosid,proto3" json:"boosid"` //怪物id
|
||||
}
|
||||
|
||||
func (x *RPCTargetMFReq) Reset() {
|
||||
*x = RPCTargetMFReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_moonfantasy_moonfantasy_db_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *RPCTargetMFReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RPCTargetMFReq) ProtoMessage() {}
|
||||
|
||||
func (x *RPCTargetMFReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_moonfantasy_moonfantasy_db_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use RPCTargetMFReq.ProtoReflect.Descriptor instead.
|
||||
func (*RPCTargetMFReq) Descriptor() ([]byte, []int) {
|
||||
return file_moonfantasy_moonfantasy_db_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *RPCTargetMFReq) GetUid() string {
|
||||
if x != nil {
|
||||
return x.Uid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RPCTargetMFReq) GetBoosid() string {
|
||||
if x != nil {
|
||||
return x.Boosid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_moonfantasy_moonfantasy_db_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_moonfantasy_moonfantasy_db_proto_rawDesc = []byte{
|
||||
@ -333,8 +389,12 @@ var file_moonfantasy_moonfantasy_db_proto_rawDesc = []byte{
|
||||
0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x54, 0x72, 0x69, 0x67,
|
||||
0x67, 0x65, 0x72, 0x12, 0x28, 0x0a, 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x72, 0x74, 0x69, 0x63, 0x6b,
|
||||
0x65, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x6c, 0x61,
|
||||
0x73, 0x74, 0x72, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x42, 0x06, 0x5a,
|
||||
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x73, 0x74, 0x72, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x3a, 0x0a,
|
||||
0x0e, 0x52, 0x50, 0x43, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4d, 0x46, 0x52, 0x65, 0x71, 0x12,
|
||||
0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69,
|
||||
0x64, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x6f, 0x6f, 0x73, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x06, 0x62, 0x6f, 0x6f, 0x73, 0x69, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70,
|
||||
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -349,16 +409,17 @@ func file_moonfantasy_moonfantasy_db_proto_rawDescGZIP() []byte {
|
||||
return file_moonfantasy_moonfantasy_db_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_moonfantasy_moonfantasy_db_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_moonfantasy_moonfantasy_db_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||
var file_moonfantasy_moonfantasy_db_proto_goTypes = []interface{}{
|
||||
(*UserInfo)(nil), // 0: UserInfo
|
||||
(*DBMoonFantasy)(nil), // 1: DBMoonFantasy
|
||||
(*DBUserMFantasy)(nil), // 2: DBUserMFantasy
|
||||
nil, // 3: DBMoonFantasy.RecordEntry
|
||||
(*RPCTargetMFReq)(nil), // 3: RPCTargetMFReq
|
||||
nil, // 4: DBMoonFantasy.RecordEntry
|
||||
}
|
||||
var file_moonfantasy_moonfantasy_db_proto_depIdxs = []int32{
|
||||
0, // 0: DBMoonFantasy.join:type_name -> UserInfo
|
||||
3, // 1: DBMoonFantasy.record:type_name -> DBMoonFantasy.RecordEntry
|
||||
4, // 1: DBMoonFantasy.record:type_name -> DBMoonFantasy.RecordEntry
|
||||
2, // [2:2] is the sub-list for method output_type
|
||||
2, // [2:2] is the sub-list for method input_type
|
||||
2, // [2:2] is the sub-list for extension type_name
|
||||
@ -408,6 +469,18 @@ func file_moonfantasy_moonfantasy_db_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_moonfantasy_moonfantasy_db_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*RPCTargetMFReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@ -415,7 +488,7 @@ func file_moonfantasy_moonfantasy_db_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_moonfantasy_moonfantasy_db_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 4,
|
||||
NumMessages: 5,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"io/ioutil"
|
||||
@ -33,6 +34,7 @@ var confCmd = &cobra.Command{
|
||||
Use: "conf",
|
||||
Short: "生成配置",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
lego.Recover("conf")
|
||||
conf()
|
||||
},
|
||||
}
|
||||
@ -40,6 +42,7 @@ var startCmd = &cobra.Command{
|
||||
Use: "start",
|
||||
Short: "启动程序",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
lego.Recover("start")
|
||||
start()
|
||||
},
|
||||
}
|
||||
@ -47,6 +50,7 @@ var stopCmd = &cobra.Command{
|
||||
Use: "stop",
|
||||
Short: "关闭程序",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
lego.Recover("stop")
|
||||
stop()
|
||||
},
|
||||
}
|
||||
@ -54,6 +58,7 @@ var restart = &cobra.Command{
|
||||
Use: "restart",
|
||||
Short: "重启服务",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
lego.Recover("restart")
|
||||
stop()
|
||||
start()
|
||||
},
|
||||
@ -92,7 +97,7 @@ func main() {
|
||||
//执行命令
|
||||
func Execute() {
|
||||
if err := RootCmd.Execute(); err != nil {
|
||||
fmt.Fprintln(os.Stdin, err)
|
||||
log.Errorln(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
@ -115,6 +120,7 @@ func conf() {
|
||||
}
|
||||
}
|
||||
}
|
||||
log.Errorf("conf succ!")
|
||||
}
|
||||
|
||||
//启动程序
|
||||
@ -179,6 +185,7 @@ func start() {
|
||||
}
|
||||
}
|
||||
}
|
||||
log.Errorf("start succ!")
|
||||
}
|
||||
|
||||
//关闭程序
|
||||
@ -197,6 +204,7 @@ func stop() {
|
||||
}
|
||||
}
|
||||
}
|
||||
log.Errorf("stop succ!")
|
||||
}
|
||||
|
||||
///转换区服配置到服务配置
|
||||
@ -211,7 +219,7 @@ func rederServiceSttings(config *comm.GameConfig) (ss []*core.ServiceSttings, er
|
||||
if ip, port, err = parseaddr(config.Mainte); err != nil {
|
||||
return
|
||||
} else {
|
||||
if sseting, err = convertServiceSttings(config, 0, comm.Service_Mainte, ip, config.MaintePort, port); err != nil {
|
||||
if sseting, err = convertServiceSttings(config, 0, comm.Service_Mainte, ip, config.MaintePort, port, config.OpenServiceTime); err != nil {
|
||||
return
|
||||
}
|
||||
ss = append(ss, sseting)
|
||||
@ -221,7 +229,7 @@ func rederServiceSttings(config *comm.GameConfig) (ss []*core.ServiceSttings, er
|
||||
if ip, port, err = parseaddr(v); err != nil {
|
||||
return
|
||||
} else {
|
||||
if sseting, err = convertServiceSttings(config, i, comm.Service_Worker, ip, port, 0); err != nil {
|
||||
if sseting, err = convertServiceSttings(config, i, comm.Service_Worker, ip, port, 0, config.OpenServiceTime); err != nil {
|
||||
return
|
||||
}
|
||||
ss = append(ss, sseting)
|
||||
@ -231,7 +239,7 @@ func rederServiceSttings(config *comm.GameConfig) (ss []*core.ServiceSttings, er
|
||||
if ip, port, err = parseaddr(v); err != nil {
|
||||
return
|
||||
} else {
|
||||
if sseting, err = convertServiceSttings(config, i, comm.Service_Gateway, ip, config.GatewayPorts[i], port); err != nil {
|
||||
if sseting, err = convertServiceSttings(config, i, comm.Service_Gateway, ip, config.GatewayPorts[i], port, config.OpenServiceTime); err != nil {
|
||||
return
|
||||
}
|
||||
ss = append(ss, sseting)
|
||||
@ -260,11 +268,12 @@ func readergmconf(path string) (config *comm.GameConfig, err error) {
|
||||
}
|
||||
|
||||
//转换游戏服务配置
|
||||
func convertServiceSttings(config *comm.GameConfig, id int, stype string, ip string, rport int, lport int) (sseting *core.ServiceSttings, err error) {
|
||||
func convertServiceSttings(config *comm.GameConfig, id int, stype string, ip string, rport int, lport int, opentime string) (sseting *core.ServiceSttings, err error) {
|
||||
sseting = &core.ServiceSttings{}
|
||||
sseting.Tag = config.AreaId
|
||||
sseting.Ip = ip
|
||||
sseting.Port = rport
|
||||
sseting.Opentime = opentime
|
||||
sseting.Modules = make(map[string]map[string]interface{})
|
||||
sseting.Sys = make(map[string]map[string]interface{})
|
||||
sseting.Sys["rpcx"] = map[string]interface{}{
|
||||
@ -306,6 +315,7 @@ func convertServiceSttings(config *comm.GameConfig, id int, stype string, ip str
|
||||
}
|
||||
sseting.Sys["configure"] = map[string]interface{}{
|
||||
"ConfigurePath": "./json",
|
||||
"TimestampFile": "./timestamp.text",
|
||||
}
|
||||
sseting.Sys["wordfilter"] = map[string]interface{}{
|
||||
"WorldFile": "./wordfilter.json",
|
||||
|
@ -203,7 +203,14 @@ func (r *Robot) MessageRsp(mainType, subType string) (bool, int64) {
|
||||
}
|
||||
//fmt.Printf("接收消息=====loginData:%v,userExpand:%v\n", resp.Data, resp.Ex)
|
||||
return true, byteLen
|
||||
} else if msg.MainType == "goutmet" && msg.SubType == "getranduser" {
|
||||
} else if msg.MainType == "gourmet" && msg.SubType == "getranduser" {
|
||||
resp := &pb.GourmetGetRandUserResp{}
|
||||
if !comm.ProtoUnmarshal(msg, resp) {
|
||||
return false, byteLen
|
||||
}
|
||||
|
||||
return false, byteLen
|
||||
} else if msg.MainType == "gourmet" && msg.SubType == "getlist" {
|
||||
resp := &pb.GourmetGetRandUserResp{}
|
||||
if !comm.ProtoUnmarshal(msg, resp) {
|
||||
return false, byteLen
|
||||
@ -220,12 +227,12 @@ func (r *Robot) CloseHandler() {
|
||||
|
||||
}
|
||||
|
||||
func (r *Robot) GetMessagedata() []byte {
|
||||
_, data, err := r.ws.ReadMessage()
|
||||
func (r *Robot) GetMessagedata() (data []byte, err error) {
|
||||
_, data, err = r.ws.ReadMessage()
|
||||
if err != nil {
|
||||
fmt.Printf("readMessage err:%v", err)
|
||||
}
|
||||
return data
|
||||
return data, err
|
||||
}
|
||||
func (r *Robot) Login() error {
|
||||
msg := &pb.UserMessage{MainType: "user", SubType: "login"}
|
||||
@ -242,8 +249,8 @@ func (r *Robot) Login() error {
|
||||
}
|
||||
|
||||
func (r Robot) GetRandUser() bool {
|
||||
mainType := "goutmet"
|
||||
subType := "getlist"
|
||||
mainType := "gourmet"
|
||||
subType := "getranduser"
|
||||
msg := &pb.UserMessage{MainType: mainType, SubType: subType}
|
||||
|
||||
rsp := &pb.GourmetGetRandUserReq{
|
||||
@ -258,12 +265,12 @@ func (r Robot) GetRandUser() bool {
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < 100; i++ {
|
||||
for {
|
||||
if b, _ := r.MessageRsp(mainType, subType); b {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return true
|
||||
//return true
|
||||
}
|
||||
func (r *Robot) Create() bool {
|
||||
mainType := "user"
|
||||
@ -287,24 +294,22 @@ func (r *Robot) Create() bool {
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < 100; i++ { // 防止丢包
|
||||
for { // 防止丢包
|
||||
if b, _ := r.MessageRsp(mainType, subType); b {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
//return false
|
||||
}
|
||||
|
||||
// 获取美食家信息列表数据
|
||||
func (r Robot) GetGourmetList() int64 {
|
||||
var byteLen int64
|
||||
mainType := "goutmet"
|
||||
subType := "getranduser"
|
||||
func (r Robot) GetGourmetList() {
|
||||
|
||||
mainType := "gourmet"
|
||||
subType := "getlist"
|
||||
msg := &pb.UserMessage{MainType: mainType, SubType: subType}
|
||||
|
||||
rsp := &pb.GourmetGetRandUserReq{
|
||||
People: 3,
|
||||
}
|
||||
rsp := &pb.GourmetGetListReq{}
|
||||
msg.Sec = r.BuildSecStr()
|
||||
if comm.ProtoMarshal(rsp, msg) {
|
||||
data, _ := proto.Marshal(msg)
|
||||
@ -314,36 +319,37 @@ func (r Robot) GetGourmetList() int64 {
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < 100; i++ {
|
||||
var msg *pb.UserMessage = &pb.UserMessage{}
|
||||
_, data, err := r.ws.ReadMessage()
|
||||
if err != nil {
|
||||
fmt.Printf("readMessage err:%v", err)
|
||||
continue
|
||||
}
|
||||
byteLen += int64(len(data))
|
||||
if err = proto.Unmarshal(data, msg); err != nil {
|
||||
fmt.Printf("unmarshal err:%v", err)
|
||||
}
|
||||
if msg.MainType == "goutmet" && msg.SubType == "getlist" {
|
||||
resp := &pb.GourmetGetListResp{}
|
||||
if !comm.ProtoUnmarshal(msg, resp) { //反序列化失败
|
||||
break
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
return byteLen
|
||||
// for {
|
||||
// var msg *pb.UserMessage = &pb.UserMessage{}
|
||||
// _, data, err := r.ws.ReadMessage()
|
||||
// if err != nil {
|
||||
// fmt.Printf("readMessage err:%v", err)
|
||||
// continue
|
||||
// }
|
||||
|
||||
// if err = proto.Unmarshal(data, msg); err != nil {
|
||||
// fmt.Printf("unmarshal err:%v", err)
|
||||
// }
|
||||
// if msg.MainType == mainType && msg.SubType == subType {
|
||||
// byteLen += int64(len(data))
|
||||
// resp := &pb.GourmetGetListResp{}
|
||||
// if !comm.ProtoUnmarshal(msg, resp) { //反序列化失败
|
||||
// break
|
||||
// }
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
return
|
||||
}
|
||||
|
||||
// addItem
|
||||
func (r Robot) AddGrormetItem() {
|
||||
func (r Robot) AddGrormetItem() bool {
|
||||
mainType := "gm"
|
||||
subType := "cmd"
|
||||
msg := &pb.UserMessage{MainType: mainType, SubType: subType}
|
||||
|
||||
rsp := &pb.GMCmdReq{
|
||||
Cmod: "bingo:item,50001,100",
|
||||
Cmod: "bingo:item,10002,100",
|
||||
}
|
||||
msg.Sec = r.BuildSecStr()
|
||||
if comm.ProtoMarshal(rsp, msg) {
|
||||
@ -353,4 +359,8 @@ func (r Robot) AddGrormetItem() {
|
||||
fmt.Printf("WriteMessage err:%v", err)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (r *Robot) SetAccount(account string) {
|
||||
r.account = account
|
||||
}
|
||||
|
@ -4,8 +4,10 @@ package server
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/stress/model"
|
||||
"go_dreamfactory/stress/robot"
|
||||
"strconv"
|
||||
|
||||
"sync"
|
||||
"time"
|
||||
@ -53,7 +55,11 @@ func Dispose(ctx context.Context, concurrency, totalNumber uint64, request *mode
|
||||
case 1:
|
||||
// 连接以后再启动协程
|
||||
r := robot.NewRobot(request.URL)
|
||||
|
||||
r.SetAccount("00000" + strconv.Itoa(int(i)))
|
||||
head := &pb.UserMessage{MainType: "user", SubType: "login"}
|
||||
// 先登录
|
||||
r.SendToClient(head, &pb.UserLoginReq{})
|
||||
r.AddGrormetItem()
|
||||
go golink.WebSocket(ctx, i, ch, totalNumber, &wg, request, r)
|
||||
case 2:
|
||||
// 并发建立长链接
|
||||
|
@ -3,13 +3,17 @@ package golink
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/stress/helper"
|
||||
"go_dreamfactory/stress/model"
|
||||
"go_dreamfactory/stress/robot"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -23,7 +27,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
keepAlive = false
|
||||
keepAlive = true
|
||||
}
|
||||
|
||||
// WebSocket webSocket go link
|
||||
@ -75,24 +79,38 @@ func webSocketRequest(chanID uint64, ch chan<- *model.RequestResults, i uint64,
|
||||
errCode = model.HTTPOk
|
||||
byteLen int64 // 协议传输字节数
|
||||
)
|
||||
// 需要发送的数据
|
||||
head := &pb.UserMessage{MainType: "user", SubType: "login"}
|
||||
|
||||
r.SendToClient(head, &pb.UserLoginReq{})
|
||||
// 美食馆增加道具
|
||||
r.AddGrormetItem()
|
||||
// for {
|
||||
// if b, len := r.MessageRsp("user", "login"); b {
|
||||
// byteLen += len
|
||||
// isSucceed = true
|
||||
// //errCode, isSucceed = request.GetVerifyWebSocket()(request, "webSocket.pb", r.GetMessagedata())
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// r.Create()
|
||||
startTime := time.Now()
|
||||
//r.Create()
|
||||
//isSucceed = r.AddGrormetItem()
|
||||
|
||||
//startTime := time.Now()
|
||||
// r.GetRandUser() // 获取随机在线玩家数据
|
||||
byteLen = r.GetGourmetList()
|
||||
|
||||
r.GetGourmetList()
|
||||
|
||||
for {
|
||||
var msg *pb.UserMessage = &pb.UserMessage{}
|
||||
data, err := r.GetMessagedata()
|
||||
if err != nil {
|
||||
fmt.Printf("readMessage err:%v", err)
|
||||
isSucceed = false
|
||||
break
|
||||
}
|
||||
if err = proto.Unmarshal(data, msg); err != nil {
|
||||
fmt.Printf("unmarshal err:%v", err)
|
||||
}
|
||||
if msg.MainType == "gourmet" && msg.SubType == "getlist" {
|
||||
byteLen += int64(len(data))
|
||||
isSucceed = true
|
||||
resp := &pb.GourmetGetListResp{}
|
||||
if !comm.ProtoUnmarshal(msg, resp) { //反序列化失败
|
||||
break
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
requestTime := uint64(helper.DiffNano(startTime))
|
||||
requestResults := &model.RequestResults{
|
||||
ID: "",
|
||||
|
@ -233,7 +233,7 @@ func table(successNum, failureNum uint64, errCode *sync.Map,
|
||||
speedStr = p.Sprintf("%d", speed)
|
||||
}
|
||||
// 打印的时长都为毫秒
|
||||
result := fmt.Sprintf("%4.0fs│%7d│%7d│%7d│%8.2f│%8.2f│%8.2f│%8.2f│%8s│%8s│%v",
|
||||
result := fmt.Sprintf("%4.0fms│%7d│%7d│%7d│%8.2f│%8.2f│%8.2f│%8.2f│%8s│%8s│%v",
|
||||
requestTimeFloat, chanIDLen, successNum, failureNum, qps, maxTimeFloat, minTimeFloat, averageTime,
|
||||
receivedBytesStr, speedStr,
|
||||
printMap(errCode))
|
||||
|
@ -79,7 +79,7 @@ func main() {
|
||||
flag.Parse()
|
||||
statistics.InitLog()
|
||||
|
||||
concurrency = 12
|
||||
concurrency = 10
|
||||
totalNumber = 1
|
||||
debugStr = "false"
|
||||
requestURL = "ws://10.0.0.85:7891/gateway"
|
||||
|
Loading…
Reference in New Issue
Block a user