上传代码
This commit is contained in:
parent
505fc22844
commit
6d992bd005
@ -118,6 +118,7 @@ const (
|
|||||||
ModuleMaincity core.M_Modules = "maincity" //主城同屏
|
ModuleMaincity core.M_Modules = "maincity" //主城同屏
|
||||||
ModuleMatchPool core.M_Modules = "matchpool" //匹配
|
ModuleMatchPool core.M_Modules = "matchpool" //匹配
|
||||||
ModuleTreasureMap core.M_Modules = "treasuremap" //藏宝图
|
ModuleTreasureMap core.M_Modules = "treasuremap" //藏宝图
|
||||||
|
ModuleGameInvite core.M_Modules = "gameinvite" //游戏邀请
|
||||||
)
|
)
|
||||||
|
|
||||||
// 数据表名定义处
|
// 数据表名定义处
|
||||||
@ -395,6 +396,9 @@ const (
|
|||||||
TableAchieve = "achieve"
|
TableAchieve = "achieve"
|
||||||
//猜颜色
|
//猜颜色
|
||||||
TableDcolorQieChuo = "dcolorqiecuo"
|
TableDcolorQieChuo = "dcolorqiecuo"
|
||||||
|
|
||||||
|
//游戏邀请
|
||||||
|
TableGameInvite = "gameinvite"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RPC服务接口定义处
|
// RPC服务接口定义处
|
||||||
|
20
modules/gameinvite/api.go
Normal file
20
modules/gameinvite/api.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package gameinvite
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/lego/base"
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/modules"
|
||||||
|
)
|
||||||
|
|
||||||
|
type apiComp struct {
|
||||||
|
modules.MCompGate
|
||||||
|
service base.IRPCXService
|
||||||
|
module *GameInvite
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
|
_ = this.MCompGate.Init(service, module, comp, options)
|
||||||
|
this.service = service.(base.IRPCXService)
|
||||||
|
this.module = module.(*GameInvite)
|
||||||
|
return
|
||||||
|
}
|
25
modules/gameinvite/model.go
Normal file
25
modules/gameinvite/model.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package gameinvite
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/modules"
|
||||||
|
|
||||||
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
|
"go.mongodb.org/mongo-driver/x/bsonx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type modelComp struct {
|
||||||
|
modules.MCompModel
|
||||||
|
module *GameInvite
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *modelComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
|
err = this.MCompModel.Init(service, module, comp, options)
|
||||||
|
this.TableName = comm.TableGameInvite
|
||||||
|
this.module = module.(*GameInvite)
|
||||||
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
||||||
|
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
30
modules/gameinvite/module.go
Normal file
30
modules/gameinvite/module.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package gameinvite
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/modules"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GameInvite struct {
|
||||||
|
modules.ModuleBase
|
||||||
|
service comm.IService
|
||||||
|
api *apiComp
|
||||||
|
model *modelComp
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewModule() core.IModule {
|
||||||
|
return &GameInvite{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *GameInvite) GetType() core.M_Modules {
|
||||||
|
return comm.ModuleGameInvite
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *GameInvite) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||||
|
if err = this.ModuleBase.Init(service, module, options); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.service = service.(comm.IService)
|
||||||
|
return
|
||||||
|
}
|
@ -13,18 +13,18 @@ func (this *apiComp) SynchPosCheck(session comm.IUserSession, req *pb.MainCitySy
|
|||||||
// 查看某一封邮件
|
// 查看某一封邮件
|
||||||
func (this *apiComp) SynchPos(session comm.IUserSession, req *pb.MainCitySynchPosPeek) (errdata *pb.ErrorData) {
|
func (this *apiComp) SynchPos(session comm.IUserSession, req *pb.MainCitySynchPosPeek) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
user *pb.DBUser
|
// user *pb.DBUser
|
||||||
friends []*pb.BaseUserInfo
|
friends []*pb.BaseUserInfo
|
||||||
groupUser map[string][]*pb.BaseUserInfo = make(map[string][]*pb.BaseUserInfo)
|
groupUser map[string][]*pb.BaseUserInfo = make(map[string][]*pb.BaseUserInfo)
|
||||||
ok bool
|
ok bool
|
||||||
err error
|
// err error
|
||||||
)
|
)
|
||||||
if user, err = this.module.ModuleUser.GetUser(session.GetUserId()); err != nil {
|
// if user, err = this.module.ModuleUser.GetUser(session.GetUserId()); err != nil {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
self := comm.GetUserBaseInfo(user)
|
// self := comm.GetUserBaseInfo(user)
|
||||||
friends = this.module.model.getplayerPos(session.GetUserId())
|
friends = this.module.model.getplayerPos(session.GetUserId())
|
||||||
friends = append(friends, self)
|
// friends = append(friends, self)
|
||||||
for _, v := range friends {
|
for _, v := range friends {
|
||||||
if _, ok = groupUser[v.Sid]; !ok {
|
if _, ok = groupUser[v.Sid]; !ok {
|
||||||
groupUser[v.Sid] = make([]*pb.BaseUserInfo, 0)
|
groupUser[v.Sid] = make([]*pb.BaseUserInfo, 0)
|
||||||
|
@ -1,31 +1,23 @@
|
|||||||
package maincity
|
package maincity
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/lego/core/cbase"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
|
||||||
"go.mongodb.org/mongo-driver/x/bsonx"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type modelComp struct {
|
type modelComp struct {
|
||||||
modules.MCompModel
|
cbase.ModuleCompBase
|
||||||
module *MainCity
|
module *MainCity
|
||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
onlines map[string][]*pb.BaseUserInfo //关联用户信息
|
onlines map[string][]*pb.BaseUserInfo //关联用户信息
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *modelComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *modelComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
err = this.MCompModel.Init(service, module, comp, options)
|
err = this.ModuleCompBase.Init(service, module, comp, options)
|
||||||
this.TableName = comm.Tablekftask
|
|
||||||
this.module = module.(*MainCity)
|
this.module = module.(*MainCity)
|
||||||
this.onlines = make(map[string][]*pb.BaseUserInfo)
|
this.onlines = make(map[string][]*pb.BaseUserInfo)
|
||||||
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
|
||||||
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,6 +26,14 @@ func (this *modelComp) setplayerPos(uid string, friends []*pb.BaseUserInfo) {
|
|||||||
this.onlines[uid] = append(this.onlines[uid], friends...)
|
this.onlines[uid] = append(this.onlines[uid], friends...)
|
||||||
this.lock.Unlock()
|
this.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
func (this *modelComp) addplayerPos(uid string, friend *pb.BaseUserInfo) {
|
||||||
|
this.lock.Lock()
|
||||||
|
if _, ok := this.onlines[uid]; ok {
|
||||||
|
this.onlines[uid] = append(this.onlines[uid], friend)
|
||||||
|
}
|
||||||
|
this.lock.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
func (this *modelComp) getplayerPos(uid string) (friends []*pb.BaseUserInfo) {
|
func (this *modelComp) getplayerPos(uid string) (friends []*pb.BaseUserInfo) {
|
||||||
this.lock.RLock()
|
this.lock.RLock()
|
||||||
friends = this.onlines[uid]
|
friends = this.onlines[uid]
|
||||||
|
@ -95,9 +95,11 @@ func (this *MainCity) EventUserLogin(session comm.IUserSession) {
|
|||||||
func (this *MainCity) EventUserOffline(uid string, sessionid string) {
|
func (this *MainCity) EventUserOffline(uid string, sessionid string) {
|
||||||
this.model.removelayerPos(uid)
|
this.model.removelayerPos(uid)
|
||||||
}
|
}
|
||||||
func (this *MainCity) AddFriends(user1 *pb.BaseUserInfo, user2 *pb.BaseUserInfo) {
|
func (this *MainCity) AddFriends(user1 *pb.BaseUserInfo, users []*pb.BaseUserInfo) {
|
||||||
this.model.setplayerPos(user1.Uid, []*pb.BaseUserInfo{user2})
|
this.model.setplayerPos(user1.Uid, users)
|
||||||
this.model.setplayerPos(user2.Uid, []*pb.BaseUserInfo{user1})
|
for _, user := range users {
|
||||||
|
this.model.addplayerPos(user.Uid, user1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *MainCity) UpdateRelatedUser(uid string, users []*pb.BaseUserInfo) {
|
func (this *MainCity) UpdateRelatedUser(uid string, users []*pb.BaseUserInfo) {
|
||||||
|
Loading…
Reference in New Issue
Block a user