package msg import ( "rocommon" "rocommon/util" "roserver/baseserver/model" "roserver/serverproto" socialModel "roserver/social/model" ) func init() { //获取CrossRouter连接的服务器状态 serverproto.Handle_SOCIAL_SSGetGServerStateReq = model.HandleBackendMessage(func(ev rocommon.ProcEvent, cliId model.ClientID) { msg := ev.Msg().(*serverproto.SSGetGServerStateReq) //util.InfoF("receive SSGetServerStateReq msg:%v", msg) socialPlayer := socialModel.GetSocialPlayer(cliId.SessID) if socialPlayer != nil { if !socialPlayer.SendGCrossRouter(msg) { ssAckMsg := &serverproto.SSGetGServerStateAck{ ServerType: msg.ServerType, } model.ServiceReplay(ev, ssAckMsg) } } else { socialModel.SendGCrossRouter(msg) } }) serverproto.Handle_SOCIAL_SSGetGServerStateAck = model.HandleBackendMessage(func(ev rocommon.ProcEvent, cliId model.ClientID) { msg := ev.Msg().(*serverproto.SSGetGServerStateAck) util.InfoF("receive SSGetGServerStateAck msg=%v", msg) socialPlayer := socialModel.GetSocialPlayer(cliId.SessID) if socialPlayer != nil { socialPlayer.SendGame(msg) } else { socialModel.SendToAllGame(msg) } }) //from router //跨服协议测试 //默认跨服协议通过social转发给router,router会进行自动分发到对应的服务器进程 serverproto.Handle_SOCIAL_SSCrossYuanHangTrialViewNtf = model.HandleBackendMessage(func(ev rocommon.ProcEvent, cliId model.ClientID) { msg := ev.Msg().(*serverproto.SSCrossYuanHangTrialViewNtf) util.InfoF("receive SSCrossYuanHangTrialViewNtf msg=%v", msg) socialModel.SendToAllGame(msg) }) //被挑战日志通知 serverproto.Handle_SOCIAL_SSCrossYuanHangTrialLogNtf = model.HandleBackendMessage(func(ev rocommon.ProcEvent, cliId model.ClientID) { msg := ev.Msg().(*serverproto.SSCrossYuanHangTrialLogNtf) util.InfoF("receive SSCrossYuanHangTrialLogNtf msg=%v", msg) //这边可以根据消息类型来处理不同消息的转发 socialPlayer := socialModel.GetSocialPlayer(msg.NtfUid) if socialPlayer != nil { socialPlayer.SendGame(msg) } else { offlinePlayer := socialModel.GetOfflineSocialPlayer(msg.NtfUid) if offlinePlayer != nil { socialModel.SendToGame(offlinePlayer.ServiceNodeId(), msg) } else { //玩家不在线,写入到db中 socialModel.SendDB(msg) } } }) }