package model import ( "rocommon" "rocommon/rpc" "rocommon/util" "roserver/baseserver/model" "roserver/serverproto" "runtime/debug" ) var ( updateList []interface{} GuildMag *GuildManager GuildBattleMag *GuildBattleManager ) type GuildUpdate struct { rocommon.UpdateModule //eventqueue.go } func (this *GuildUpdate) Init() { // GuildMag = newGuildManager() updateList = append(updateList, GuildMag) GuildBattleMag = newGuildBattleManager() updateList = append(updateList, GuildBattleMag) } func (this *GuildUpdate) Update(ms uint64) { defer func() { //打印奔溃信息 if err := recover(); err != nil { util.InfoF("onError data=%v \n%s\n", err, string(debug.Stack())) } }() //对管理器进行更新操作 for _, data := range updateList { data.(rocommon.UpdateLogic).Update(ms) } } func SendSocial(msg interface{}) bool { data, meta, err := rpc.EncodeMessage(msg) if err != nil { util.InfoF("[SendSocial] EncodeMessage err:%v %v", err, msg) return false } socialNode := model.SelectServiceNode(model.SERVICE_NODE_TYPE_SOCIAL_STR, 0) if socialNode == "" { util.InfoF("[SendSocial] social node not exist msg:%v", msg) return false } socialSess := model.GetServiceNode(socialNode) if socialSess == nil { util.ErrorF("[SendSocial] social session not exist:%v", socialSess) } else { //如果玩家信息存在,ClientId中存放的是玩家ID,否则存放的是玩家的gate sessionId socialSess.Send(&serverproto.ServiceTransmitAck{ MsgId: uint32(meta.ID), MsgData: data, }) } return true } func SendToAllGame(msg interface{}) { data, info, err := rpc.EncodeMessage(msg) if err != nil { util.InfoF("[SendGame]EncodeMessage err:%v %v", err, msg) return } sendMsg := &serverproto.ServiceTransmitAck{ MsgId: uint32(info.ID), MsgData: data, } serviceList := model.GetAllServiceNodeByName(model.SERVICE_NODE_TYPE_GAME_STR) if len(serviceList) > 0 { for _, node := range serviceList { gameSess := model.GetServiceNode(node) if gameSess != nil { gameSess.Send(sendMsg) } } } }