diff --git a/comm/imodule.go b/comm/imodule.go index d55087766..09d4896c1 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -26,9 +26,9 @@ type ( //查询用户背包多个物品数量 QueryItemsAmount(source *ModuleCallSource, uId string, itemid ...int32) (result map[int32]uint32) ///添加单个物品到背包 (可以加物品和减物品) - AddItem(source *ModuleCallSource, uId string, itemid, addnum int32, bPush bool) (code pb.ErrorCode) + AddItem(source *ModuleCallSource, session IUserSession, itemid, addnum int32, bPush bool) (code pb.ErrorCode) ///添加多个物品到背包 (可以加物品和减物品) - AddItems(source *ModuleCallSource, uId string, items map[int32]int32, bPush bool) (code pb.ErrorCode) + AddItems(source *ModuleCallSource, session IUserSession, items map[int32]int32, bPush bool) (code pb.ErrorCode) } //英雄 @@ -57,7 +57,7 @@ type ( //查询用户属性值 例如 金币 经验 QueryAttributeValue(uid string, attr string) (value int32) //添加/减少属性值 第四个参数控制是否推送给前端 - AddAttributeValue(uid string, attr string, add int32, bPush bool) (code pb.ErrorCode) + AddAttributeValue(session IUserSession, attr string, add int32, bPush bool) (code pb.ErrorCode) } //武器模块 IEquipment interface { @@ -66,7 +66,7 @@ type ( //查询服务资源数量 参数武器配置id QueryEquipmentAmount(source *ModuleCallSource, uid string, equipmentId int32) (amount uint32) //添加新武器 - AddNewEquipments(source *ModuleCallSource, uid string, cIds map[int32]uint32, bPush bool) (code pb.ErrorCode) + AddNewEquipments(source *ModuleCallSource, session IUserSession, cIds map[int32]uint32, bPush bool) (code pb.ErrorCode) } IMainline interface { // 修改章节信息 diff --git a/modules/equipment/api_upgrade.go b/modules/equipment/api_upgrade.go index e29a2900f..03a9559ea 100644 --- a/modules/equipment/api_upgrade.go +++ b/modules/equipment/api_upgrade.go @@ -71,7 +71,7 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade } } if issucc { - if code = this.module.CheckConsumeRes(session.GetUserId(), intensify.Need, true); code != pb.ErrorCode_Success { + if code = this.module.CheckConsumeRes(session, intensify.Need, true); code != pb.ErrorCode_Success { return } modifyequipments = make([]*pb.DB_Equipment, 0) diff --git a/modules/equipment/module.go b/modules/equipment/module.go index 656f02fc4..233de3462 100644 --- a/modules/equipment/module.go +++ b/modules/equipment/module.go @@ -80,28 +80,27 @@ func (this *Equipment) QueryEquipmentAmount(source *comm.ModuleCallSource, uid s } //添加武器 -func (this *Equipment) AddNewEquipments(source *comm.ModuleCallSource, uid string, cIds map[int32]uint32, bPush bool) (code pb.ErrorCode) { +func (this *Equipment) AddNewEquipments(source *comm.ModuleCallSource, session comm.IUserSession, cIds map[int32]uint32, bPush bool) (code pb.ErrorCode) { var ( err error change []*pb.DB_Equipment ) - if change, err = this.modelEquipment.AddEquipments(uid, cIds); err != nil { + if change, err = this.modelEquipment.AddEquipments(session.GetUserId(), cIds); err != nil { log.Errorf("err%v", err) code = pb.ErrorCode_SystemError return } if len(change) > 0 && bPush { - this.equipmentsChangePush(uid, change) + this.equipmentsChangePush(session, change) } return } //Evens-------------------------------------------------------------------------------------------------------------------------------- //推送道具变化消息 -func (this *Equipment) equipmentsChangePush(uid string, items []*pb.DB_Equipment) (err error) { - if session, ok := this.GetUserSession(uid); ok { - session.SendMsg(string(this.GetType()), "change", &pb.EquipmentChangePush{Equipments: items}) - err = session.Push() - } +func (this *Equipment) equipmentsChangePush(session comm.IUserSession, items []*pb.DB_Equipment) (err error) { + + session.SendMsg(string(this.GetType()), "change", &pb.EquipmentChangePush{Equipments: items}) + return } diff --git a/modules/equipment/module_test.go b/modules/equipment/module_test.go index cf7d61e87..06eab8365 100644 --- a/modules/equipment/module_test.go +++ b/modules/equipment/module_test.go @@ -98,12 +98,12 @@ func Test_Modules_EquipmentUpgradeReq(t *testing.T) { //添加武器测试 func Test_Module_AddNewEquipments(t *testing.T) { - code := module.AddNewEquipments(&comm.ModuleCallSource{ - Module: "Test", - FuncName: "Test_Module", - Describe: "摸底测试", - }, "0_62b16dda909b2f8faeff788d", map[int32]uint32{10001: 1}, true) - log.Debugf("Test_Module Code:%d", code) + // code := module.AddNewEquipments(&comm.ModuleCallSource{ + // Module: "Test", + // FuncName: "Test_Module", + // Describe: "摸底测试", + // }, "0_62b16dda909b2f8faeff788d", map[int32]uint32{10001: 1}, true) + // log.Debugf("Test_Module Code:%d", code) } //查询武器信息 diff --git a/modules/hero/api_awaken.go b/modules/hero/api_awaken.go index b06d3199a..a3a4a0c34 100644 --- a/modules/hero/api_awaken.go +++ b/modules/hero/api_awaken.go @@ -55,7 +55,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c return } // 消耗校验 - code = this.module.CheckConsumeRes(session.GetUserId(), awakenData.Phaseneed, true) + code = this.module.CheckConsumeRes(session, awakenData.Phaseneed, true) if code != pb.ErrorCode_Success { return } diff --git a/modules/hero/api_resonance.go b/modules/hero/api_resonance.go index 755ba923f..44f499ffb 100644 --- a/modules/hero/api_resonance.go +++ b/modules/hero/api_resonance.go @@ -93,7 +93,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR return } // 消耗校验 - code = this.module.CheckConsumeRes(session.GetUserId(), resonConfig.Need, true) + code = this.module.CheckConsumeRes(session, resonConfig.Need, true) if code != pb.ErrorCode_Success { return } diff --git a/modules/hero/api_resonanceReset.go b/modules/hero/api_resonanceReset.go index fcb26c1b9..18a74815d 100644 --- a/modules/hero/api_resonanceReset.go +++ b/modules/hero/api_resonanceReset.go @@ -56,7 +56,7 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson return } // 消耗校验 - code = this.module.CheckConsumeRes(session.GetUserId(), _costConfig.Var, true) + code = this.module.CheckConsumeRes(session, _costConfig.Var, true) if code != pb.ErrorCode_Success { return } diff --git a/modules/hero/api_starUp.go b/modules/hero/api_starUp.go index 33636ba8a..91f7a6dc0 100644 --- a/modules/hero/api_starUp.go +++ b/modules/hero/api_starUp.go @@ -124,7 +124,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr } // 消耗道具 - code = this.module.ModuleUser.AddAttributeValue(session.GetUserId(), "gold", -target.Gold, true) // 减少金币 + code = this.module.ModuleUser.AddAttributeValue(session, "gold", -target.Gold, true) // 减少金币 if code != pb.ErrorCode_Success { this.module.Errorf("cost gold failed ,count = %d", target.Gold) code = pb.ErrorCode_GoldNoEnough diff --git a/modules/hero/api_strengthen.go b/modules/hero/api_strengthen.go index cc9dafea4..ed0439a98 100644 --- a/modules/hero/api_strengthen.go +++ b/modules/hero/api_strengthen.go @@ -145,7 +145,7 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren N: costGold, } res = append(res, _d) - code = this.module.CheckConsumeRes(session.GetUserId(), res, true) + code = this.module.CheckConsumeRes(session, res, true) if code != pb.ErrorCode_Success { return } @@ -154,7 +154,7 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren code = this.module.AddCardExp(session.GetUserId(), req.HeroObjID, addExp) // 加经验 if code != pb.ErrorCode_Success { // 升级失败资源回退 - code = this.module.DispenseRes(session.GetUserId(), res, true) + code = this.module.DispenseRes(session, res, true) return } diff --git a/modules/items/module.go b/modules/items/module.go index ce2aab871..bcf5dab06 100644 --- a/modules/items/module.go +++ b/modules/items/module.go @@ -62,14 +62,14 @@ func (this *Items) QueryItemsAmount(source *comm.ModuleCallSource, uId string, i } ///添加单个物品到背包 (可以加物品和减物品) -func (this *Items) AddItem(source *comm.ModuleCallSource, uId string, itemid, addnum int32, bPush bool) (code pb.ErrorCode) { +func (this *Items) AddItem(source *comm.ModuleCallSource, session comm.IUserSession, itemid, addnum int32, bPush bool) (code pb.ErrorCode) { var ( err error change []*pb.DB_UserItemData ) - defer this.Debugf("给用户添加物品 uId:%s itemid:%d addnum:%d issucc:%v", uId, itemid, addnum, err == nil) - if change, err = this.modelItems.Pack_AddItemToUserPack(uId, itemid, addnum); err != nil { - this.Errorf("给用户添加物品 uId:%s itemid:%d addnum:%d err:%v", uId, itemid, addnum, err) + defer this.Debugf("给用户添加物品 uId:%s itemid:%d addnum:%d issucc:%v", session.GetUserId(), itemid, addnum, err == nil) + if change, err = this.modelItems.Pack_AddItemToUserPack(session.GetUserId(), itemid, addnum); err != nil { + this.Errorf("给用户添加物品 uId:%s itemid:%d addnum:%d err:%v", session.GetUserId(), itemid, addnum, err) if err == ItemNotEnoughError { code = pb.ErrorCode_ItemsNoEnough } else if err == PackGridNumUpper { @@ -80,22 +80,22 @@ func (this *Items) AddItem(source *comm.ModuleCallSource, uId string, itemid, ad return } if bPush { - this.itemsChangePush(uId, change) //推送道具背包变化 + this.itemsChangePush(session, change) //推送道具背包变化 } return } ///添加多个物品到背包 (可以加物品和减物品) -func (this *Items) AddItems(source *comm.ModuleCallSource, uId string, items map[int32]int32, bPush bool) (code pb.ErrorCode) { +func (this *Items) AddItems(source *comm.ModuleCallSource, session comm.IUserSession, items map[int32]int32, bPush bool) (code pb.ErrorCode) { var ( err error change []*pb.DB_UserItemData ) - defer this.Debugf("给用户添加物品 uId:%s items:%d items:%v", uId, items, err == nil) - if change, err = this.modelItems.Pack_AddItemsToUserPack(uId, items); err != nil { - this.Errorf("给用户添加物品 uId:%s items:%d err:%v", uId, items, err) + defer this.Debugf("给用户添加物品 uId:%s items:%d items:%v", session.GetUserId(), items, err == nil) + if change, err = this.modelItems.Pack_AddItemsToUserPack(session.GetUserId(), items); err != nil { + this.Errorf("给用户添加物品 uId:%s items:%d err:%v", session.GetUserId(), items, err) if err == ItemNotEnoughError { code = pb.ErrorCode_ItemsNoEnough } else if err == PackGridNumUpper { @@ -106,17 +106,15 @@ func (this *Items) AddItems(source *comm.ModuleCallSource, uId string, items map return } if len(change) > 0 && bPush { - this.itemsChangePush(uId, change) //推送道具背包变化 + this.itemsChangePush(session, change) //推送道具背包变化 } return } //Evens-------------------------------------------------------------------------------------------------------------------------------- //推送道具变化消息 -func (this *Items) itemsChangePush(uid string, items []*pb.DB_UserItemData) (err error) { - if session, ok := this.GetUserSession(uid); ok { - session.SendMsg(string(this.GetType()), "change", &pb.ItemsChangePush{Grids: items}) - err = session.Push() - } +func (this *Items) itemsChangePush(session comm.IUserSession, items []*pb.DB_UserItemData) (err error) { + + session.SendMsg(string(this.GetType()), "change", &pb.ItemsChangePush{Grids: items}) return } diff --git a/modules/items/module_test.go b/modules/items/module_test.go index 9ce8b44e8..8cdda0637 100644 --- a/modules/items/module_test.go +++ b/modules/items/module_test.go @@ -90,10 +90,10 @@ func Test_Modules(t *testing.T) { } func Test_Modules_AddItems(t *testing.T) { - code := module.AddItems(&comm.ModuleCallSource{ - Module: "Test", - FuncName: "Test_Modules_AddItems", - Describe: "测试模块接口", - }, "0_62c259916d8cf3e4e06311a8", map[int32]int32{10001: 1000}, true) - log.Debugf("Test_Modules_AddItems code:%v", code) + // code := module.AddItems(&comm.ModuleCallSource{ + // Module: "Test", + // FuncName: "Test_Modules_AddItems", + // Describe: "测试模块接口", + // }, "0_62c259916d8cf3e4e06311a8", map[int32]int32{10001: 1000}, true) + // log.Debugf("Test_Modules_AddItems code:%v", code) } diff --git a/modules/mail/api_getAttachment.go b/modules/mail/api_getAttachment.go index eef1184ee..cd0f6414e 100644 --- a/modules/mail/api_getAttachment.go +++ b/modules/mail/api_getAttachment.go @@ -46,7 +46,7 @@ func (this *apiComp) GetUserMailAttachment(session comm.IUserSession, req *pb.Ma } res = append(res, d) } - code = this.module.api.module.CheckConsumeRes(session.GetUserId(), res, true) // 领取附件 + code = this.module.api.module.CheckConsumeRes(session, res, true) // 领取附件 if code == pb.ErrorCode_Success { // 修改状态 this.module.modelMail.Mail_UpdateMailAttachmentState(req.ObjID) diff --git a/modules/modulebase.go b/modules/modulebase.go index ada1c8d48..7cd18edf7 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -138,7 +138,7 @@ func (this *ModuleBase) SendMsgToUsers(mainType, subType string, msg proto.Messa } //校验消耗资源 -func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn, bPush bool) (code pb.ErrorCode) { +func (this *ModuleBase) CheckConsumeRes(session comm.IUserSession, res []*cfg.Game_atn, bPush bool) (code pb.ErrorCode) { var ( err error resID int @@ -153,7 +153,7 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn, bPush b //校验消费资源是否充足 for _, v := range res { if v.A == comm.AttrType { //用户属性资源 - if amount = this.ModuleUser.QueryAttributeValue(uid, v.T); amount < v.N { + if amount = this.ModuleUser.QueryAttributeValue(session.GetUserId(), v.T); amount < v.N { code = pb.ErrorCode_ResNoEnough this.Errorf("道具不足:A:%s,T:%s,N:%d", v.A, v.T, v.N) return @@ -163,7 +163,7 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn, bPush b code = pb.ErrorCode_ConfigurationException return } - if amount = int32(this.ModuleItems.QueryItemAmount(source, uid, int32(resID))); amount < v.N { + if amount = int32(this.ModuleItems.QueryItemAmount(source, session.GetSessionId(), int32(resID))); amount < v.N { code = pb.ErrorCode_ResNoEnough this.Errorf("道具不足:A:%s,T:%s,N:%d", v.A, v.T, v.N) return @@ -194,10 +194,10 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn, bPush b for _, v := range res { if v.A == comm.AttrType { //用户属性资源 - this.ModuleUser.AddAttributeValue(uid, v.T, -1*v.N, bPush) + this.ModuleUser.AddAttributeValue(session, v.T, -1*v.N, bPush) } else if v.A == comm.ItemType { //道具资源 resID, _ = strconv.Atoi(v.T) - this.ModuleItems.AddItem(source, uid, int32(resID), -1*v.N, bPush) + this.ModuleItems.AddItem(source, session, int32(resID), -1*v.N, bPush) } // else if v.A == comm.HeroType { //卡片资源 // resID, _ = strconv.Atoi(v.T) @@ -213,7 +213,7 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn, bPush b } //发放资源 -func (this *ModuleBase) DispenseRes(uid string, res []*cfg.Game_atn, bPush bool) (code pb.ErrorCode) { +func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Game_atn, bPush bool) (code pb.ErrorCode) { var ( resID int ) @@ -225,30 +225,31 @@ func (this *ModuleBase) DispenseRes(uid string, res []*cfg.Game_atn, bPush bool) for _, v := range res { this.Debugf("发放资源 DispenseRes:A = %s, T:%s, N:%d", v.A, v.T, v.N) if v.A == comm.AttrType { //用户属性资源 - code = this.ModuleUser.AddAttributeValue(uid, v.T, v.N, bPush) + code = this.ModuleUser.AddAttributeValue(session, v.T, v.N, bPush) } else if v.A == comm.ItemType { //道具资源 resID = cast.ToInt(v.T) // resID, _ = strconv.Atoi(v.T) - code = this.ModuleItems.AddItem(source, uid, int32(resID), v.N, bPush) + code = this.ModuleItems.AddItem(source, session, int32(resID), v.N, bPush) } else if v.A == comm.HeroType { //卡片资源 resID, _ = strconv.Atoi(v.T) - hero, err := this.ModuleHero.CreateRepeatHero(uid, int32(resID), v.N) + hero, err := this.ModuleHero.CreateRepeatHero(session.GetUserId(), int32(resID), v.N) if err != nil { code = pb.ErrorCode_HeroMaxCount } // 创建英雄成功 向客户端推送数据 - if bPush { - if session, ok := this.GetUserSession(uid); ok { - session.SendMsg("hero", "addnewhero", &pb.HeroAddNewHeroPush{Hero: hero, Count: v.N}) - err = session.Push() - } - } + session.SendMsg("hero", "addnewhero", &pb.HeroAddNewHeroPush{Hero: hero, Count: v.N}) + // if bPush { + // if session, ok := this.GetUserSession(uid); ok { + // session.SendMsg("hero", "addnewhero", &pb.HeroAddNewHeroPush{Hero: hero, Count: v.N}) + // err = session.Push() + // } + // } } else if v.A == comm.EquipmentType { resID, _ = strconv.Atoi(v.T) - code = this.ModuleEquipment.AddNewEquipments(source, uid, map[int32]uint32{int32(resID): uint32(v.N)}, bPush) + code = this.ModuleEquipment.AddNewEquipments(source, session, map[int32]uint32{int32(resID): uint32(v.N)}, bPush) } } return diff --git a/modules/shop/api_buy.go b/modules/shop/api_buy.go index c551ba78e..6fd388972 100644 --- a/modules/shop/api_buy.go +++ b/modules/shop/api_buy.go @@ -45,10 +45,10 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (code pb } } - if code = this.module.CheckConsumeRes(session.GetUserId(), conf.Need, true); code != pb.ErrorCode_Success { + if code = this.module.CheckConsumeRes(session, conf.Need, true); code != pb.ErrorCode_Success { return } - if code = this.module.DispenseRes(session.GetUserId(), conf.Iteminfo, true); code != pb.ErrorCode_Success { + if code = this.module.DispenseRes(session, conf.Iteminfo, true); code != pb.ErrorCode_Success { return } shopitem.BuyNum++ diff --git a/modules/shop/api_getlist.go b/modules/shop/api_getlist.go index 537ffbba7..00fcc72f2 100644 --- a/modules/shop/api_getlist.go +++ b/modules/shop/api_getlist.go @@ -94,7 +94,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq) } if req.IsManualRefresh && shopconf.Rtype == 1 { //可以手动刷新 - if code = this.module.CheckConsumeRes(session.GetUserId(), shopconf.Rneed, true); code != pb.ErrorCode_Success { + if code = this.module.CheckConsumeRes(session, shopconf.Rneed, true); code != pb.ErrorCode_Success { return } var _items []*cfg.Game_shopitemData diff --git a/modules/task/api_activereceive.go b/modules/task/api_activereceive.go index 325dcd87c..c3c1c73d9 100644 --- a/modules/task/api_activereceive.go +++ b/modules/task/api_activereceive.go @@ -50,6 +50,6 @@ func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActive } //派发奖励 - code = this.moduleTask.DispenseRes(session.GetUserId(), conf.Reword, true) + code = this.moduleTask.DispenseRes(session, conf.Reword, true) return } diff --git a/modules/task/api_receive.go b/modules/task/api_receive.go index b39312e77..9c049cc5a 100644 --- a/modules/task/api_receive.go +++ b/modules/task/api_receive.go @@ -33,7 +33,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq) userTask := this.moduleTask.modelTask.getUserTask(session.GetUserId(), comm.TaskTag(req.TaskTag), req.Id) if userTask != nil { //判断是否完成 - if userTask.Status == 0{ + if userTask.Status == 0 { code = pb.ErrorCode_TaskHandle return } @@ -50,7 +50,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq) } //奖励 - if code = this.moduleTask.CheckConsumeRes(session.GetUserId(), conf.Reword, true); code != pb.ErrorCode_Success { + if code = this.moduleTask.CheckConsumeRes(session, conf.Reword, true); code != pb.ErrorCode_Success { return } diff --git a/modules/user/api_res.go b/modules/user/api_res.go index f6f09b5a2..6e0ca029e 100644 --- a/modules/user/api_res.go +++ b/modules/user/api_res.go @@ -32,7 +32,7 @@ func (this *apiComp) AddRes(session comm.IUserSession, req *pb.UserAddResReq) (c N: req.Res.N, } res = append(res, atn) - code = this.module.DispenseRes(session.GetUserId(), res, true) + code = this.module.DispenseRes(session, res, true) if code == pb.ErrorCode_Success { rsp := &pb.UserAddResResp{ Res: req.Res, diff --git a/modules/user/module.go b/modules/user/module.go index c5a86ca80..09aab48b7 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -74,13 +74,13 @@ func (this *User) QueryAttributeValue(uid string, attr string) (value int32) { } //用户资源 -func (this *User) AddAttributeValue(uid string, attr string, add int32, bPush bool) (code pb.ErrorCode) { +func (this *User) AddAttributeValue(session comm.IUserSession, attr string, add int32, bPush bool) (code pb.ErrorCode) { if add == 0 { - log.Errorf("attr no changed,uid: %s attr: %s add: %d", uid, attr, add) + log.Errorf("attr no changed,uid: %s attr: %s add: %d", session.GetUserId(), attr, add) code = pb.ErrorCode_ReqParameterError return } - user := this.GetUser(uid) + user := this.GetUser(session.GetUserId()) if user == nil { code = pb.ErrorCode_UserSessionNobeing return @@ -129,28 +129,26 @@ func (this *User) AddAttributeValue(uid string, attr string, add int32, bPush bo if len(update) == 0 { return } - if err := this.modelUser.updateUserAttr(uid, update); err != nil { + if err := this.modelUser.updateUserAttr(session.GetUserId(), update); err != nil { log.Errorf("AddAttributeValue err:%v", err) code = pb.ErrorCode_DBError } data := &pb.UserResChangePush{} var _cache = &pb.CacheUser{} - err := this.modelUser.MCompModel.Get(uid, _cache) + err := this.modelUser.MCompModel.Get(session.GetUserId(), _cache) if err != nil { this.SendMsgToUser(string(this.GetType()), "reschange", data, _cache) } if bPush { - this.UserChangePush(uid, _change) // 推送玩家数据变化 + this.UserChangePush(session, _change) // 推送玩家数据变化 } return } //推送玩家账号信息变化消息 -func (this *User) UserChangePush(uid string, resChange *pb.UserResChangePush) (err error) { - if session, ok := this.ModuleBase.GetUserSession(uid); ok { - session.SendMsg(string(this.GetType()), "reschange", resChange) - err = session.Push() - } +func (this *User) UserChangePush(session comm.IUserSession, resChange *pb.UserResChangePush) (err error) { + + session.SendMsg(string(this.GetType()), "reschange", resChange) return } diff --git a/pb/hero_msg.pb.go b/pb/hero_msg.pb.go index edc6d176d..07f70c2f1 100644 --- a/pb/hero_msg.pb.go +++ b/pb/hero_msg.pb.go @@ -1490,6 +1490,53 @@ func (x *HeroGetSpecifiedResp) GetHero() *DBHero { return nil } +type HeroDelNewHeroPush struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Heros map[string]int32 `protobuf:"bytes,1,rep,name=heros,proto3" json:"heros" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` +} + +func (x *HeroDelNewHeroPush) Reset() { + *x = HeroDelNewHeroPush{} + if protoimpl.UnsafeEnabled { + mi := &file_hero_hero_msg_proto_msgTypes[28] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HeroDelNewHeroPush) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeroDelNewHeroPush) ProtoMessage() {} + +func (x *HeroDelNewHeroPush) ProtoReflect() protoreflect.Message { + mi := &file_hero_hero_msg_proto_msgTypes[28] + 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 HeroDelNewHeroPush.ProtoReflect.Descriptor instead. +func (*HeroDelNewHeroPush) Descriptor() ([]byte, []int) { + return file_hero_hero_msg_proto_rawDescGZIP(), []int{28} +} + +func (x *HeroDelNewHeroPush) GetHeros() map[string]int32 { + if x != nil { + return x.Heros + } + return nil +} + var File_hero_hero_msg_proto protoreflect.FileDescriptor var file_hero_hero_msg_proto_rawDesc = []byte{ @@ -1631,8 +1678,17 @@ var file_hero_hero_msg_proto_rawDesc = []byte{ 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x22, 0x33, 0x0a, 0x14, 0x48, 0x65, 0x72, 0x6f, 0x47, 0x65, 0x74, 0x53, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1b, 0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x07, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x42, - 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x32, 0x07, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x22, + 0x84, 0x01, 0x0a, 0x12, 0x48, 0x65, 0x72, 0x6f, 0x44, 0x65, 0x6c, 0x4e, 0x65, 0x77, 0x48, 0x65, + 0x72, 0x6f, 0x50, 0x75, 0x73, 0x68, 0x12, 0x34, 0x0a, 0x05, 0x68, 0x65, 0x72, 0x6f, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x48, 0x65, 0x72, 0x6f, 0x44, 0x65, 0x6c, 0x4e, + 0x65, 0x77, 0x48, 0x65, 0x72, 0x6f, 0x50, 0x75, 0x73, 0x68, 0x2e, 0x48, 0x65, 0x72, 0x6f, 0x73, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x68, 0x65, 0x72, 0x6f, 0x73, 0x1a, 0x38, 0x0a, 0x0a, + 0x48, 0x65, 0x72, 0x6f, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1647,7 +1703,7 @@ func file_hero_hero_msg_proto_rawDescGZIP() []byte { return file_hero_hero_msg_proto_rawDescData } -var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 31) +var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 33) var file_hero_hero_msg_proto_goTypes = []interface{}{ (*HeroInfoReq)(nil), // 0: HeroInfoReq (*HeroInfoResp)(nil), // 1: HeroInfoResp @@ -1677,36 +1733,39 @@ var file_hero_hero_msg_proto_goTypes = []interface{}{ (*HeroAddNewHeroPush)(nil), // 25: HeroAddNewHeroPush (*HeroGetSpecifiedReq)(nil), // 26: HeroGetSpecifiedReq (*HeroGetSpecifiedResp)(nil), // 27: HeroGetSpecifiedResp - nil, // 28: HeroStrengthenUplvReq.ExpCardsEntry - nil, // 29: HeroPropertyPush.PropertyEntry - nil, // 30: HeroPropertyPush.AddPropertyEntry - (*DBHero)(nil), // 31: DBHero + (*HeroDelNewHeroPush)(nil), // 28: HeroDelNewHeroPush + nil, // 29: HeroStrengthenUplvReq.ExpCardsEntry + nil, // 30: HeroPropertyPush.PropertyEntry + nil, // 31: HeroPropertyPush.AddPropertyEntry + nil, // 32: HeroDelNewHeroPush.HerosEntry + (*DBHero)(nil), // 33: DBHero } var file_hero_hero_msg_proto_depIdxs = []int32{ - 31, // 0: HeroInfoResp.base:type_name -> DBHero - 31, // 1: HeroListResp.list:type_name -> DBHero - 28, // 2: HeroStrengthenUplvReq.expCards:type_name -> HeroStrengthenUplvReq.ExpCardsEntry - 31, // 3: HeroStrengthenUplvResp.hero:type_name -> DBHero + 33, // 0: HeroInfoResp.base:type_name -> DBHero + 33, // 1: HeroListResp.list:type_name -> DBHero + 29, // 2: HeroStrengthenUplvReq.expCards:type_name -> HeroStrengthenUplvReq.ExpCardsEntry + 33, // 3: HeroStrengthenUplvResp.hero:type_name -> DBHero 7, // 4: HeroStrengthenUpStarReq.hero:type_name -> CostCardData 7, // 5: HeroStrengthenUpStarReq.heroRace:type_name -> CostCardData - 31, // 6: HeroStrengthenUpStarResp.hero:type_name -> DBHero - 31, // 7: HeroStrengthenUpSkillResp.hero:type_name -> DBHero - 31, // 8: HeroResonanceResp.hero:type_name -> DBHero - 31, // 9: HeroResonanceResp.upStarCard:type_name -> DBHero - 31, // 10: HeroResonanceResetResp.hero:type_name -> DBHero - 31, // 11: HeroResonanceUseEnergyResp.hero:type_name -> DBHero - 31, // 12: HeroAwakenResp.hero:type_name -> DBHero - 31, // 13: HeroChoukaResp.heroes:type_name -> DBHero - 29, // 14: HeroPropertyPush.property:type_name -> HeroPropertyPush.PropertyEntry - 30, // 15: HeroPropertyPush.addProperty:type_name -> HeroPropertyPush.AddPropertyEntry - 31, // 16: HeroLockResp.hero:type_name -> DBHero - 31, // 17: HeroAddNewHeroPush.hero:type_name -> DBHero - 31, // 18: HeroGetSpecifiedResp.hero:type_name -> DBHero - 19, // [19:19] is the sub-list for method output_type - 19, // [19:19] is the sub-list for method input_type - 19, // [19:19] is the sub-list for extension type_name - 19, // [19:19] is the sub-list for extension extendee - 0, // [0:19] is the sub-list for field type_name + 33, // 6: HeroStrengthenUpStarResp.hero:type_name -> DBHero + 33, // 7: HeroStrengthenUpSkillResp.hero:type_name -> DBHero + 33, // 8: HeroResonanceResp.hero:type_name -> DBHero + 33, // 9: HeroResonanceResp.upStarCard:type_name -> DBHero + 33, // 10: HeroResonanceResetResp.hero:type_name -> DBHero + 33, // 11: HeroResonanceUseEnergyResp.hero:type_name -> DBHero + 33, // 12: HeroAwakenResp.hero:type_name -> DBHero + 33, // 13: HeroChoukaResp.heroes:type_name -> DBHero + 30, // 14: HeroPropertyPush.property:type_name -> HeroPropertyPush.PropertyEntry + 31, // 15: HeroPropertyPush.addProperty:type_name -> HeroPropertyPush.AddPropertyEntry + 33, // 16: HeroLockResp.hero:type_name -> DBHero + 33, // 17: HeroAddNewHeroPush.hero:type_name -> DBHero + 33, // 18: HeroGetSpecifiedResp.hero:type_name -> DBHero + 32, // 19: HeroDelNewHeroPush.heros:type_name -> HeroDelNewHeroPush.HerosEntry + 20, // [20:20] is the sub-list for method output_type + 20, // [20:20] is the sub-list for method input_type + 20, // [20:20] is the sub-list for extension type_name + 20, // [20:20] is the sub-list for extension extendee + 0, // [0:20] is the sub-list for field type_name } func init() { file_hero_hero_msg_proto_init() } @@ -2052,6 +2111,18 @@ func file_hero_hero_msg_proto_init() { return nil } } + file_hero_hero_msg_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HeroDelNewHeroPush); 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{ @@ -2059,7 +2130,7 @@ func file_hero_hero_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_hero_hero_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 31, + NumMessages: 33, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/proto/hero/hero_msg.proto b/pb/proto/hero/hero_msg.proto index 229d0a378..5ab1d8e3f 100644 --- a/pb/proto/hero/hero_msg.proto +++ b/pb/proto/hero/hero_msg.proto @@ -139,4 +139,8 @@ message HeroGetSpecifiedReq { message HeroGetSpecifiedResp { DBHero hero = 1; // 英雄对象 +} + +message HeroDelNewHeroPush { + map heros = 1; } \ No newline at end of file