Compare commits
No commits in common. "46a4255273d23ae78614f40fe5c7a24844881af8" and "2f749646ab2784b24a0412db0693cae04572d85c" have entirely different histories.
46a4255273
...
2f749646ab
|
|
@ -19,6 +19,10 @@ var ActionMgrSington = &ActionMgr{
|
||||||
pool: make(map[int]ActionBase),
|
pool: make(map[int]ActionBase),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
type ActionMgr struct {
|
type ActionMgr struct {
|
||||||
pool map[int]ActionBase
|
pool map[int]ActionBase
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,7 @@ const (
|
||||||
// 房间模式
|
// 房间模式
|
||||||
const (
|
const (
|
||||||
SceneMode_Public = iota //公共房间
|
SceneMode_Public = iota //公共房间
|
||||||
|
SceneMode_Club //俱乐部房间
|
||||||
SceneMode_Private //私人房间
|
SceneMode_Private //私人房间
|
||||||
SceneMode_Match //赛事房间
|
SceneMode_Match //赛事房间
|
||||||
SceneMode_Thr //三方房间
|
SceneMode_Thr //三方房间
|
||||||
|
|
@ -186,88 +187,78 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
GainWay_NewPlayer int32 = 0 //新建角色
|
GainWay_NewPlayer int32 = 0 //0.新建角色
|
||||||
GainWay_Pay = 1 //后台增加(主要是充值)
|
GainWay_Pay = 1 //1.后台增加(主要是充值)
|
||||||
GainWay_ByPMCmd = 2 //pm命令
|
GainWay_ByPMCmd = 2 //2.pm命令
|
||||||
GainWay_MatchBreakBack = 3 //退赛退还
|
GainWay_MatchBreakBack = 3 //3.退赛退还
|
||||||
GainWay_MatchSystemSupply = 4 //比赛奖励
|
GainWay_MatchSystemSupply = 4 //4.比赛奖励
|
||||||
GainWay_Exchange = 5 //兑换
|
GainWay_Exchange = 5 //5.兑换
|
||||||
GainWay_ServiceFee = 6 //桌费
|
GainWay_ServiceFee = 6 //6.桌费
|
||||||
GainWay_CoinSceneWin = 7 //金豆场赢取
|
GainWay_CoinSceneWin = 7 //7.金豆场赢取
|
||||||
GainWay_CoinSceneLost = 8 //金豆场输
|
GainWay_CoinSceneLost = 8 //8.金豆场输
|
||||||
GainWay_CoinSceneEnter = 9 //进入金币场预扣
|
GainWay_CoinSceneEnter = 9 //9.进入金币场预扣
|
||||||
GainWay_ShopBuy = 10 //商城购买或者兑换
|
GainWay_ShopBuy = 10 //10.商城购买或者兑换
|
||||||
GainWay_CoinSceneLeave = 11 //金豆场回兑
|
GainWay_CoinSceneLeave = 11 //11.金豆场回兑
|
||||||
GainWay_HundredSceneWin = 12 //万人场赢取
|
GainWay_HundredSceneWin = 12 //12.万人场赢取
|
||||||
GainWay_HundredSceneLost = 13 //万人场输
|
GainWay_HundredSceneLost = 13 //13.万人场输
|
||||||
GainWay_MessageAttach = 14 //邮件
|
GainWay_MessageAttach = 14 //14.邮件
|
||||||
GainWay_SafeBoxSave = 15 //保险箱存入
|
GainWay_SafeBoxSave = 15 //15.保险箱存入
|
||||||
GainWay_SafeBoxTakeOut = 16 //保险箱取出
|
GainWay_SafeBoxTakeOut = 16 //16.保险箱取出
|
||||||
GainWay_Fishing = 17 //捕鱼
|
GainWay_Fishing = 17 //17.捕鱼
|
||||||
GainWay_CoinSceneExchange = 18 //金豆场兑换
|
GainWay_CoinSceneExchange = 18 //18.金豆场兑换
|
||||||
GainWay_UpgradeAccount = 19 //升级账号
|
GainWay_UpgradeAccount = 19 //19.升级账号
|
||||||
GainWay_API_AddCoin = 20 //API操作钱包
|
GainWay_API_AddCoin = 20 //20.API操作钱包
|
||||||
GainWay_GoldCome = 21 //财神降临
|
GainWay_GoldCome = 21 //21.财神降临
|
||||||
GainWay_Transfer_System2Thrid = 22 //系统平台转入到第三方平台的金币
|
GainWay_Transfer_System2Thrid = 22 //22.系统平台转入到第三方平台的金币
|
||||||
GainWay_Transfer_Thrid2System = 23 //第三方平台转入到系统平台的金币
|
GainWay_Transfer_Thrid2System = 23 //23.第三方平台转入到系统平台的金币
|
||||||
GainWay_RebateTask = 24 //返利获取
|
GainWay_RebateTask = 24 //24.返利获取
|
||||||
GainWay_IOSINSTALLSTABLE = 25 //ios安装奖励
|
GainWay_IOSINSTALLSTABLE = 25 //25.ios安装奖励
|
||||||
GainWay_VirtualChange = 26 //德州虚拟账变
|
GainWay_VirtualChange = 26 //26.德州虚拟账变
|
||||||
GainWay_CreatePrivateScene = 27 //创建私有房间
|
GainWay_CreatePrivateScene = 27 //27.创建私有房间
|
||||||
GainWay_PrivateSceneReturn = 28 //解散私有房间返还
|
GainWay_PrivateSceneReturn = 28 //28.解散私有房间返还
|
||||||
GainWay_OnlineRandCoin = 29 //红包雨
|
GainWay_OnlineRandCoin = 29 //29.红包雨
|
||||||
GainWay_Expire = 30 //到期清理
|
GainWay_Expire = 30 //30.到期清理
|
||||||
GainWay_PromoterBind = 31 //手动绑定推广员
|
GainWay_PromoterBind = 31 //31.手动绑定推广员
|
||||||
GainWay_GradeShopReturn = 32 //积分商城撤单退还积分
|
GainWay_GradeShopReturn = 32 //32.积分商城撤单退还积分
|
||||||
GainWay_Api_In = 33 //转移金币
|
GainWay_Api_In = 33 //33.转移金币
|
||||||
GainWay_Api_Out = 34 //转移金币
|
GainWay_Api_Out = 34 //34.转移金币
|
||||||
GainWay_Shop_Buy = 35 //购买记录
|
GainWay_Shop_Buy = 35 //35.购买记录
|
||||||
GainWay_MAIL_MTEM = 36 //邮件领取道具
|
GainWay_MAIL_MTEM = 36 //36.邮件领取道具
|
||||||
GainWay_Item_Sale = 37 //道具出售
|
GainWay_Item_Sale = 37 //37.道具出售
|
||||||
GainWay_ReliefFund = 38 //领取救济金
|
GainWay_ReliefFund = 38 //38.领取救济金
|
||||||
GainWay_Shop_Revoke = 39 //撤单
|
GainWay_Shop_Revoke = 39 //39.撤单
|
||||||
GainWay_ActSign = 40 //
|
GainWay_ActSign = 40 //40.签到
|
||||||
GainWay_MatchSignup = 41 //比赛报名费用
|
GainWay_MatchSignup = 41 //比赛报名费用
|
||||||
GainWay_MatchSeason = 42 //比赛赛季奖励
|
GainWay_MatchSeason = 42 //比赛赛季奖励
|
||||||
GainWay_ActSignNew = 43 //新签到
|
GainWay_ActSignNew = 43 //43.新签到
|
||||||
GainWay_ActTurnplate = 44 //轮盘
|
GainWay_ActTurnplate = 44 //44.轮盘
|
||||||
GainWay_ActBlindBox = 45 //盲盒
|
GainWay_ActBlindBox = 45 //45.盲盒
|
||||||
GainWay_ActFirstPay = 46 //首充
|
GainWay_ActFirstPay = 46 //46.首充
|
||||||
GainWay_VIPGift = 47 //vip礼包
|
GainWay_VIPGift = 47 //47.vip礼包
|
||||||
GainWay_ActContinuousPay = 48 //连续充值
|
GainWay_ActContinuousPay = 48 //48.连续充值
|
||||||
GainWay_ActJybAward = 49 //礼包码兑换
|
GainWay_ActJybAward = 49 //49.礼包码兑换
|
||||||
GainWay_LeaveDeduct = 50 //离开扣分
|
GainWay_LeaveDeduct = 50 //50.离开扣分
|
||||||
GainWay_LeaveCombat = 51 //离开补偿
|
GainWay_LeaveCombat = 51 //51.离开补偿
|
||||||
GainWay_RankMatch = 52 //排位赛段位奖励
|
GainWay_RankMatch = 52 //52.排位赛段位奖励
|
||||||
GainWay_AddBag = 53 //增加背包接口调用
|
GainWay_AddBag = 53 //53 增加背包接口调用
|
||||||
GainWay_SmallRocket = 54 //小火箭收入
|
GainWay_SmallRocket = 54 //54.小火箭收入
|
||||||
GainWay_BindTel = 55 //绑定手机号
|
GainWay_BindTel = 55 //55.绑定手机号
|
||||||
GainWay_ReliefFund2 = 56 //救济金看视频双倍领取
|
GainWay_ReliefFund2 = 56 //56.救济金看视频双倍领取
|
||||||
GainWay_ActTurnplate2 = 57 //轮盘看视频双倍领取
|
GainWay_ActTurnplate2 = 57 //57.轮盘看视频双倍领取
|
||||||
GainWay_ActSignNew2 = 58 //签到看视频双倍领取
|
GainWay_ActSignNew2 = 58 //58.签到看视频双倍领取
|
||||||
GainWay_ItemUse = 59 //道具使用
|
GainWay_ItemUse = 59 //59.道具使用
|
||||||
GainWay_PhoneScore = 60 //手机积分活动
|
GainWay_PhoneScore = 60 //60.积分抽奖活动
|
||||||
GainWay_RankReward = 61 //排位奖励
|
GainWay_RankReward = 61 //61.段位奖励
|
||||||
GainWay_TaskReward = 62 //任务奖励
|
GainWay_TaskReward = 62 //62.任务奖励
|
||||||
GainWay_Interact = 63 //房间内互动效果
|
GainWay_Interact = 63 //63.房间内互动效果
|
||||||
GainWay_Collect = 64 //集卡活动
|
GainWay_Collect = 64 //64.集卡活动
|
||||||
GainWay_WeekCardAward = 65 //周卡奖励
|
GainWay_WeekCardAward = 65 //65.周卡每日奖励
|
||||||
GainWay_PigrankTakeCoin = 66 //存钱罐领取耗费钻石
|
GainWay_PigrankTakeCoin = 66 //66.存钱罐领取耗费钻石
|
||||||
GainWay_PigrankGainCoin = 67 //存钱罐打开获取金币
|
GainWay_PigrankGainCoin = 67 //66.存钱罐打开获取金币
|
||||||
GainWay_ItemMove = 68 //道具赠送
|
GainWay_ItemMove = 68 //68.道具赠送
|
||||||
GainWay_RoleUpgrade = 69 //角色升级
|
GainWay_RoleUpgrade = 69 //69.角色升级
|
||||||
GainWay_PetUpgrade = 70 //宠物升级
|
GainWay_PetUpgrade = 70 //70.宠物升级
|
||||||
GainWay_Game = 71 //游戏掉落
|
GainWay_Game = 71 //71.玩游戏获得
|
||||||
GainWayItemCollectLogin = 73 //集卡活动登录
|
|
||||||
GainWayItemCollectExchange = 74 //集卡活动兑换
|
|
||||||
GainWayItemPhoneScoreExchange = 75 //抽手机活动兑换
|
|
||||||
GainWayItemTaskInvite = 78 //邀请任务
|
|
||||||
GainWayItemTaskNewPlayer = 79 //新手任务
|
|
||||||
GainWayItemTaskAchievement = 80 //成就任务
|
|
||||||
GainWayItemTaskEveryDay = 81 //每日任务
|
|
||||||
GainWayItemWeekActive = 82 //周活跃奖励
|
|
||||||
GainWayContinueSign = 83 //累计签到
|
|
||||||
GainWayBackend = 84 // 后台操作
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 后台选择 金币变化类型 的充值 类型id号起始
|
// 后台选择 金币变化类型 的充值 类型id号起始
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,13 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/howeyc/fsnotify"
|
"github.com/howeyc/fsnotify"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core"
|
"mongo.games.com/goserver/core"
|
||||||
"mongo.games.com/goserver/core/basic"
|
"mongo.games.com/goserver/core/basic"
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var LastModifyConfig int64
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
@ -61,7 +62,7 @@ type loggerParamModifiedCommand struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lmc *loggerParamModifiedCommand) Done(o *basic.Object) error {
|
func (lmc *loggerParamModifiedCommand) Done(o *basic.Object) error {
|
||||||
logger.Logger.Info("reload logger.xml:", lmc.fileName)
|
logger.Logger.Info("===reload ", lmc.fileName)
|
||||||
data, err := os.ReadFile(lmc.fileName)
|
data, err := os.ReadFile(lmc.fileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -69,7 +70,7 @@ func (lmc *loggerParamModifiedCommand) Done(o *basic.Object) error {
|
||||||
if len(data) != 0 {
|
if len(data) != 0 {
|
||||||
err = logger.Reload(lmc.fileName)
|
err = logger.Reload(lmc.fileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Logger.Warnf("reload logger.xml %v err: %v", lmc.fileName, err)
|
logger.Logger.Warn("===reload ", lmc.fileName, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
|
|
||||||
иУ†
|
ъУ†
|
||||||
иФ†
|
ъФ†
|
||||||
иХ†
|
ъХ†
|
||||||
иЦ†
|
ъЦ†
|
||||||
ЮЧ†
|
ъЧ†
|
||||||
2Ш†
|
ИШ†
|
||||||
2Щ†
|
ИЩ†
|
||||||
2Ъ†
|
ИЪ†
|
||||||
2Ы†
|
ИЫ†
|
||||||
|
|
||||||
Ь†
|
|
||||||
фЎЌђN
|
Ь†
|
||||||
dЎЌР†
|
2ЎЌђN
|
||||||
ЎЌ Ќ
|
¬ЎЌР†
|
||||||
|
2ЎЌ Ќ
|
||||||
|
|
@ -2,91 +2,91 @@
|
||||||
"Arr": [
|
"Arr": [
|
||||||
{
|
{
|
||||||
"Id": 1,
|
"Id": 1,
|
||||||
"Rate": 1000,
|
"Rate": 250,
|
||||||
"ItemID": {
|
"ItemID": {
|
||||||
"50003": 1
|
"50003": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Id": 2,
|
"Id": 2,
|
||||||
"Rate": 1000,
|
"Rate": 250,
|
||||||
"ItemID": {
|
"ItemID": {
|
||||||
"50004": 1
|
"50004": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Id": 3,
|
"Id": 3,
|
||||||
"Rate": 1000,
|
"Rate": 250,
|
||||||
"ItemID": {
|
"ItemID": {
|
||||||
"50005": 1
|
"50005": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Id": 4,
|
"Id": 4,
|
||||||
"Rate": 1000,
|
"Rate": 250,
|
||||||
"ItemID": {
|
"ItemID": {
|
||||||
"50006": 1
|
"50006": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Id": 5,
|
"Id": 5,
|
||||||
"Rate": 350,
|
"Rate": 250,
|
||||||
"ItemID": {
|
"ItemID": {
|
||||||
"50007": 1
|
"50007": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Id": 6,
|
"Id": 6,
|
||||||
"Rate": 50,
|
"Rate": 200,
|
||||||
"ItemID": {
|
"ItemID": {
|
||||||
"50008": 1
|
"50008": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Id": 7,
|
"Id": 7,
|
||||||
"Rate": 50,
|
"Rate": 200,
|
||||||
"ItemID": {
|
"ItemID": {
|
||||||
"50009": 1
|
"50009": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Id": 8,
|
"Id": 8,
|
||||||
"Rate": 50,
|
"Rate": 200,
|
||||||
"ItemID": {
|
"ItemID": {
|
||||||
"50010": 1
|
"50010": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Id": 9,
|
"Id": 9,
|
||||||
"Rate": 50,
|
"Rate": 200,
|
||||||
"ItemID": {
|
"ItemID": {
|
||||||
"50011": 1
|
"50011": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Id": 10,
|
"Id": 10,
|
||||||
"Rate": 1,
|
"Rate": 10,
|
||||||
"ItemID": {
|
"ItemID": {
|
||||||
"50012": 1
|
"50012": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Id": 11,
|
"Id": 11,
|
||||||
"Rate": 500,
|
"Rate": 50,
|
||||||
"ItemID": {
|
"ItemID": {
|
||||||
"100001": 10000
|
"100001": 10000
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Id": 12,
|
"Id": 12,
|
||||||
"Rate": 100,
|
"Rate": 300,
|
||||||
"ItemID": {
|
"ItemID": {
|
||||||
"100001": 50000
|
"100001": 50000
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Id": 13,
|
"Id": 13,
|
||||||
"Rate": 20,
|
"Rate": 50,
|
||||||
"ItemID": {
|
"ItemID": {
|
||||||
"100001": 100000
|
"100001": 100000
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -748,6 +748,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 6,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -805,6 +806,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 4,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -861,6 +863,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -916,6 +919,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -971,6 +975,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1026,6 +1031,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1083,6 +1089,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 6,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1140,6 +1147,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 4,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1196,6 +1204,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1251,6 +1260,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1306,6 +1316,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1361,6 +1372,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1418,6 +1430,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 4,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1475,6 +1488,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1531,6 +1545,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 2,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1586,6 +1601,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 2,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1641,6 +1657,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 2,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1696,6 +1713,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 2,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1753,6 +1771,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 6,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1810,6 +1829,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 4,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1866,6 +1886,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1921,6 +1942,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -1976,6 +1998,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -2031,6 +2054,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -2090,6 +2114,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 6,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -2149,6 +2174,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 4,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -2207,6 +2233,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -2264,6 +2291,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -2321,6 +2349,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -2378,6 +2407,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -2437,6 +2467,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 6,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -2496,6 +2527,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 4,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -2554,6 +2586,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -2611,6 +2644,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -2668,6 +2702,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -2725,6 +2760,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -2784,6 +2820,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 4,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -2843,6 +2880,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -2901,6 +2939,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 2,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -2958,6 +2997,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 2,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -3015,6 +3055,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 2,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -3072,6 +3113,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 2,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -3131,6 +3173,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 6,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -3190,6 +3233,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 4,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -3248,6 +3292,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -3305,6 +3350,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -3362,6 +3408,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -3419,6 +3466,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 3,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -3826,6 +3874,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -3884,6 +3933,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -3942,6 +3992,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -4000,6 +4051,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -4058,6 +4110,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -4113,6 +4166,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": -1,
|
"MatchTrueMan": -1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100
|
"BetWaterRate": 100
|
||||||
|
|
@ -4164,6 +4218,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": -1,
|
"MatchTrueMan": -1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100
|
"BetWaterRate": 100
|
||||||
|
|
@ -4215,6 +4270,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": -1,
|
"MatchTrueMan": -1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100
|
"BetWaterRate": 100
|
||||||
|
|
@ -4266,6 +4322,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": -1,
|
"MatchTrueMan": -1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100
|
"BetWaterRate": 100
|
||||||
|
|
@ -4317,6 +4374,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": -1,
|
"MatchTrueMan": -1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100
|
"BetWaterRate": 100
|
||||||
|
|
@ -4368,6 +4426,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -4421,6 +4480,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -4473,6 +4533,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -4525,6 +4586,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -4577,6 +4639,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -4629,6 +4692,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -4682,6 +4746,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -4735,6 +4800,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -4787,6 +4853,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -4839,6 +4906,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -4891,6 +4959,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -4943,6 +5012,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -4996,7 +5066,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"CreateRoomNum": 6,
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -5050,7 +5120,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"CreateRoomNum": 4,
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -5104,7 +5174,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"CreateRoomNum": 2,
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -5158,7 +5228,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"CreateRoomNum": 6,
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -5212,7 +5282,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"CreateRoomNum": 4,
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -5266,7 +5336,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"CreateRoomNum": 2,
|
"CreateRoomNum": 1,
|
||||||
"MatchTrueMan": 1,
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
|
|
@ -5360,6 +5430,7 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100
|
"BetWaterRate": 100
|
||||||
},
|
},
|
||||||
|
|
@ -6108,6 +6179,8 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100
|
"BetWaterRate": 100
|
||||||
},
|
},
|
||||||
|
|
@ -6148,6 +6221,8 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100
|
"BetWaterRate": 100
|
||||||
},
|
},
|
||||||
|
|
@ -6188,6 +6263,8 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100
|
"BetWaterRate": 100
|
||||||
},
|
},
|
||||||
|
|
@ -6228,6 +6305,8 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100
|
"BetWaterRate": 100
|
||||||
},
|
},
|
||||||
|
|
@ -6268,6 +6347,8 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100
|
"BetWaterRate": 100
|
||||||
},
|
},
|
||||||
|
|
@ -6308,6 +6389,8 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100
|
"BetWaterRate": 100
|
||||||
},
|
},
|
||||||
|
|
@ -6348,6 +6431,8 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100
|
"BetWaterRate": 100
|
||||||
},
|
},
|
||||||
|
|
@ -6388,6 +6473,8 @@
|
||||||
"MaxBetCoin": [
|
"MaxBetCoin": [
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
|
"CreateRoomNum": 1,
|
||||||
|
"MatchTrueMan": 1,
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100
|
"BetWaterRate": 100
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
BIN
data/DB_Task.dat
BIN
data/DB_Task.dat
Binary file not shown.
|
|
@ -44,15 +44,6 @@
|
||||||
"AppId": "5c56d1644966f078bfb90c71",
|
"AppId": "5c56d1644966f078bfb90c71",
|
||||||
"IsDevMode": true
|
"IsDevMode": true
|
||||||
},
|
},
|
||||||
"data":{
|
|
||||||
"RootPath":"../data"
|
|
||||||
},
|
|
||||||
"etcd": {
|
|
||||||
"Url": ["127.0.0.1:2379"],
|
|
||||||
"UserName": "",
|
|
||||||
"Password": "",
|
|
||||||
"DialTimeout": 60
|
|
||||||
},
|
|
||||||
"costum": {
|
"costum": {
|
||||||
"MgoRpcCliNet": "tcp",
|
"MgoRpcCliNet": "tcp",
|
||||||
"MgoRpcCliAddr": "127.0.0.1:8999",
|
"MgoRpcCliAddr": "127.0.0.1:8999",
|
||||||
|
|
@ -60,6 +51,11 @@
|
||||||
"RMQExchange": "win88",
|
"RMQExchange": "win88",
|
||||||
"RMQQosPrefetchCount": 2,
|
"RMQQosPrefetchCount": 2,
|
||||||
"RMQQosPrefetchSize": 0,
|
"RMQQosPrefetchSize": 0,
|
||||||
"RMQQosGlobal": true
|
"RMQQosGlobal": true,
|
||||||
|
"etcdurl": [
|
||||||
|
"127.0.0.1:2379"
|
||||||
|
],
|
||||||
|
"etcduser": "",
|
||||||
|
"etcdpwd": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,46 +7,53 @@ import (
|
||||||
"net/rpc"
|
"net/rpc"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core"
|
"mongo.games.com/goserver/core"
|
||||||
"mongo.games.com/goserver/core/etcd"
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
"mongo.games.com/goserver/core/module"
|
"mongo.games.com/goserver/core/module"
|
||||||
|
|
||||||
_ "mongo.games.com/game"
|
_ "mongo.games.com/game"
|
||||||
"mongo.games.com/game/common"
|
|
||||||
_ "mongo.games.com/game/dbproxy/mq"
|
_ "mongo.games.com/game/dbproxy/mq"
|
||||||
|
|
||||||
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/dbproxy/svc"
|
"mongo.games.com/game/dbproxy/svc"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/mq"
|
"mongo.games.com/game/mq"
|
||||||
_ "mongo.games.com/game/srvdata"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
var rabbitMqConsumer *mq.RabbitMQConsumer
|
||||||
// 自定义配置文件
|
|
||||||
|
func init() {
|
||||||
|
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
||||||
model.InitGameParam()
|
model.InitGameParam()
|
||||||
// package模块
|
rabbitMqConsumer = mq.NewRabbitMQConsumer(common.CustomConfig.GetString("RabbitMQURL"), rabbitmq.Exchange{Name: common.CustomConfig.GetString("RMQExchange"), Durable: true})
|
||||||
|
if rabbitMqConsumer != nil {
|
||||||
|
rabbitMqConsumer.Start()
|
||||||
|
}
|
||||||
|
|
||||||
|
//尝试初始化
|
||||||
|
svc.GetOnePlayerIdFromBucket()
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
||||||
|
if rabbitMqConsumer != nil {
|
||||||
|
rabbitMqConsumer.Stop()
|
||||||
|
}
|
||||||
|
model.ShutdownRPClient()
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
defer core.ClosePackages()
|
defer core.ClosePackages()
|
||||||
core.LoadPackages("config.json")
|
core.LoadPackages("config.json")
|
||||||
// core hook
|
|
||||||
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
|
||||||
etcd.Start()
|
|
||||||
mq.StartConsumer(common.CustomConfig.GetString("RabbitMQURL"), common.CustomConfig.GetString("RMQExchange"), true)
|
|
||||||
mq.StartPublisher(common.CustomConfig.GetString("RabbitMQURL"), common.CustomConfig.GetString("RMQExchange"), true, common.CustomConfig.GetInt("RMQPublishBacklog"))
|
|
||||||
// 尝试初始化玩家id
|
|
||||||
svc.GetOnePlayerIdFromBucket()
|
|
||||||
// rpc 服务
|
|
||||||
rpc.HandleHTTP() // 采用http协议作为rpc载体
|
rpc.HandleHTTP() // 采用http协议作为rpc载体
|
||||||
lis, err := net.Listen(common.CustomConfig.GetString("MgoRpcCliNet"), common.CustomConfig.GetString("MgoRpcCliAddr"))
|
lis, err := net.Listen(common.CustomConfig.GetString("MgoRpcCliNet"), common.CustomConfig.GetString("MgoRpcCliAddr"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("rpc start fatal error: ", err)
|
log.Fatalln("fatal error: ", err)
|
||||||
}
|
}
|
||||||
go http.Serve(lis, nil)
|
go http.Serve(lis, nil)
|
||||||
return nil
|
|
||||||
})
|
waitor := module.Start()
|
||||||
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
waitor.Wait("main()")
|
||||||
mq.StopConsumer()
|
|
||||||
mq.StopPublisher()
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
// module模块
|
|
||||||
w := module.Start()
|
|
||||||
w.Wait("main()")
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,11 @@ package mq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/broker"
|
|
||||||
"mongo.games.com/goserver/core/broker/rabbitmq"
|
|
||||||
|
|
||||||
"mongo.games.com/game/dbproxy/svc"
|
"mongo.games.com/game/dbproxy/svc"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/mq"
|
"mongo.games.com/game/mq"
|
||||||
|
"mongo.games.com/goserver/core/broker"
|
||||||
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -16,7 +14,13 @@ func init() {
|
||||||
msg := e.Message()
|
msg := e.Message()
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
mq.BackUp(e, err)
|
||||||
|
}
|
||||||
|
|
||||||
e.Ack()
|
e.Ack()
|
||||||
|
|
||||||
|
recover()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var log model.APILog
|
var log model.APILog
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
package mq
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
//mq.RegisteSubscriber(model.ClientLogCollName, func(e broker.Event) (err error) {
|
||||||
|
// msg := e.Message()
|
||||||
|
// if msg != nil {
|
||||||
|
// defer func() {
|
||||||
|
// if err != nil {
|
||||||
|
// mq.BackUp(e, err)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// e.Ack()
|
||||||
|
//
|
||||||
|
// recover()
|
||||||
|
// }()
|
||||||
|
//
|
||||||
|
// var log model.ClientLog
|
||||||
|
// err = json.Unmarshal(msg.Body, &log)
|
||||||
|
// if err != nil {
|
||||||
|
// logger.Logger.Errorf("[mq] %s %v", model.ClientLogCollName, err)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// logger.Logger.Tracef("[mq] %s %v", model.ClientLogCollName, string(msg.Body))
|
||||||
|
//
|
||||||
|
// data := map[string]interface{}{}
|
||||||
|
// err = json.Unmarshal([]byte(log.Data), &data)
|
||||||
|
// if err != nil {
|
||||||
|
// logger.Logger.Errorf("[mq] %s %v", model.ClientLogCollName, err)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 获取平台id
|
||||||
|
// platform := log.Platform
|
||||||
|
// if log.Platform == "" {
|
||||||
|
// id, ok := data["platform"]
|
||||||
|
// if ok {
|
||||||
|
// platform = string(id.([]byte))
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// data["ts"] = log.Ts
|
||||||
|
// if log.Snid > 0 {
|
||||||
|
// data["snid"] = log.Snid
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// c := svc.ClientLogStartCollection(platform)
|
||||||
|
// if c != nil {
|
||||||
|
// err = c.Insert(data)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// return nil
|
||||||
|
//}, broker.Queue(model.ClientLogCollName), broker.DisableAutoAck(), rabbitmq.DurableQueue())
|
||||||
|
}
|
||||||
|
|
@ -2,13 +2,11 @@ package mq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/broker"
|
|
||||||
"mongo.games.com/goserver/core/broker/rabbitmq"
|
|
||||||
|
|
||||||
"mongo.games.com/game/dbproxy/svc"
|
"mongo.games.com/game/dbproxy/svc"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/mq"
|
"mongo.games.com/game/mq"
|
||||||
|
"mongo.games.com/goserver/core/broker"
|
||||||
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -16,7 +14,13 @@ func init() {
|
||||||
msg := e.Message()
|
msg := e.Message()
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
mq.BackUp(e, err)
|
||||||
|
}
|
||||||
|
|
||||||
e.Ack()
|
e.Ack()
|
||||||
|
|
||||||
|
recover()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var log model.CoinGiveLog
|
var log model.CoinGiveLog
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,11 @@ package mq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/broker"
|
|
||||||
"mongo.games.com/goserver/core/broker/rabbitmq"
|
|
||||||
|
|
||||||
"mongo.games.com/game/dbproxy/svc"
|
"mongo.games.com/game/dbproxy/svc"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/mq"
|
"mongo.games.com/game/mq"
|
||||||
|
"mongo.games.com/goserver/core/broker"
|
||||||
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -16,7 +14,13 @@ func init() {
|
||||||
msg := e.Message()
|
msg := e.Message()
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
mq.BackUp(e, err)
|
||||||
|
}
|
||||||
|
|
||||||
e.Ack()
|
e.Ack()
|
||||||
|
|
||||||
|
recover()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var log model.CoinLog
|
var log model.CoinLog
|
||||||
|
|
@ -26,7 +30,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if log.Count == 0 { //玩家冲账探针
|
if log.Count == 0 { //玩家冲账探针
|
||||||
mq.Send(model.TopicProbeCoinLogAck, log)
|
RabbitMQPublisher.Send(model.TopicProbeCoinLogAck, log)
|
||||||
} else {
|
} else {
|
||||||
c := svc.CoinLogsCollection(log.Platform)
|
c := svc.CoinLogsCollection(log.Platform)
|
||||||
if c != nil {
|
if c != nil {
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,11 @@ package mq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/broker"
|
|
||||||
"mongo.games.com/goserver/core/broker/rabbitmq"
|
|
||||||
|
|
||||||
"mongo.games.com/game/dbproxy/svc"
|
"mongo.games.com/game/dbproxy/svc"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/mq"
|
"mongo.games.com/game/mq"
|
||||||
|
"mongo.games.com/goserver/core/broker"
|
||||||
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -16,7 +14,13 @@ func init() {
|
||||||
msg := e.Message()
|
msg := e.Message()
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
mq.BackUp(e, err)
|
||||||
|
}
|
||||||
|
|
||||||
e.Ack()
|
e.Ack()
|
||||||
|
|
||||||
|
recover()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var log model.FriendRecord
|
var log model.FriendRecord
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,12 @@ package mq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/broker"
|
|
||||||
"mongo.games.com/goserver/core/broker/rabbitmq"
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
|
||||||
|
|
||||||
"mongo.games.com/game/dbproxy/svc"
|
"mongo.games.com/game/dbproxy/svc"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/mq"
|
"mongo.games.com/game/mq"
|
||||||
|
"mongo.games.com/goserver/core/broker"
|
||||||
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
|
"mongo.games.com/goserver/core/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -17,7 +15,13 @@ func init() {
|
||||||
msg := e.Message()
|
msg := e.Message()
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
mq.BackUp(e, err)
|
||||||
|
}
|
||||||
|
|
||||||
e.Ack()
|
e.Ack()
|
||||||
|
|
||||||
|
recover()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var log model.GameDetailedLog
|
var log model.GameDetailedLog
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,11 @@ package mq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/broker"
|
|
||||||
"mongo.games.com/goserver/core/broker/rabbitmq"
|
|
||||||
|
|
||||||
"mongo.games.com/game/dbproxy/svc"
|
"mongo.games.com/game/dbproxy/svc"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/mq"
|
"mongo.games.com/game/mq"
|
||||||
|
"mongo.games.com/goserver/core/broker"
|
||||||
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -16,7 +14,13 @@ func init() {
|
||||||
msg := e.Message()
|
msg := e.Message()
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
mq.BackUp(e, err)
|
||||||
|
}
|
||||||
|
|
||||||
e.Ack()
|
e.Ack()
|
||||||
|
|
||||||
|
recover()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var log model.GamePlayerListLog
|
var log model.GamePlayerListLog
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,13 @@ func init() {
|
||||||
msg := e.Message()
|
msg := e.Message()
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
mq.BackUp(e, err)
|
||||||
|
}
|
||||||
|
|
||||||
e.Ack()
|
e.Ack()
|
||||||
|
|
||||||
|
recover()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var log model.BindInvite
|
var log model.BindInvite
|
||||||
|
|
@ -53,7 +59,7 @@ func init() {
|
||||||
InviteNumCache.Put(name, n, int64(time.Hour.Seconds()))
|
InviteNumCache.Put(name, n, int64(time.Hour.Seconds()))
|
||||||
|
|
||||||
// 更新绑定数量
|
// 更新绑定数量
|
||||||
mq.Send(model.AckBindNum, &model.BindNum{
|
RabbitMQPublisher.Send(model.AckBindNum, &model.BindNum{
|
||||||
SnId: log.InviteSnId,
|
SnId: log.InviteSnId,
|
||||||
Num: n,
|
Num: n,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,11 @@ package mq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/broker"
|
|
||||||
"mongo.games.com/goserver/core/broker/rabbitmq"
|
|
||||||
|
|
||||||
"mongo.games.com/game/dbproxy/svc"
|
"mongo.games.com/game/dbproxy/svc"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/mq"
|
"mongo.games.com/game/mq"
|
||||||
|
"mongo.games.com/goserver/core/broker"
|
||||||
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -16,7 +14,13 @@ func init() {
|
||||||
msg := e.Message()
|
msg := e.Message()
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
mq.BackUp(e, err)
|
||||||
|
}
|
||||||
|
|
||||||
e.Ack()
|
e.Ack()
|
||||||
|
|
||||||
|
recover()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var log model.ItemLog
|
var log model.ItemLog
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package mq
|
||||||
|
|
||||||
|
//func init() {
|
||||||
|
// mq.RegisteSubscriber(model.JackPotLogCollName, func(e broker.Event) (err error) {
|
||||||
|
// msg := e.Message()
|
||||||
|
// if msg != nil {
|
||||||
|
// defer func() {
|
||||||
|
// if err != nil {
|
||||||
|
// mq.BackUp(e, err)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// e.Ack()
|
||||||
|
//
|
||||||
|
// recover()
|
||||||
|
// }()
|
||||||
|
//
|
||||||
|
// var log model.JackPotLog
|
||||||
|
// err = json.Unmarshal(msg.Body, &log)
|
||||||
|
// if err != nil {
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// c := svc.JackPotLogsCollection(log.Platform)
|
||||||
|
// if c != nil {
|
||||||
|
// _, err = c.Upsert(bson.M{"_id": log.LogId}, log)
|
||||||
|
// }
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// return nil
|
||||||
|
// }, broker.Queue(model.JackPotLogCollName), broker.DisableAutoAck(), rabbitmq.DurableQueue())
|
||||||
|
//}
|
||||||
|
|
@ -2,13 +2,11 @@ package mq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/broker"
|
|
||||||
"mongo.games.com/goserver/core/broker/rabbitmq"
|
|
||||||
|
|
||||||
"mongo.games.com/game/dbproxy/svc"
|
"mongo.games.com/game/dbproxy/svc"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/mq"
|
"mongo.games.com/game/mq"
|
||||||
|
"mongo.games.com/goserver/core/broker"
|
||||||
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -16,7 +14,13 @@ func init() {
|
||||||
msg := e.Message()
|
msg := e.Message()
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
mq.BackUp(e, err)
|
||||||
|
}
|
||||||
|
|
||||||
e.Ack()
|
e.Ack()
|
||||||
|
|
||||||
|
recover()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var log model.LoginLog
|
var log model.LoginLog
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,13 @@ func init() {
|
||||||
msg := e.Message()
|
msg := e.Message()
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
mq.BackUp(e, err)
|
||||||
|
}
|
||||||
|
|
||||||
e.Ack()
|
e.Ack()
|
||||||
|
|
||||||
|
recover()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var log model.OnlineLog
|
var log model.OnlineLog
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,14 @@ package mq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"mongo.games.com/game/dbproxy/svc"
|
||||||
|
"mongo.games.com/game/model"
|
||||||
|
"mongo.games.com/game/mq"
|
||||||
"mongo.games.com/goserver/core"
|
"mongo.games.com/goserver/core"
|
||||||
"mongo.games.com/goserver/core/basic"
|
"mongo.games.com/goserver/core/basic"
|
||||||
"mongo.games.com/goserver/core/broker"
|
"mongo.games.com/goserver/core/broker"
|
||||||
"mongo.games.com/goserver/core/broker/rabbitmq"
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
|
||||||
"mongo.games.com/game/dbproxy/svc"
|
|
||||||
"mongo.games.com/game/model"
|
|
||||||
"mongo.games.com/game/mq"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -20,7 +18,13 @@ func init() {
|
||||||
msg := e.Message()
|
msg := e.Message()
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
mq.BackUp(e, err)
|
||||||
|
}
|
||||||
|
|
||||||
e.Ack()
|
e.Ack()
|
||||||
|
|
||||||
|
recover()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var log model.PlayerRankScore
|
var log model.PlayerRankScore
|
||||||
|
|
@ -49,7 +53,13 @@ func init() {
|
||||||
msg := e.Message()
|
msg := e.Message()
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
mq.BackUp(e, err)
|
||||||
|
}
|
||||||
|
|
||||||
e.Ack()
|
e.Ack()
|
||||||
|
|
||||||
|
recover()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var log model.RankPlayerCoin
|
var log model.RankPlayerCoin
|
||||||
|
|
@ -78,7 +88,13 @@ func init() {
|
||||||
msg := e.Message()
|
msg := e.Message()
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
mq.BackUp(e, err)
|
||||||
|
}
|
||||||
|
|
||||||
e.Ack()
|
e.Ack()
|
||||||
|
|
||||||
|
recover()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var log model.PlayerLevelInfo
|
var log model.PlayerLevelInfo
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,11 @@ package mq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/broker"
|
|
||||||
"mongo.games.com/goserver/core/broker/rabbitmq"
|
|
||||||
|
|
||||||
"mongo.games.com/game/dbproxy/svc"
|
"mongo.games.com/game/dbproxy/svc"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/mq"
|
"mongo.games.com/game/mq"
|
||||||
|
"mongo.games.com/goserver/core/broker"
|
||||||
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -16,7 +14,13 @@ func init() {
|
||||||
msg := e.Message()
|
msg := e.Message()
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
mq.BackUp(e, err)
|
||||||
|
}
|
||||||
|
|
||||||
e.Ack()
|
e.Ack()
|
||||||
|
|
||||||
|
recover()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var log model.SceneCoinLog
|
var log model.SceneCoinLog
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,11 @@ package mq
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/broker"
|
|
||||||
"mongo.games.com/goserver/core/broker/rabbitmq"
|
|
||||||
|
|
||||||
"mongo.games.com/game/dbproxy/svc"
|
"mongo.games.com/game/dbproxy/svc"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/mq"
|
"mongo.games.com/game/mq"
|
||||||
|
"mongo.games.com/goserver/core/broker"
|
||||||
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -16,7 +15,13 @@ func init() {
|
||||||
msg := e.Message()
|
msg := e.Message()
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
mq.BackUp(e, err)
|
||||||
|
}
|
||||||
|
|
||||||
e.Ack()
|
e.Ack()
|
||||||
|
|
||||||
|
recover()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var log model.WelfareLog
|
var log model.WelfareLog
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package mq
|
||||||
|
|
||||||
|
import (
|
||||||
|
"mongo.games.com/game/common"
|
||||||
|
"mongo.games.com/game/mq"
|
||||||
|
"mongo.games.com/goserver/core"
|
||||||
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
|
)
|
||||||
|
|
||||||
|
var RabbitMQPublisher *mq.RabbitMQPublisher
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
////首先加载游戏配置
|
||||||
|
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
||||||
|
//rabbitmq打开链接
|
||||||
|
RabbitMQPublisher = mq.NewRabbitMQPublisher(common.CustomConfig.GetString("RabbitMQURL"), rabbitmq.Exchange{Name: common.CustomConfig.GetString("RMQExchange"), Durable: true}, common.CustomConfig.GetInt("RMQPublishBacklog"))
|
||||||
|
if RabbitMQPublisher != nil {
|
||||||
|
err := RabbitMQPublisher.Start()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
||||||
|
//关闭rabbitmq连接
|
||||||
|
if RabbitMQPublisher != nil {
|
||||||
|
RabbitMQPublisher.Stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,260 @@
|
||||||
|
package etcd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"go.etcd.io/etcd/client/v3"
|
||||||
|
"mongo.games.com/goserver/core"
|
||||||
|
"mongo.games.com/goserver/core/basic"
|
||||||
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
|
||||||
|
"mongo.games.com/game/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
etcd常用操作和数据监听
|
||||||
|
*/
|
||||||
|
|
||||||
|
type (
|
||||||
|
InitFunc func() int64
|
||||||
|
WatchFunc func(context.Context, int64)
|
||||||
|
FuncPair struct {
|
||||||
|
initFunc InitFunc
|
||||||
|
watchFunc WatchFunc
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type Client struct {
|
||||||
|
cli *clientv3.Client
|
||||||
|
functions []FuncPair
|
||||||
|
closed bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) IsClosed() bool {
|
||||||
|
return c.closed
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) Ctx() context.Context {
|
||||||
|
if c.cli != nil {
|
||||||
|
return c.cli.Ctx()
|
||||||
|
}
|
||||||
|
return context.TODO()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) Open(etcdUrl []string, userName, passWord string, dialTimeout time.Duration) error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
c.cli, err = clientv3.New(clientv3.Config{
|
||||||
|
Endpoints: etcdUrl,
|
||||||
|
Username: userName,
|
||||||
|
Password: passWord,
|
||||||
|
DialTimeout: dialTimeout,
|
||||||
|
DialKeepAliveTime: 5 * time.Second,
|
||||||
|
DialKeepAliveTimeout: 30 * time.Second,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logger.Logger.Errorf("EtcdClient.open(%v) err:%v", etcdUrl, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
c.closed = false
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) Close() error {
|
||||||
|
logger.Logger.Warn("EtcdClient.close")
|
||||||
|
c.closed = true
|
||||||
|
if c.cli != nil {
|
||||||
|
return c.cli.Close()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// PutValue 添加键值对
|
||||||
|
func (c *Client) PutValue(key, value string) (*clientv3.PutResponse, error) {
|
||||||
|
resp, err := c.cli.Put(context.TODO(), key, value)
|
||||||
|
if err != nil {
|
||||||
|
logger.Logger.Warnf("EtcdClient.PutValue(%v,%v) error:%v", key, value, err)
|
||||||
|
}
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetValue 查询
|
||||||
|
func (c *Client) GetValue(key string) (*clientv3.GetResponse, error) {
|
||||||
|
resp, err := c.cli.Get(context.TODO(), key)
|
||||||
|
if err != nil {
|
||||||
|
logger.Logger.Warnf("EtcdClient.GetValue(%v) error:%v", key, err)
|
||||||
|
}
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// DelValue 返回删除了几条数据
|
||||||
|
func (c *Client) DelValue(key string) (*clientv3.DeleteResponse, error) {
|
||||||
|
res, err := c.cli.Delete(context.TODO(), key)
|
||||||
|
if err != nil {
|
||||||
|
logger.Logger.Warnf("EtcdClient.DelValue(%v) error:%v", key, err)
|
||||||
|
}
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// DelValueWithPrefix 按照前缀删除
|
||||||
|
func (c *Client) DelValueWithPrefix(prefix string) (*clientv3.DeleteResponse, error) {
|
||||||
|
res, err := c.cli.Delete(context.TODO(), prefix, clientv3.WithPrefix())
|
||||||
|
if err != nil {
|
||||||
|
logger.Logger.Warnf("EtcdClient.DelValueWithPrefix(%v) error:%v", prefix, err)
|
||||||
|
}
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetValueWithPrefix 获取前缀
|
||||||
|
func (c *Client) GetValueWithPrefix(prefix string) (*clientv3.GetResponse, error) {
|
||||||
|
resp, err := c.cli.Get(context.TODO(), prefix, clientv3.WithPrefix())
|
||||||
|
if err != nil {
|
||||||
|
logger.Logger.Warnf("EtcdClient.GetValueWIthPrefix(%v) error:%v", prefix, err)
|
||||||
|
}
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// WatchWithPrefix 监测前缀创建事件
|
||||||
|
func (c *Client) WatchWithPrefix(prefix string, revision int64) clientv3.WatchChan {
|
||||||
|
if c.cli != nil {
|
||||||
|
opts := []clientv3.OpOption{clientv3.WithPrefix(), clientv3.WithCreatedNotify()}
|
||||||
|
if revision > 0 {
|
||||||
|
opts = append(opts, clientv3.WithRev(revision))
|
||||||
|
}
|
||||||
|
return c.cli.Watch(clientv3.WithRequireLeader(context.Background()), prefix, opts...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compact 压缩数据
|
||||||
|
//func (this *Client) Compact() {
|
||||||
|
// if this.closed {
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// resp, err := this.GetValue("@@@GET_LASTEST_REVISION@@@")
|
||||||
|
// if err == nil {
|
||||||
|
// ctx, _ := context.WithCancel(this.cli.Ctx())
|
||||||
|
// start := time.Now()
|
||||||
|
// compactResponse, err := this.cli.Compact(ctx, resp.Header.Revision, clientv3.WithCompactPhysical())
|
||||||
|
// if err == nil {
|
||||||
|
// logger.Logger.Infof("EtcdClient.Compact From %v CompactResponse %v take %v", resp.Header.Revision, compactResponse.Header, time.Now().Sub(start))
|
||||||
|
// } else {
|
||||||
|
// logger.Logger.Errorf("EtcdClient.Compact From %v CompactResponse:%v take:%v err:%v", resp.Header.Revision, compactResponse, time.Now().Sub(start), err)
|
||||||
|
// }
|
||||||
|
// endpoints := this.cli.Endpoints()
|
||||||
|
// for _, endpoint := range endpoints {
|
||||||
|
// ctx1, _ := context.WithCancel(this.cli.Ctx())
|
||||||
|
// start := time.Now()
|
||||||
|
// defragmentResponse, err := this.cli.Defragment(ctx1, endpoint)
|
||||||
|
// if err == nil {
|
||||||
|
// logger.Logger.Infof("EtcdClient.Defragment %v,%v take %v", endpoint, defragmentResponse.Header, time.Now().Sub(start))
|
||||||
|
// } else {
|
||||||
|
// logger.Logger.Errorf("EtcdClient.Defragment DefragmentResponse:%v take:%v err:%v", defragmentResponse, time.Now().Sub(start), err)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
// AddFunc 添加监听函数
|
||||||
|
func (c *Client) AddFunc(initFunc InitFunc, watchFunc WatchFunc) {
|
||||||
|
funcPair := FuncPair{
|
||||||
|
initFunc: initFunc,
|
||||||
|
watchFunc: watchFunc,
|
||||||
|
}
|
||||||
|
c.functions = append(c.functions, funcPair)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReInitAndWatchAll 重新监听
|
||||||
|
func (c *Client) ReInitAndWatchAll() {
|
||||||
|
if c.closed {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
oldFunc := c.functions
|
||||||
|
c.functions = nil
|
||||||
|
for i := 0; i < len(oldFunc); i++ {
|
||||||
|
c.InitAndWatch(oldFunc[i].initFunc, oldFunc[i].watchFunc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// InitAndWatch 开始监听
|
||||||
|
func (c *Client) InitAndWatch(initFunc InitFunc, watchFunc WatchFunc) {
|
||||||
|
funcPair := FuncPair{
|
||||||
|
initFunc: initFunc,
|
||||||
|
watchFunc: watchFunc,
|
||||||
|
}
|
||||||
|
c.functions = append(c.functions, funcPair)
|
||||||
|
lastRevision := initFunc()
|
||||||
|
ctx, _ := context.WithCancel(c.cli.Ctx())
|
||||||
|
watchFunc(ctx, lastRevision+1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GoWatch 异步监听
|
||||||
|
func (c *Client) GoWatch(ctx context.Context, revision int64, prefix string, f func(res clientv3.WatchResponse) error) {
|
||||||
|
go func() {
|
||||||
|
defer func() {
|
||||||
|
if err := recover(); err != nil {
|
||||||
|
logger.Logger.Errorf("etcd watch WithPrefix(%v) panic:%v", prefix, err)
|
||||||
|
}
|
||||||
|
logger.Logger.Warnf("etcd watch WithPrefix(%v) quit!!!", prefix)
|
||||||
|
}()
|
||||||
|
var times int64
|
||||||
|
for !c.closed {
|
||||||
|
times++
|
||||||
|
logger.Logger.Warnf("etcd watch WithPrefix(%v) base revision %v start[%v]!!!", prefix, revision, times)
|
||||||
|
rch := c.WatchWithPrefix(prefix, revision)
|
||||||
|
for {
|
||||||
|
skip := false
|
||||||
|
select {
|
||||||
|
case _, ok := <-ctx.Done():
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case resp, ok := <-rch:
|
||||||
|
if !ok {
|
||||||
|
logger.Logger.Warnf("etcd watch WithPrefix(%v) be closed", prefix)
|
||||||
|
skip = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if resp.Header.Revision > revision {
|
||||||
|
revision = resp.Header.Revision
|
||||||
|
}
|
||||||
|
if resp.Canceled {
|
||||||
|
logger.Logger.Warnf("etcd watch WithPrefix(%v) be closed, reason:%v", prefix, resp.Err())
|
||||||
|
skip = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if err := resp.Err(); err != nil {
|
||||||
|
logger.Logger.Warnf("etcd watch WithPrefix(%v) err:%v", prefix, resp.Err())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !model.GameParamData.UseEtcd {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if len(resp.Events) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Logger.Tracef("@goWatch %v changed, header:%#v", prefix, resp.Header)
|
||||||
|
obj := core.CoreObject()
|
||||||
|
if obj != nil {
|
||||||
|
func(res clientv3.WatchResponse) {
|
||||||
|
obj.SendCommand(basic.CommandWrapper(func(*basic.Object) error {
|
||||||
|
return f(res)
|
||||||
|
}), true)
|
||||||
|
}(resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if skip {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package etcd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"mongo.games.com/goserver/core"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
||||||
|
mgr.Start()
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
||||||
|
mgr.Shutdown()
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -2,17 +2,40 @@ package etcd
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// 系统配置
|
// 系统配置
|
||||||
|
ETCDKEY_SYS_ROOT_PREFIX = "/sys/"
|
||||||
ETCDKEY_SYS_PLT_DBCFG_PREFIX = "/sys/plt/dbcfg/"
|
ETCDKEY_SYS_PLT_DBCFG_PREFIX = "/sys/plt/dbcfg/"
|
||||||
|
|
||||||
//业务配置
|
//业务配置
|
||||||
|
ETCDKEY_ROOT_PREFIX = "/game/"
|
||||||
ETCDKEY_PLATFORM_PREFIX = "/game/plt/config/"
|
ETCDKEY_PLATFORM_PREFIX = "/game/plt/config/"
|
||||||
|
ETCDKEY_BULLETIN_PREFIX = "/game/plt/bulletin/"
|
||||||
|
ETCDKEY_AGENTCUSTOMER_PREFIX = "/game/plt/agent_customer/"
|
||||||
ETCDKEY_GAME_CONFIG_GLOBAL = "/game/plt/game_config_global" // 超管平台游戏开关
|
ETCDKEY_GAME_CONFIG_GLOBAL = "/game/plt/game_config_global" // 超管平台游戏开关
|
||||||
ETCDKEY_GAMECONFIG_PREFIX = "/game/plt/game_config/" // 平台游戏配置
|
ETCDKEY_GAMECONFIG_PREFIX = "/game/plt/game_config/" // 平台游戏配置
|
||||||
ETCDKEY_PACKAGE_PREFIX = "/game/plt/package/"
|
ETCDKEY_PACKAGE_PREFIX = "/game/plt/package/"
|
||||||
ETCDKEY_GROUPCONFIG_PREFIX = "/game/group_config/"
|
ETCDKEY_GROUPCONFIG_PREFIX = "/game/group_config/"
|
||||||
ETCDKEY_BLACKLIST_PREFIX = "/game/plt/black_list/"
|
ETCDKEY_BLACKLIST_PREFIX = "/game/plt/black_list/"
|
||||||
|
ETCDKEY_ACT_SIGNIN_PREFIX = "/game/activity/signin/"
|
||||||
|
ETCDKEY_ACT_TASK_PREFIX = "/game/activity/task/"
|
||||||
|
ETCDKEY_ACT_GOLDTASK_PREFIX = "/game/activity/goldtask/"
|
||||||
|
ETCDKEY_ACT_GOLDCOME_PREFIX = "/game/activity/goldcome/"
|
||||||
|
ETCDKEY_ACT_ONLINEREWARD_PREFIX = "/game/activity/onlinereward/"
|
||||||
|
ETCDKEY_ACT_LUCKLYTURNTABLE_PREFIX = "/game/activity/lucklyturntable/"
|
||||||
|
ETCDKEY_ACT_YEB_PREFIX = "/game/activity/yeb/"
|
||||||
|
ETCDKEY_CONFIG_REBATE = "/game/plt/game_rebate_config/"
|
||||||
ETCDKEY_PROMOTER_PREFIX = "/game/plt/promoter/"
|
ETCDKEY_PROMOTER_PREFIX = "/game/plt/promoter/"
|
||||||
|
ETCDKEY_ACT_VIP_PREFIX = "/game/plt/actvip/"
|
||||||
|
ETCDKEY_ACT_WEIXIN_SHARE_PREFIX = "/game/plt/actshare/"
|
||||||
ETCDKEY_ACT_GIVE_PREFIX = "/game/plt/actgive/"
|
ETCDKEY_ACT_GIVE_PREFIX = "/game/plt/actgive/"
|
||||||
|
ETCDKEY_ACT_PAY_PREFIX = "/game/plt/payact/"
|
||||||
|
ETCDKEY_ACT_RANDCOIN_PREFIX = "/game/plt/randcoin/"
|
||||||
|
ETCDKEY_ACT_FPAY_PREFIX = "/game/plt/fpay/"
|
||||||
|
ETCDKEY_PLATFORM_PROFITCONTROL = "/game/plt/profitcontrol/"
|
||||||
|
ETCDKEY_MATCH_PROFIX = "/game/match/"
|
||||||
|
ETCDKEY_ACT_TICKET_PROFIX = "/game/activity/ticket/"
|
||||||
|
ETCDKEY_ACT_TICKET_RUNNING = "/game/activity/ticket/running"
|
||||||
|
ETCDKEY_MATCH_GRADESHOP = "/game/match/gradeshop/"
|
||||||
|
ETCDKEY_CONFIG_LOGICLEVEL = "/game/logiclevel/"
|
||||||
ETCDKEY_SHOP_EXCHANGE = "/game/exchange_shop"
|
ETCDKEY_SHOP_EXCHANGE = "/game/exchange_shop"
|
||||||
ETCDKEY_GAME_NOTICE = "/game/common_notice"
|
ETCDKEY_GAME_NOTICE = "/game/common_notice"
|
||||||
ETCDKEY_SHOP_ITEM = "/game/item_shop"
|
ETCDKEY_SHOP_ITEM = "/game/item_shop"
|
||||||
|
|
@ -24,6 +47,7 @@ const (
|
||||||
ETCDKEY_ACT_CONTINUOUSPAY = "/game/act_ContinuousPay"
|
ETCDKEY_ACT_CONTINUOUSPAY = "/game/act_ContinuousPay"
|
||||||
ETCDKEY_ACT_Collect = "/game/act_collect"
|
ETCDKEY_ACT_Collect = "/game/act_collect"
|
||||||
ETCDKEY_VIP_CFG = "/game/VIPcfg"
|
ETCDKEY_VIP_CFG = "/game/VIPcfg"
|
||||||
|
ETCDKEY_WBCtrl_CFG = "/game/WBCtrlCfg"
|
||||||
ETCDKEY_PACKAGE_ENTRYSWITCH = "/game/plt/entryswitch/" //界面入口开关
|
ETCDKEY_PACKAGE_ENTRYSWITCH = "/game/plt/entryswitch/" //界面入口开关
|
||||||
ETCDKEY_CHESSRANK_CFG = "/game/plt/chessrank/" // 象棋段位配置
|
ETCDKEY_CHESSRANK_CFG = "/game/plt/chessrank/" // 象棋段位配置
|
||||||
ETCDKEY_PLAYERPOOL = "/game/plt/playerpool/" // 个人水池调控配置
|
ETCDKEY_PLAYERPOOL = "/game/plt/playerpool/" // 个人水池调控配置
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,123 @@
|
||||||
|
package etcd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"reflect"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"go.etcd.io/etcd/client/v3"
|
||||||
|
|
||||||
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
|
||||||
|
"mongo.games.com/game/common"
|
||||||
|
"mongo.games.com/game/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
var mgr = &Manager{Client: new(Client)}
|
||||||
|
|
||||||
|
type Manager struct {
|
||||||
|
*Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register .
|
||||||
|
func (this *Manager) Register(key string, msgType interface{}, f func(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{})) {
|
||||||
|
|
||||||
|
createFunc := func() interface{} {
|
||||||
|
tp := reflect.TypeOf(msgType)
|
||||||
|
if tp.Kind() == reflect.Ptr {
|
||||||
|
tp = tp.Elem()
|
||||||
|
}
|
||||||
|
return reflect.New(tp).Interface()
|
||||||
|
}
|
||||||
|
|
||||||
|
initFunc := func() int64 {
|
||||||
|
logger.Logger.Info("ETCD 拉取数据:", key)
|
||||||
|
res, err := this.GetValueWithPrefix(key)
|
||||||
|
if err == nil {
|
||||||
|
for i := int64(0); i < res.Count; i++ {
|
||||||
|
data := createFunc()
|
||||||
|
v, ok := data.(proto.Message)
|
||||||
|
if !ok {
|
||||||
|
logger.Logger.Errorf("ETCD %v error: not proto message", key)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
err := proto.Unmarshal(res.Kvs[i].Value, v)
|
||||||
|
if err != nil {
|
||||||
|
logger.Logger.Errorf("ETCD %v unmarshal error:%v", key, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
logger.Logger.Tracef("ETCD 拉取成功 %v ==> %v", string(res.Kvs[i].Key), v)
|
||||||
|
event := &clientv3.Event{
|
||||||
|
Type: 0,
|
||||||
|
}
|
||||||
|
f(context.TODO(), string(res.Kvs[i].Key), true, event, v)
|
||||||
|
}
|
||||||
|
if res.Header != nil {
|
||||||
|
return res.Header.Revision
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("ETCD get WithPrefix(%v) panic:%v", key, err)
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监控数据变动
|
||||||
|
watchFunc := func(ctx context.Context, revision int64) {
|
||||||
|
this.GoWatch(ctx, revision, key, func(res clientv3.WatchResponse) error {
|
||||||
|
for _, ev := range res.Events {
|
||||||
|
switch ev.Type {
|
||||||
|
case clientv3.EventTypePut:
|
||||||
|
data := createFunc()
|
||||||
|
v, ok := data.(proto.Message)
|
||||||
|
if !ok {
|
||||||
|
logger.Logger.Errorf("ETCD %v error: not proto message", string(ev.Kv.Key))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
err := proto.Unmarshal(ev.Kv.Value, v)
|
||||||
|
if err != nil {
|
||||||
|
logger.Logger.Errorf("etcd unmarshal(%v) error:%v", string(ev.Kv.Key), err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
logger.Logger.Tracef("ETCD 更新事件 %v ==> %v", string(ev.Kv.Key), v)
|
||||||
|
f(ctx, string(ev.Kv.Key), false, ev, v)
|
||||||
|
case clientv3.EventTypeDelete:
|
||||||
|
logger.Logger.Tracef("ETCD 删除事件 %v", string(ev.Kv.Key))
|
||||||
|
f(ctx, string(ev.Kv.Key), false, ev, nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.AddFunc(initFunc, watchFunc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Manager) Start() {
|
||||||
|
logger.Logger.Infof("EtcdClient开始连接url:%v;etcduser:%v;etcdpwd:%v", common.CustomConfig.GetStrings("etcdurl"), common.CustomConfig.GetString("etcduser"), common.CustomConfig.GetString("etcdpwd"))
|
||||||
|
err := this.Open(common.CustomConfig.GetStrings("etcdurl"), common.CustomConfig.GetString("etcduser"), common.CustomConfig.GetString("etcdpwd"), time.Minute)
|
||||||
|
if err != nil {
|
||||||
|
logger.Logger.Tracef("Manager.Open err:%v", err)
|
||||||
|
}
|
||||||
|
this.ReInitAndWatchAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Manager) Shutdown() {
|
||||||
|
this.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Manager) Reset() {
|
||||||
|
this.Close()
|
||||||
|
this.Start()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register 注册etcd监听方法
|
||||||
|
// key:监听的key
|
||||||
|
// msgType:数据类型
|
||||||
|
// f:数据变更回调方法, completeKey:完整键, isInit:第一次主动拉取数据,event:事件类型, data:已经反序列化的数据,类型为msgType,是指针类型
|
||||||
|
func Register(key string, msgType interface{}, f func(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{})) {
|
||||||
|
mgr.Register(key, msgType, f)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Reset() {
|
||||||
|
mgr.Reset()
|
||||||
|
}
|
||||||
120
etcd/register.go
120
etcd/register.go
|
|
@ -1,120 +0,0 @@
|
||||||
package etcd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"reflect"
|
|
||||||
|
|
||||||
"go.etcd.io/etcd/client/v3"
|
|
||||||
"mongo.games.com/goserver/core"
|
|
||||||
"mongo.games.com/goserver/core/basic"
|
|
||||||
"mongo.games.com/goserver/core/etcd"
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
|
||||||
|
|
||||||
"mongo.games.com/game/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Register 注册etcd监听方法
|
|
||||||
// key:监听的key
|
|
||||||
// msgType:数据类型
|
|
||||||
// f:数据变更回调方法, completeKey:完整键, isInit:第一次主动拉取数据,event:事件类型, data:已经反序列化的数据,类型为msgType,是指针类型
|
|
||||||
func Register(key string, msgType interface{}, f func(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{})) {
|
|
||||||
createFunc := func() interface{} {
|
|
||||||
tp := reflect.TypeOf(msgType)
|
|
||||||
if tp.Kind() == reflect.Ptr {
|
|
||||||
tp = tp.Elem()
|
|
||||||
}
|
|
||||||
return reflect.New(tp).Interface()
|
|
||||||
}
|
|
||||||
|
|
||||||
initFunc := func(ctx context.Context, res *clientv3.GetResponse) {
|
|
||||||
if res == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
f := func() {
|
|
||||||
for i := int64(0); i < res.Count; i++ {
|
|
||||||
data := createFunc()
|
|
||||||
switch d := data.(type) {
|
|
||||||
case proto.Message:
|
|
||||||
err := proto.Unmarshal(res.Kvs[i].Value, d)
|
|
||||||
if err != nil {
|
|
||||||
logger.Logger.Errorf("ETCD %v proto.Unmarshal error:%v", key, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
logger.Logger.Tracef("ETCD 拉取成功 %v ==> %v", string(res.Kvs[i].Key), d)
|
|
||||||
event := &clientv3.Event{
|
|
||||||
Type: 0,
|
|
||||||
}
|
|
||||||
f(context.TODO(), string(res.Kvs[i].Key), true, event, d)
|
|
||||||
default:
|
|
||||||
err := json.Unmarshal(res.Kvs[i].Value, d)
|
|
||||||
if err != nil {
|
|
||||||
logger.Logger.Errorf("ETCD %v josn.Unmarshal error:%v", key, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
logger.Logger.Tracef("ETCD 拉取成功 %v ==> %v", string(res.Kvs[i].Key), d)
|
|
||||||
event := &clientv3.Event{
|
|
||||||
Type: 0,
|
|
||||||
}
|
|
||||||
f(context.TODO(), string(res.Kvs[i].Key), true, event, d)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
obj := core.CoreObject()
|
|
||||||
if obj == nil {
|
|
||||||
f()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
obj.SendCommand(basic.CommandWrapper(func(*basic.Object) error {
|
|
||||||
f()
|
|
||||||
return nil
|
|
||||||
}), true)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 监控数据变动
|
|
||||||
watchFunc := func(ctx context.Context, res *clientv3.WatchResponse) {
|
|
||||||
if res == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
f := func() {
|
|
||||||
for _, ev := range res.Events {
|
|
||||||
switch ev.Type {
|
|
||||||
case clientv3.EventTypePut:
|
|
||||||
data := createFunc()
|
|
||||||
switch d := data.(type) {
|
|
||||||
case proto.Message:
|
|
||||||
err := proto.Unmarshal(ev.Kv.Value, d)
|
|
||||||
if err != nil {
|
|
||||||
logger.Logger.Errorf("ETCD %v proto.Unmarshal error:%v", key, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
logger.Logger.Tracef("ETCD 更新事件 %v ==> %v", string(ev.Kv.Key), d)
|
|
||||||
f(ctx, string(ev.Kv.Key), false, ev, d)
|
|
||||||
default:
|
|
||||||
err := json.Unmarshal(ev.Kv.Value, d)
|
|
||||||
if err != nil {
|
|
||||||
logger.Logger.Errorf("ETCD %v josn.Unmarshal error:%v", key, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
logger.Logger.Tracef("ETCD 更新事件 %v ==> %v", string(ev.Kv.Key), d)
|
|
||||||
f(ctx, string(ev.Kv.Key), false, ev, d)
|
|
||||||
}
|
|
||||||
case clientv3.EventTypeDelete:
|
|
||||||
logger.Logger.Tracef("ETCD 删除事件 %v", string(ev.Kv.Key))
|
|
||||||
f(ctx, string(ev.Kv.Key), false, ev, nil)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
obj := core.CoreObject()
|
|
||||||
if obj == nil {
|
|
||||||
f()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
obj.SendCommand(basic.CommandWrapper(func(*basic.Object) error {
|
|
||||||
f()
|
|
||||||
return nil
|
|
||||||
}), true)
|
|
||||||
}
|
|
||||||
|
|
||||||
etcd.AddFunc(key, initFunc, watchFunc)
|
|
||||||
}
|
|
||||||
|
|
@ -164,6 +164,7 @@ func init() {
|
||||||
|
|
||||||
p.LastSyncCoin = p.Coin
|
p.LastSyncCoin = p.Coin
|
||||||
p.IsQM = IsQM
|
p.IsQM = IsQM
|
||||||
|
p.AppChannel = msg.GetAppChannel()
|
||||||
|
|
||||||
if sid == 0 && (scene != nil && !scene.IsMatchScene()) {
|
if sid == 0 && (scene != nil && !scene.IsMatchScene()) {
|
||||||
logger.Logger.Warnf("when WGPlayerEnter (sid == 0)")
|
logger.Logger.Warnf("when WGPlayerEnter (sid == 0)")
|
||||||
|
|
@ -307,6 +308,7 @@ func init() {
|
||||||
p.SetTakeCoin(msg.GetTakeCoin())
|
p.SetTakeCoin(msg.GetTakeCoin())
|
||||||
p.LastSyncCoin = p.Coin
|
p.LastSyncCoin = p.Coin
|
||||||
p.IsQM = IsQM
|
p.IsQM = IsQM
|
||||||
|
p.AppChannel = msg.GetAppChannel()
|
||||||
if scene != nil {
|
if scene != nil {
|
||||||
scene.AudienceEnter(p, isload)
|
scene.AudienceEnter(p, isload)
|
||||||
if !p.IsRobot() && !scene.Testing {
|
if !p.IsRobot() && !scene.Testing {
|
||||||
|
|
@ -557,7 +559,7 @@ func init() {
|
||||||
return nil
|
return nil
|
||||||
}))
|
}))
|
||||||
|
|
||||||
//同步记牌器过期时间
|
//玩家离开
|
||||||
netlib.RegisterFactory(int(server.SSPacketID_PACKET_WG_BUYRECTIMEITEM), netlib.PacketFactoryWrapper(func() interface{} {
|
netlib.RegisterFactory(int(server.SSPacketID_PACKET_WG_BUYRECTIMEITEM), netlib.PacketFactoryWrapper(func() interface{} {
|
||||||
return &server.WGBuyRecTimeItem{}
|
return &server.WGBuyRecTimeItem{}
|
||||||
}))
|
}))
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
package base
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"mongo.games.com/goserver/core"
|
||||||
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
|
|
||||||
|
"mongo.games.com/game/common"
|
||||||
|
"mongo.games.com/game/model"
|
||||||
|
"mongo.games.com/game/mq"
|
||||||
|
)
|
||||||
|
|
||||||
|
var RabbitMQPublisher *mq.RabbitMQPublisher
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
model.InitGameParam()
|
||||||
|
model.InitFishingParam()
|
||||||
|
model.InitNormalParam()
|
||||||
|
model.InitGMAC()
|
||||||
|
|
||||||
|
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
||||||
|
model.StartupRPClient(common.CustomConfig.GetString("MgoRpcCliNet"), common.CustomConfig.GetString("MgoRpcCliAddr"), time.Duration(common.CustomConfig.GetInt("MgoRpcCliReconnInterV"))*time.Second)
|
||||||
|
model.InitGameKVData()
|
||||||
|
|
||||||
|
//rabbitmq打开链接
|
||||||
|
RabbitMQPublisher = mq.NewRabbitMQPublisher(common.CustomConfig.GetString("RabbitMQURL"), rabbitmq.Exchange{Name: common.CustomConfig.GetString("RMQExchange"), Durable: true}, common.CustomConfig.GetInt("RMQPublishBacklog"))
|
||||||
|
if RabbitMQPublisher != nil {
|
||||||
|
err := RabbitMQPublisher.Start()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
||||||
|
//关闭rabbitmq连接
|
||||||
|
if RabbitMQPublisher != nil {
|
||||||
|
RabbitMQPublisher.Stop()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/mq"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// LogChannelSingleton 日志记录器
|
// LogChannelSingleton 日志记录器
|
||||||
|
|
@ -38,11 +37,11 @@ func (c *LogChannel) WriteLog(log interface{}) {
|
||||||
if cname == "" {
|
if cname == "" {
|
||||||
cname = "_null_"
|
cname = "_null_"
|
||||||
}
|
}
|
||||||
mq.Send(cname, log)
|
RabbitMQPublisher.Send(cname, log)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *LogChannel) WriteMQData(data *model.RabbitMQData) {
|
func (c *LogChannel) WriteMQData(data *model.RabbitMQData) {
|
||||||
mq.Send(data.MQName, data.Data)
|
RabbitMQPublisher.Send(data.MQName, data.Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ type Player struct {
|
||||||
MatchRobotGrades []MatchRobotGrade
|
MatchRobotGrades []MatchRobotGrade
|
||||||
TestLog []string // 调试日志
|
TestLog []string // 调试日志
|
||||||
RankScore map[int32]int64 // 段位积分
|
RankScore map[int32]int64 // 段位积分
|
||||||
|
AppChannel string // app渠道(玩家本次登录使用的包的渠道类型,换登录包,这个值也会变;玩家model.PlayerData存储的渠道是玩家第一次登录的渠道,不会修改)
|
||||||
}
|
}
|
||||||
|
|
||||||
type MatchRobotGrade struct {
|
type MatchRobotGrade struct {
|
||||||
|
|
|
||||||
|
|
@ -1632,8 +1632,6 @@ func (this *Scene) NewBigCoinNotice(player *Player, num int64, msgType int64) {
|
||||||
|
|
||||||
type GameDetailedParam struct {
|
type GameDetailedParam struct {
|
||||||
Trend20Lately string //最近20局开奖结果
|
Trend20Lately string //最近20局开奖结果
|
||||||
CtrlType int
|
|
||||||
PlayerPool map[int]int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存详细游戏日志
|
// 保存详细游戏日志
|
||||||
|
|
@ -1653,8 +1651,7 @@ func (this *Scene) SaveGameDetailedLog(logid string, gamedetailednote string, ga
|
||||||
log := model.NewGameDetailedLogEx(logid, int32(this.GameId), int32(this.SceneId),
|
log := model.NewGameDetailedLogEx(logid, int32(this.GameId), int32(this.SceneId),
|
||||||
this.DbGameFree.GetGameMode(), this.DbGameFree.Id, int32(len(this.Players)),
|
this.DbGameFree.GetGameMode(), this.DbGameFree.Id, int32(len(this.Players)),
|
||||||
int32(time.Now().Unix()-this.GameNowTime.Unix()), baseScore,
|
int32(time.Now().Unix()-this.GameNowTime.Unix()), baseScore,
|
||||||
gamedetailednote, p.Platform, this.ClubId, this.RoomId, this.CpCtx, GameDetailedVer[this.GameId], trend20Lately,
|
gamedetailednote, p.Platform, this.ClubId, this.RoomId, this.CpCtx, GameDetailedVer[this.GameId], trend20Lately)
|
||||||
gameDetailedParam.CtrlType, gameDetailedParam.PlayerPool)
|
|
||||||
if log != nil {
|
if log != nil {
|
||||||
if this.IsMatchScene() {
|
if this.IsMatchScene() {
|
||||||
log.MatchId = this.MatchId
|
log.MatchId = this.MatchId
|
||||||
|
|
@ -1667,8 +1664,7 @@ func (this *Scene) SaveGameDetailedLog(logid string, gamedetailednote string, ga
|
||||||
log := model.NewGameDetailedLogEx(logid, int32(this.GameId), int32(this.SceneId),
|
log := model.NewGameDetailedLogEx(logid, int32(this.GameId), int32(this.SceneId),
|
||||||
this.DbGameFree.GetGameMode(), this.DbGameFree.Id, int32(len(this.Players)),
|
this.DbGameFree.GetGameMode(), this.DbGameFree.Id, int32(len(this.Players)),
|
||||||
int32(time.Now().Unix()-this.GameNowTime.Unix()), baseScore,
|
int32(time.Now().Unix()-this.GameNowTime.Unix()), baseScore,
|
||||||
gamedetailednote, this.Platform, this.ClubId, this.RoomId, this.CpCtx, GameDetailedVer[this.GameId], trend20Lately,
|
gamedetailednote, this.Platform, this.ClubId, this.RoomId, this.CpCtx, GameDetailedVer[this.GameId], trend20Lately)
|
||||||
gameDetailedParam.CtrlType, gameDetailedParam.PlayerPool)
|
|
||||||
if log != nil {
|
if log != nil {
|
||||||
if this.IsMatchScene() {
|
if this.IsMatchScene() {
|
||||||
log.MatchId = this.MatchId
|
log.MatchId = this.MatchId
|
||||||
|
|
@ -2132,7 +2128,7 @@ func (this *Scene) TryBillExGameDrop(p *Player) {
|
||||||
|
|
||||||
// 渠道开关
|
// 渠道开关
|
||||||
conf := ConfigMgrInst.GetConfig(p.Platform).ChannelSwitch[common.ChannelSwitchDropItem]
|
conf := ConfigMgrInst.GetConfig(p.Platform).ChannelSwitch[common.ChannelSwitchDropItem]
|
||||||
if !model.GameParamData.CloseChannelSwitch && (conf == nil || !common.InSliceString(conf.OnChannelName, p.LastChannel)) {
|
if !model.GameParamData.CloseChannelSwitch && (conf == nil || !common.InSliceString(conf.OnChannelName, p.AppChannel)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2162,7 +2158,6 @@ func (this *Scene) TryBillExGameDrop(p *Player) {
|
||||||
pack := &player.SCGameExDropItems{}
|
pack := &player.SCGameExDropItems{}
|
||||||
pack.Items = make(map[int32]int32)
|
pack.Items = make(map[int32]int32)
|
||||||
for id, num := range realDrop {
|
for id, num := range realDrop {
|
||||||
remark := fmt.Sprintf("游戏掉落%v", id)
|
|
||||||
pack.Items[id] = proto.Int32(num)
|
pack.Items[id] = proto.Int32(num)
|
||||||
itemData := srvdata.PBDB_GameItemMgr.GetData(id)
|
itemData := srvdata.PBDB_GameItemMgr.GetData(id)
|
||||||
if itemData != nil {
|
if itemData != nil {
|
||||||
|
|
@ -2174,8 +2169,8 @@ func (this *Scene) TryBillExGameDrop(p *Player) {
|
||||||
ItemId: itemData.Id,
|
ItemId: itemData.Id,
|
||||||
ItemName: itemData.Name,
|
ItemName: itemData.Name,
|
||||||
Count: int64(num),
|
Count: int64(num),
|
||||||
Remark: remark,
|
Remark: "tienlen游戏掉落",
|
||||||
TypeId: common.GainWay_Game,
|
TypeId: common.GainWay_Interact,
|
||||||
GameId: int64(this.GameId),
|
GameId: int64(this.GameId),
|
||||||
GameFreeId: int64(this.GetGameFreeId()),
|
GameFreeId: int64(this.GetGameFreeId()),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
|
"mongo.games.com/goserver/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ServerStateMgr = &ServerStateManager{
|
var ServerStateMgr = &ServerStateManager{
|
||||||
|
|
@ -23,3 +24,10 @@ func (this *ServerStateManager) SetState(state common.GameSessState) {
|
||||||
func (this *ServerStateManager) GetState() common.GameSessState {
|
func (this *ServerStateManager) GetState() common.GameSessState {
|
||||||
return this.State
|
return this.State
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
||||||
|
ServerStateMgr.Init()
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package base
|
||||||
import (
|
import (
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/srvdata"
|
"mongo.games.com/game/srvdata"
|
||||||
|
"mongo.games.com/goserver/core"
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -185,3 +186,12 @@ func (this *DB_FishOutMgrEx) InitFishAppear() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 初始化在线奖励系统
|
||||||
|
func init() {
|
||||||
|
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
||||||
|
logger.Logger.Info("初始化牌库[S]")
|
||||||
|
defer logger.Logger.Info("初始化牌库[E]")
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -148,19 +148,18 @@
|
||||||
"profile": {
|
"profile": {
|
||||||
"SlowMS": 500
|
"SlowMS": 500
|
||||||
},
|
},
|
||||||
"etcd": {
|
|
||||||
"Url": ["127.0.0.1:2379"],
|
|
||||||
"UserName": "",
|
|
||||||
"Password": "",
|
|
||||||
"DialTimeout": 60
|
|
||||||
},
|
|
||||||
"costum": {
|
"costum": {
|
||||||
"MgoRpcCliNet": "tcp",
|
"MgoRpcCliNet": "tcp",
|
||||||
"MgoRpcCliAddr": "127.0.0.1:8999",
|
"MgoRpcCliAddr": "127.0.0.1:8999",
|
||||||
"MgoRpcCliReconnInterV": 3,
|
"MgoRpcCliReconnInterV": 3,
|
||||||
"RabbitMQURL": "amqp://win88:123456@127.0.0.1:5672/win88",
|
"RabbitMQURL": "amqp://win88:123456@127.0.0.1:5672/win88",
|
||||||
"RMQExchange": "win88",
|
"RMQExchange": "win88",
|
||||||
"RMQPublishBacklog": 1024
|
"RMQPublishBacklog": 1024,
|
||||||
|
"etcdurl": [
|
||||||
|
"127.0.0.1:2379"
|
||||||
|
],
|
||||||
|
"etcduser": "",
|
||||||
|
"etcdpwd": ""
|
||||||
},
|
},
|
||||||
"webapi": {
|
"webapi": {
|
||||||
"GameApiURL": "http://127.0.0.1:8000/api/game_srv"
|
"GameApiURL": "http://127.0.0.1:8000/api/game_srv"
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,17 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"mongo.games.com/goserver/core"
|
"mongo.games.com/goserver/core"
|
||||||
"mongo.games.com/goserver/core/etcd"
|
|
||||||
_ "mongo.games.com/goserver/core/i18n"
|
_ "mongo.games.com/goserver/core/i18n"
|
||||||
"mongo.games.com/goserver/core/module"
|
"mongo.games.com/goserver/core/module"
|
||||||
|
|
||||||
_ "mongo.games.com/game"
|
_ "mongo.games.com/game"
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
|
_ "mongo.games.com/game/srvdata"
|
||||||
|
|
||||||
_ "mongo.games.com/game/gamesrv/action"
|
_ "mongo.games.com/game/gamesrv/action"
|
||||||
_ "mongo.games.com/game/gamesrv/base"
|
_ "mongo.games.com/game/gamesrv/base"
|
||||||
_ "mongo.games.com/game/gamesrv/transact"
|
_ "mongo.games.com/game/gamesrv/transact"
|
||||||
"mongo.games.com/game/model"
|
|
||||||
"mongo.games.com/game/mq"
|
|
||||||
_ "mongo.games.com/game/srvdata"
|
|
||||||
|
|
||||||
// game
|
// game
|
||||||
_ "mongo.games.com/game/gamesrv/chess"
|
_ "mongo.games.com/game/gamesrv/chess"
|
||||||
|
|
@ -35,27 +31,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// 自定义配置文件
|
core.RegisterConfigEncryptor(common.ConfigFE)
|
||||||
model.InitGameParam()
|
|
||||||
model.InitFishingParam()
|
|
||||||
model.InitNormalParam()
|
|
||||||
model.InitGMAC()
|
|
||||||
// package模块
|
|
||||||
defer core.ClosePackages()
|
defer core.ClosePackages()
|
||||||
core.LoadPackages("config.json")
|
core.LoadPackages("config.json")
|
||||||
// core hook
|
|
||||||
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
waiter := module.Start()
|
||||||
etcd.Start()
|
waiter.Wait("main()")
|
||||||
model.StartupRPClient(common.CustomConfig.GetString("MgoRpcCliNet"), common.CustomConfig.GetString("MgoRpcCliAddr"), time.Duration(common.CustomConfig.GetInt("MgoRpcCliReconnInterV"))*time.Second)
|
|
||||||
mq.StartPublisher(common.CustomConfig.GetString("RabbitMQURL"), common.CustomConfig.GetString("RMQExchange"), true, common.CustomConfig.GetInt("RMQPublishBacklog"))
|
|
||||||
model.InitGameKVData()
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
|
||||||
mq.StopPublisher()
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
// module模块
|
|
||||||
w := module.Start()
|
|
||||||
w.Wait("main()")
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ type TienLenPlayerData struct {
|
||||||
curHandLimitTimeOut time.Duration // 出牌时间上限
|
curHandLimitTimeOut time.Duration // 出牌时间上限
|
||||||
isNotOverLastHand bool //手牌不能压过上家出牌标志
|
isNotOverLastHand bool //手牌不能压过上家出牌标志
|
||||||
cardScore int // 手牌评分
|
cardScore int // 手牌评分
|
||||||
playerPool int // 个人水池分
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *TienLenPlayerData) init() {
|
func (this *TienLenPlayerData) init() {
|
||||||
|
|
@ -50,7 +49,6 @@ func (this *TienLenPlayerData) init() {
|
||||||
this.curHandLimitTimeOut = rule.TienLenPlayerOpTimeout
|
this.curHandLimitTimeOut = rule.TienLenPlayerOpTimeout
|
||||||
this.isNotOverLastHand = false
|
this.isNotOverLastHand = false
|
||||||
this.cardScore = 0
|
this.cardScore = 0
|
||||||
this.playerPool = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *TienLenPlayerData) Clear() {
|
func (this *TienLenPlayerData) Clear() {
|
||||||
|
|
@ -69,7 +67,6 @@ func (this *TienLenPlayerData) Clear() {
|
||||||
this.ThinkLongCnt = 0
|
this.ThinkLongCnt = 0
|
||||||
this.curHandLimitTimeOut = rule.TienLenPlayerOpTimeout
|
this.curHandLimitTimeOut = rule.TienLenPlayerOpTimeout
|
||||||
this.isNotOverLastHand = false
|
this.isNotOverLastHand = false
|
||||||
this.playerPool = 0
|
|
||||||
|
|
||||||
this.MarkFlag(base.PlayerState_WaitNext)
|
this.MarkFlag(base.PlayerState_WaitNext)
|
||||||
this.TestLog = this.TestLog[:0]
|
this.TestLog = this.TestLog[:0]
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,6 @@ type TienLenSceneData struct {
|
||||||
cHintCards []int32 //客户端提示出牌记录
|
cHintCards []int32 //客户端提示出牌记录
|
||||||
isCardsKu bool //是否是牌库
|
isCardsKu bool //是否是牌库
|
||||||
cardsKuId int32 //牌库ID
|
cardsKuId int32 //牌库ID
|
||||||
ctrlType int // 1控赢 2控输 0不控
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTienLenSceneData(s *base.Scene) *TienLenSceneData {
|
func NewTienLenSceneData(s *base.Scene) *TienLenSceneData {
|
||||||
|
|
@ -86,7 +85,6 @@ func (this *TienLenSceneData) init() bool {
|
||||||
this.card_play_action_seq_int32 = [][]int32{}
|
this.card_play_action_seq_int32 = [][]int32{}
|
||||||
this.bombToEnd = 0
|
this.bombToEnd = 0
|
||||||
this.allPlayerCards = [][]int32{}
|
this.allPlayerCards = [][]int32{}
|
||||||
this.ctrlType = 0
|
|
||||||
this.recordId, _ = model.AutoIncGameLogId()
|
this.recordId, _ = model.AutoIncGameLogId()
|
||||||
if this.GetPlayerNum() == 0 {
|
if this.GetPlayerNum() == 0 {
|
||||||
this.SetPlayerNum(rule.MaxNumOfPlayer)
|
this.SetPlayerNum(rule.MaxNumOfPlayer)
|
||||||
|
|
@ -116,7 +114,6 @@ func (this *TienLenSceneData) Clear() {
|
||||||
this.isAllRob = false
|
this.isAllRob = false
|
||||||
this.robotGamingNum = 0
|
this.robotGamingNum = 0
|
||||||
this.allPlayerCards = [][]int32{}
|
this.allPlayerCards = [][]int32{}
|
||||||
this.ctrlType = 0
|
|
||||||
this.recordId, _ = model.AutoIncGameLogId()
|
this.recordId, _ = model.AutoIncGameLogId()
|
||||||
for _, player := range this.players {
|
for _, player := range this.players {
|
||||||
if player != nil {
|
if player != nil {
|
||||||
|
|
@ -1056,7 +1053,6 @@ func (this *TienLenSceneData) SendHandCardOdds() {
|
||||||
robotPlayers = append(robotPlayers, seat)
|
robotPlayers = append(robotPlayers, seat)
|
||||||
} else {
|
} else {
|
||||||
seat.odds = this.GetPlayerOdds(seat.Player, this.GameId, this.robotGamingNum > 0)
|
seat.odds = this.GetPlayerOdds(seat.Player, this.GameId, this.robotGamingNum > 0)
|
||||||
seat.playerPool = int(this.PlayerPoolOdds(seat.Player))
|
|
||||||
if seat.odds > 0 {
|
if seat.odds > 0 {
|
||||||
realPlayersGood = append(realPlayersGood, seat)
|
realPlayersGood = append(realPlayersGood, seat)
|
||||||
G += seat.odds
|
G += seat.odds
|
||||||
|
|
@ -1110,89 +1106,88 @@ func (this *TienLenSceneData) SendHandCardOdds() {
|
||||||
// 前两局不能天胡,之后根据概率给一次天胡,至少天胡一次
|
// 前两局不能天胡,之后根据概率给一次天胡,至少天胡一次
|
||||||
noviceTianHu := false
|
noviceTianHu := false
|
||||||
noviceCtrl := false
|
noviceCtrl := false
|
||||||
//config := srvdata.PBDB_NewPlayerMgr.GetData(int32(this.GameId))
|
config := srvdata.PBDB_NewPlayerMgr.GetData(int32(this.GameId))
|
||||||
//if config != nil && config.GetTianHuRate() > 0 && len(this.testPokers) == 0 { // 启用新手天胡体验
|
if config != nil && config.GetTianHuRate() > 0 && len(this.testPokers) == 0 { // 启用新手天胡体验
|
||||||
// rand.Shuffle(len(novicePlayers), func(i, j int) {
|
rand.Shuffle(len(novicePlayers), func(i, j int) {
|
||||||
// novicePlayers[i], novicePlayers[j] = novicePlayers[j], novicePlayers[i]
|
novicePlayers[i], novicePlayers[j] = novicePlayers[j], novicePlayers[i]
|
||||||
// })
|
})
|
||||||
// keyNovice := common.GetKeyNoviceGameId(this.GameId)
|
keyNovice := common.GetKeyNoviceGameId(this.GameId)
|
||||||
// for _, v := range novicePlayers {
|
for _, v := range novicePlayers {
|
||||||
// data, ok := v.GDatas[keyNovice]
|
data, ok := v.GDatas[keyNovice]
|
||||||
// if !ok {
|
if !ok {
|
||||||
// data = &model.PlayerGameInfo{FirstTime: time.Now()}
|
data = &model.PlayerGameInfo{FirstTime: time.Now()}
|
||||||
// v.GDatas[keyNovice] = data
|
v.GDatas[keyNovice] = data
|
||||||
// }
|
}
|
||||||
// // 前两局不能天胡
|
// 前两局不能天胡
|
||||||
// if data.Statics.GameTimes < 2 {
|
if data.Statics.GameTimes < 2 {
|
||||||
// continue
|
continue
|
||||||
// }
|
}
|
||||||
// if int(config.GetTianHuRate()) > this.RandInt(1000) {
|
if int(config.GetTianHuRate()) > this.RandInt(1000) {
|
||||||
// var allcs []int32
|
var allcs []int32
|
||||||
// for i := 0; i < 52; i++ {
|
for i := 0; i < 52; i++ {
|
||||||
// allcs = append(allcs, int32(i))
|
allcs = append(allcs, int32(i))
|
||||||
// }
|
}
|
||||||
// rand.Shuffle(len(allcs), func(i, j int) {
|
rand.Shuffle(len(allcs), func(i, j int) {
|
||||||
// allcs[i], allcs[j] = allcs[j], allcs[i]
|
allcs[i], allcs[j] = allcs[j], allcs[i]
|
||||||
// })
|
})
|
||||||
// cs, _ := rule.GetTianHu()
|
cs, _ := rule.GetTianHu()
|
||||||
// allcs = common.DelSliceIn32s(allcs, cs)
|
allcs = common.DelSliceIn32s(allcs, cs)
|
||||||
// for _, seat := range this.seats {
|
for _, seat := range this.seats {
|
||||||
// if seat != nil && seat.IsGameing() {
|
if seat != nil && seat.IsGameing() {
|
||||||
// if seat != v {
|
if seat != v {
|
||||||
// f1(seat, allcs[:13])
|
f1(seat, allcs[:13])
|
||||||
// allcs = allcs[13:]
|
allcs = allcs[13:]
|
||||||
// } else {
|
} else {
|
||||||
// f1(seat, cs)
|
f1(seat, cs)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// v.TestLog = append(v.TestLog, fmt.Sprintf("新手天胡体验,玩家:%d 发天胡 num:%v", v.SnId, data.Statics.GameTimes))
|
v.TestLog = append(v.TestLog, fmt.Sprintf("新手天胡体验,玩家:%d 发天胡 num:%v", v.SnId, data.Statics.GameTimes))
|
||||||
// logger.Logger.Tracef("新手天胡体验,玩家:%d 发天胡", v.SnId)
|
logger.Logger.Tracef("新手天胡体验,玩家:%d 发天胡", v.SnId)
|
||||||
// noviceTianHu = true
|
noviceTianHu = true
|
||||||
// noviceCtrl = true
|
noviceCtrl = true
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// if !noviceTianHu {
|
if !noviceTianHu {
|
||||||
// // 没有新手玩家天胡,随机一个非新手玩家,如果没有天胡过,给一次天胡
|
// 没有新手玩家天胡,随机一个非新手玩家,如果没有天胡过,给一次天胡
|
||||||
// rand.Shuffle(len(notNoviceRealPlayers), func(i, j int) {
|
rand.Shuffle(len(notNoviceRealPlayers), func(i, j int) {
|
||||||
// notNoviceRealPlayers[i], notNoviceRealPlayers[j] = notNoviceRealPlayers[j], notNoviceRealPlayers[i]
|
notNoviceRealPlayers[i], notNoviceRealPlayers[j] = notNoviceRealPlayers[j], notNoviceRealPlayers[i]
|
||||||
// })
|
})
|
||||||
// for _, v := range notNoviceRealPlayers {
|
for _, v := range notNoviceRealPlayers {
|
||||||
// data, ok := v.GDatas[keyNovice]
|
data, ok := v.GDatas[keyNovice]
|
||||||
// if !ok {
|
if !ok {
|
||||||
// data = &model.PlayerGameInfo{FirstTime: time.Now()}
|
data = &model.PlayerGameInfo{FirstTime: time.Now()}
|
||||||
// v.GDatas[keyNovice] = data
|
v.GDatas[keyNovice] = data
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if data.Statics.GetInt(rule.StaticsTianHuTimes) == 0 {
|
if data.Statics.GetInt(rule.StaticsTianHuTimes) == 0 {
|
||||||
// var allcs []int32
|
var allcs []int32
|
||||||
// for i := 0; i < 52; i++ {
|
for i := 0; i < 52; i++ {
|
||||||
// allcs = append(allcs, int32(i))
|
allcs = append(allcs, int32(i))
|
||||||
// }
|
}
|
||||||
// rand.Shuffle(len(allcs), func(i, j int) {
|
rand.Shuffle(len(allcs), func(i, j int) {
|
||||||
// allcs[i], allcs[j] = allcs[j], allcs[i]
|
allcs[i], allcs[j] = allcs[j], allcs[i]
|
||||||
// })
|
})
|
||||||
// cs, _ := rule.GetTianHu()
|
cs, _ := rule.GetTianHu()
|
||||||
// allcs = common.DelSliceIn32s(allcs, cs)
|
allcs = common.DelSliceIn32s(allcs, cs)
|
||||||
// for _, seat := range this.seats {
|
for _, seat := range this.seats {
|
||||||
// if seat != nil && seat.IsGameing() {
|
if seat != nil && seat.IsGameing() {
|
||||||
// if seat != v {
|
if seat != v {
|
||||||
// f1(seat, allcs[:13])
|
f1(seat, allcs[:13])
|
||||||
// allcs = allcs[13:]
|
allcs = allcs[13:]
|
||||||
// } else {
|
} else {
|
||||||
// f1(seat, cs)
|
f1(seat, cs)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// v.TestLog = append(v.TestLog, fmt.Sprintf("新手阶段没有天胡过,玩家:%d 发天胡 num:%v", v.SnId, data.Statics.GameTimes))
|
v.TestLog = append(v.TestLog, fmt.Sprintf("新手阶段没有天胡过,玩家:%d 发天胡 num:%v", v.SnId, data.Statics.GameTimes))
|
||||||
// logger.Logger.Tracef("新手阶段没有天胡过,玩家:%v 发天胡", v.SnId)
|
logger.Logger.Tracef("新手阶段没有天胡过,玩家:%v 发天胡", v.SnId)
|
||||||
// noviceCtrl = true
|
noviceCtrl = true
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
// 全局配置
|
|
||||||
gameConfig := base.ConfigMgrInst.GetConfig(this.Platform).GameConfig
|
gameConfig := base.ConfigMgrInst.GetConfig(this.Platform).GameConfig
|
||||||
|
|
||||||
// testPokers 用于测试
|
// testPokers 用于测试
|
||||||
|
|
@ -1237,7 +1232,6 @@ func (this *TienLenSceneData) SendHandCardOdds() {
|
||||||
logger.Logger.Tracef("TienLen SendHandCardOdds Good:%v G:%v Bad:%v B:%v", isGood, G, isBad, B)
|
logger.Logger.Tracef("TienLen SendHandCardOdds Good:%v G:%v Bad:%v B:%v", isGood, G, isBad, B)
|
||||||
|
|
||||||
if isBad && !isTestPoker && len(robotPlayers) > 0 && !noviceCtrl && !noviceTianHu {
|
if isBad && !isTestPoker && len(robotPlayers) > 0 && !noviceCtrl && !noviceTianHu {
|
||||||
this.ctrlType = 2
|
|
||||||
gf := base.ConfigMgrInst.GetConfig(this.Platform).GameConfig
|
gf := base.ConfigMgrInst.GetConfig(this.Platform).GameConfig
|
||||||
items := []int32{gf.GetTianHu(), gf.GetPaiKu(), gf.GetFenCha()}
|
items := []int32{gf.GetTianHu(), gf.GetPaiKu(), gf.GetFenCha()}
|
||||||
score := this.RandInt(int(gf.GetTianHu() + gf.GetPaiKu() + gf.GetFenCha()))
|
score := this.RandInt(int(gf.GetTianHu() + gf.GetPaiKu() + gf.GetFenCha()))
|
||||||
|
|
@ -1500,8 +1494,7 @@ func (this *TienLenSceneData) SendHandCardOdds() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isBad && !isTestPoker && !noviceCtrl && !noviceTianHu { // 天胡调控没有生效
|
if !isBad && !isTestPoker && !noviceCtrl && !noviceTianHu { // 天胡调控没有生效
|
||||||
if isGood {
|
if isGood || isBad {
|
||||||
this.ctrlType = 1
|
|
||||||
// 牌平分,按从大到小排序
|
// 牌平分,按从大到小排序
|
||||||
// 使用分差配置,最好牌和最差牌的牌型分差大于分差配置
|
// 使用分差配置,最好牌和最差牌的牌型分差大于分差配置
|
||||||
for i := 0; i < 20; i++ { // 尝试20次,如果还不能满足分差配置,则直接发牌
|
for i := 0; i < 20; i++ { // 尝试20次,如果还不能满足分差配置,则直接发牌
|
||||||
|
|
|
||||||
|
|
@ -1606,13 +1606,6 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
|
||||||
BaseScore: s.GetBaseScore(),
|
BaseScore: s.GetBaseScore(),
|
||||||
TaxRate: s.DbGameFree.GetTaxRate(),
|
TaxRate: s.DbGameFree.GetTaxRate(),
|
||||||
RoomMode: s.GetSceneMode(),
|
RoomMode: s.GetSceneMode(),
|
||||||
PlayerPool: make(map[int]int),
|
|
||||||
}
|
|
||||||
for _, v := range sceneEx.seats {
|
|
||||||
if v == nil || !v.IsGameing() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
tienlenType.PlayerPool[int(v.SnId)] = v.playerPool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nGamingPlayerCount := sceneEx.GetGameingPlayerCnt()
|
nGamingPlayerCount := sceneEx.GetGameingPlayerCnt()
|
||||||
|
|
@ -2506,11 +2499,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
|
||||||
}
|
}
|
||||||
if isSave {
|
if isSave {
|
||||||
// 牌局记录
|
// 牌局记录
|
||||||
sceneEx.SaveGameDetailedLog(sceneEx.recordId, info, &base.GameDetailedParam{
|
sceneEx.SaveGameDetailedLog(sceneEx.recordId, info, &base.GameDetailedParam{})
|
||||||
Trend20Lately: "",
|
|
||||||
CtrlType: sceneEx.ctrlType,
|
|
||||||
PlayerPool: tienlenType.PlayerPool,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,10 @@ package main
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"mongo.games.com/goserver/core"
|
||||||
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
|
|
||||||
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/mq"
|
"mongo.games.com/game/mq"
|
||||||
)
|
)
|
||||||
|
|
@ -38,9 +42,33 @@ func (c *LogChannel) WriteLog(log interface{}) {
|
||||||
if cname == "" {
|
if cname == "" {
|
||||||
cname = "_null_"
|
cname = "_null_"
|
||||||
}
|
}
|
||||||
mq.Send(cname, log)
|
RabbitMQPublisher.Send(cname, log)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *LogChannel) WriteMQData(data *model.RabbitMQData) {
|
func (c *LogChannel) WriteMQData(data *model.RabbitMQData) {
|
||||||
mq.Send(data.MQName, data.Data)
|
RabbitMQPublisher.Send(data.MQName, data.Data)
|
||||||
|
}
|
||||||
|
|
||||||
|
var RabbitMQPublisher *mq.RabbitMQPublisher
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
||||||
|
//rabbitmq打开链接
|
||||||
|
RabbitMQPublisher = mq.NewRabbitMQPublisher(common.CustomConfig.GetString("RabbitMQURL"), rabbitmq.Exchange{Name: common.CustomConfig.GetString("RMQExchange"), Durable: true}, common.CustomConfig.GetInt("RMQPublishBacklog"))
|
||||||
|
if RabbitMQPublisher != nil {
|
||||||
|
err := RabbitMQPublisher.Start()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
||||||
|
//关闭rabbitmq连接
|
||||||
|
if RabbitMQPublisher != nil {
|
||||||
|
RabbitMQPublisher.Stop()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,21 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"mongo.games.com/goserver/core"
|
|
||||||
"mongo.games.com/goserver/core/module"
|
|
||||||
|
|
||||||
_ "mongo.games.com/game"
|
_ "mongo.games.com/game"
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/mq"
|
|
||||||
|
"mongo.games.com/goserver/core"
|
||||||
|
"mongo.games.com/goserver/core/module"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// 自定义配置文件
|
core.RegisterConfigEncryptor(common.ConfigFE)
|
||||||
model.InitGameParam()
|
|
||||||
// package模块
|
|
||||||
defer core.ClosePackages()
|
defer core.ClosePackages()
|
||||||
core.LoadPackages("config.json")
|
core.LoadPackages("config.json")
|
||||||
// core hook
|
|
||||||
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
model.InitGameParam()
|
||||||
mq.StartPublisher(common.CustomConfig.GetString("RabbitMQURL"), common.CustomConfig.GetString("RMQExchange"), true, common.CustomConfig.GetInt("RMQPublishBacklog"))
|
|
||||||
return nil
|
waiter := module.Start()
|
||||||
})
|
waiter.Wait("main()")
|
||||||
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
|
||||||
mq.StopPublisher()
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
// module模块
|
|
||||||
w := module.Start()
|
|
||||||
w.Wait("main()")
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,11 @@ package api
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/mq"
|
"mongo.games.com/game/mq"
|
||||||
|
"mongo.games.com/goserver/core"
|
||||||
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -12,9 +15,11 @@ import (
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LogChanelBlackHole = "_null_"
|
LOGCHANEL_BLACKHOLE = "_null_"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var RabbitMQPublisher *mq.RabbitMQPublisher
|
||||||
|
|
||||||
var LogChannelSington = &LogChannel{
|
var LogChannelSington = &LogChannel{
|
||||||
cName: make(map[reflect.Type]string),
|
cName: make(map[reflect.Type]string),
|
||||||
}
|
}
|
||||||
|
|
@ -43,15 +48,36 @@ func (c *LogChannel) getLogCName(log interface{}) string {
|
||||||
func (c *LogChannel) WriteLog(log interface{}) {
|
func (c *LogChannel) WriteLog(log interface{}) {
|
||||||
cname := c.getLogCName(log)
|
cname := c.getLogCName(log)
|
||||||
if cname == "" {
|
if cname == "" {
|
||||||
cname = LogChanelBlackHole
|
cname = LOGCHANEL_BLACKHOLE
|
||||||
}
|
}
|
||||||
mq.Send(cname, log)
|
RabbitMQPublisher.Send(cname, log)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *LogChannel) WriteMQData(data *model.RabbitMQData) {
|
func (c *LogChannel) WriteMQData(data *model.RabbitMQData) {
|
||||||
mq.Send(data.MQName, data.Data)
|
RabbitMQPublisher.Send(data.MQName, data.Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
LogChannelSington.RegisteLogCName(model.APILogCollName, &model.APILog{})
|
LogChannelSington.RegisteLogCName(model.APILogCollName, &model.APILog{})
|
||||||
|
|
||||||
|
//首先加载游戏配置
|
||||||
|
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
||||||
|
//rabbitmq打开链接
|
||||||
|
RabbitMQPublisher = mq.NewRabbitMQPublisher(common.CustomConfig.GetString("RabbitMQURL"), rabbitmq.Exchange{Name: common.CustomConfig.GetString("RMQExchange"), Durable: true}, common.CustomConfig.GetInt("RMQPublishBacklog"))
|
||||||
|
if RabbitMQPublisher != nil {
|
||||||
|
err := RabbitMQPublisher.Start()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
||||||
|
//关闭rabbitmq连接
|
||||||
|
if RabbitMQPublisher != nil {
|
||||||
|
RabbitMQPublisher.Stop()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,203 @@
|
||||||
|
package api
|
||||||
|
|
||||||
|
//
|
||||||
|
//import (
|
||||||
|
// "encoding/json"
|
||||||
|
// "io/ioutil"
|
||||||
|
// "net/http"
|
||||||
|
// "time"
|
||||||
|
//
|
||||||
|
// "crypto/md5"
|
||||||
|
// "encoding/hex"
|
||||||
|
// "fmt"
|
||||||
|
// "mongo.games.com/game/common"
|
||||||
|
// "mongo.games.com/game/model"
|
||||||
|
// "mongo.games.com/game/webapi"
|
||||||
|
// "mongo.games.com/goserver/core"
|
||||||
|
// "mongo.games.com/goserver/core/admin"
|
||||||
|
// "mongo.games.com/goserver/core/logger"
|
||||||
|
// "mongo.games.com/goserver/core/netlib"
|
||||||
|
// "mongo.games.com/goserver/core/transact"
|
||||||
|
// "mongo.games.com/goserver/core/utils"
|
||||||
|
// "io"
|
||||||
|
// "sync/atomic"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//// API
|
||||||
|
//// http://127.0.0.1:9595/api/Report/QueryOnlineReportList?ts=20141024000000&sign=41cc8cee8dd93f7dc70b6426cfd1029d
|
||||||
|
//
|
||||||
|
//func ActThrSrvApi(rw http.ResponseWriter, req *http.Request) {
|
||||||
|
// defer utils.DumpStackIfPanic("api.ActThrSrvApi")
|
||||||
|
// logger.Logger.Info("ActThrSrvApi receive:", req.URL.Path, req.URL.RawQuery)
|
||||||
|
//
|
||||||
|
// if common.RequestCheck(req, model.GameParamData.WhiteHttpAddr) == false {
|
||||||
|
// logger.Logger.Info("RemoteAddr [%v] require api.", req.RemoteAddr)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// data, err := io.ReadAll(req.Body)
|
||||||
|
// if err != nil {
|
||||||
|
// logger.Logger.Info("Body err.", err)
|
||||||
|
// webApiResponse(rw, map[string]interface{}{webapi.RESPONSE_STATE: webapi.STATE_ERR, webapi.RESPONSE_ERRMSG: "Post data is null!"})
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// m := req.URL.Query()
|
||||||
|
// timestamp := m.Get("nano")
|
||||||
|
// if timestamp == "" {
|
||||||
|
// logger.Logger.Info(req.RemoteAddr, " ActThrSrvApi param error: nano not allow null")
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// sign := m.Get("sign")
|
||||||
|
// if sign == "" {
|
||||||
|
// logger.Logger.Info(req.RemoteAddr, " ActThrSrvApi param error: sign not allow null")
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// startTime := time.Now().UnixNano()
|
||||||
|
// args := fmt.Sprintf("%v;%v;%v;%v", common.Config.AppId, req.URL.Path, string(data), timestamp)
|
||||||
|
// h := md5.New()
|
||||||
|
// io.WriteString(h, args)
|
||||||
|
// realSign := hex.EncodeToString(h.Sum(nil))
|
||||||
|
// if realSign != sign && !common.Config.IsDevMode {
|
||||||
|
// logger.Logger.Info(req.RemoteAddr, " srvCtrlMain sign error: expect ", realSign, " ; but get ", sign, " raw=", args)
|
||||||
|
// webApiResponse(rw, map[string]interface{}{webapi.RESPONSE_STATE: webapi.STATE_ERR, webapi.RESPONSE_ERRMSG: "Sign error!"})
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// var stats *ApiStats
|
||||||
|
// if v, exist := WebApiStats.Load(req.URL.Path); exist {
|
||||||
|
// stats = v.(*ApiStats)
|
||||||
|
// } else {
|
||||||
|
// stats = &ApiStats{}
|
||||||
|
// WebApiStats.Store(req.URL.Path, stats)
|
||||||
|
// }
|
||||||
|
// var rep map[string]interface{}
|
||||||
|
// start := time.Now()
|
||||||
|
// res := make(chan map[string]interface{}, 1)
|
||||||
|
// core.CoreObject().SendCommand(&WebApiEvent{req: req, path: req.URL.Path, h: HandlerWrapper(func(event *WebApiEvent, data []byte) bool {
|
||||||
|
// logger.Logger.Trace("ActThrSrvApi start transcate")
|
||||||
|
// tnp := &transact.TransNodeParam{
|
||||||
|
// Tt: common.TransType_ActThrSrvWebApi,
|
||||||
|
// Ot: transact.TransOwnerType(common.GetSelfSrvType()),
|
||||||
|
// Oid: common.GetSelfSrvId(),
|
||||||
|
// AreaID: common.GetSelfAreaId(),
|
||||||
|
// }
|
||||||
|
// tNode := transact.DTCModule.StartTrans(tnp, event, transact.DefaultTransactTimeout) //超时时间30秒
|
||||||
|
// if tNode != nil {
|
||||||
|
// tNode.TransEnv.SetField(WEBAPI_TRANSACTE_EVENT, event)
|
||||||
|
// tNode.Go(core.CoreObject())
|
||||||
|
// }
|
||||||
|
// return true
|
||||||
|
// }), body: data, rawQuery: req.URL.RawQuery, res: res}, false)
|
||||||
|
// select {
|
||||||
|
// case rep = <-res:
|
||||||
|
// if rep != nil {
|
||||||
|
// webApiResponse(rw, rep)
|
||||||
|
// }
|
||||||
|
// case <-time.After(ApiDefaultTimeout):
|
||||||
|
// rep = make(map[string]interface{})
|
||||||
|
// rep[webapi.RESPONSE_STATE] = webapi.STATE_ERR
|
||||||
|
// rep[webapi.RESPONSE_ERRMSG] = "proccess timeout!"
|
||||||
|
// webApiResponse(rw, rep)
|
||||||
|
// if stats != nil {
|
||||||
|
// atomic.AddInt64(&stats.TimeoutTimes, 1)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// ps := int64(time.Now().Sub(start) / time.Millisecond)
|
||||||
|
// if stats != nil {
|
||||||
|
// atomic.AddInt64(&stats.RunTimes, 1)
|
||||||
|
// atomic.AddInt64(&stats.TotalRuningTime, ps)
|
||||||
|
// if atomic.LoadInt64(&stats.MaxRuningTime) < ps {
|
||||||
|
// atomic.StoreInt64(&stats.MaxRuningTime, ps)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// result, err := json.Marshal(rep)
|
||||||
|
// if err == nil {
|
||||||
|
// log := model.NewAPILog(req.URL.Path, req.URL.RawQuery, string(data[:]), req.RemoteAddr, string(result[:]), startTime, ps)
|
||||||
|
// APILogChannelSington.Write(log)
|
||||||
|
// }
|
||||||
|
// return
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
////--------------------------------------------------------------------------------------
|
||||||
|
//func init() {
|
||||||
|
// transact.RegisteHandler(common.TransType_ActThrSrvWebApi, &transact.TransHanderWrapper{
|
||||||
|
// OnExecuteWrapper: transact.OnExecuteWrapper(func(tNode *transact.TransNode, ud interface{}) transact.TransExeResult {
|
||||||
|
// logger.Logger.Trace("ActThrSrvApi start TransType_WebApi OnExecuteWrapper ")
|
||||||
|
// tnp := &transact.TransNodeParam{
|
||||||
|
// Tt: common.TransType_ActThrSrvWebApi,
|
||||||
|
// Ot: transact.TransOwnerType(common.ActThrServerType),
|
||||||
|
// Oid: common.ActThrServerID,
|
||||||
|
// AreaID: common.GetSelfAreaId(),
|
||||||
|
// Tct: transact.TransactCommitPolicy_TwoPhase,
|
||||||
|
// }
|
||||||
|
// if event, ok := ud.(*WebApiEvent); ok {
|
||||||
|
// userData := &common.M2GWebApiRequest{Path: event.path, RawQuery: event.rawQuery, Body: event.body, ReqIp: event.req.RemoteAddr}
|
||||||
|
// tNode.StartChildTrans(tnp, userData, transact.DefaultTransactTimeout)
|
||||||
|
//
|
||||||
|
// pid := tNode.MyTnp.TId
|
||||||
|
// cid := tnp.TId
|
||||||
|
// logger.Logger.Tracef("ActThrSrvApi start TransType_WebApi OnExecuteWrapper tid:%x childid:%x", pid, cid)
|
||||||
|
// return transact.TransExeResult_Success
|
||||||
|
// }
|
||||||
|
// return transact.TransExeResult_Failed
|
||||||
|
// }),
|
||||||
|
// OnCommitWrapper: transact.OnCommitWrapper(func(tNode *transact.TransNode) transact.TransExeResult {
|
||||||
|
// logger.Logger.Trace("ActThrSrvApi start TransType_WebApi OnCommitWrapper")
|
||||||
|
// event := tNode.TransEnv.GetField(WEBAPI_TRANSACTE_EVENT).(*WebApiEvent)
|
||||||
|
// resp := tNode.TransEnv.GetField(WEBAPI_TRANSACTE_RESPONSE)
|
||||||
|
// if userData, ok := resp.(*common.M2GWebApiResponse); ok {
|
||||||
|
// if len(userData.Body) > 0 {
|
||||||
|
// m := make(map[string]interface{})
|
||||||
|
// err := json.Unmarshal(userData.Body, &m)
|
||||||
|
// if err == nil {
|
||||||
|
// event.Response(m)
|
||||||
|
// return transact.TransExeResult_Success
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// event.Response(map[string]interface{}{webapi.RESPONSE_STATE: webapi.STATE_ERR, webapi.RESPONSE_ERRMSG: "execute failed!"})
|
||||||
|
// return transact.TransExeResult_Success
|
||||||
|
// }),
|
||||||
|
// OnRollBackWrapper: transact.OnRollBackWrapper(func(tNode *transact.TransNode) transact.TransExeResult {
|
||||||
|
// logger.Logger.Trace("ActThrSrvApi start TransType_WebApi OnRollBackWrapper")
|
||||||
|
// event := tNode.TransEnv.GetField(WEBAPI_TRANSACTE_EVENT).(*WebApiEvent)
|
||||||
|
// resp := tNode.TransEnv.GetField(WEBAPI_TRANSACTE_RESPONSE)
|
||||||
|
// if userData, ok := resp.(*common.M2GWebApiResponse); ok {
|
||||||
|
// if len(userData.Body) > 0 {
|
||||||
|
// m := make(map[string]interface{})
|
||||||
|
// err := json.Unmarshal(userData.Body, &m)
|
||||||
|
// if err == nil {
|
||||||
|
// event.Response(m)
|
||||||
|
// return transact.TransExeResult_Success
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return transact.TransExeResult_Success
|
||||||
|
// }
|
||||||
|
// event.Response(map[string]interface{}{webapi.RESPONSE_STATE: webapi.STATE_ERR, webapi.RESPONSE_ERRMSG: "execute failed!"})
|
||||||
|
// return transact.TransExeResult_Success
|
||||||
|
// }),
|
||||||
|
// OnChildRespWrapper: transact.OnChildRespWrapper(func(tNode *transact.TransNode, hChild transact.TransNodeID, retCode int, ud interface{}) transact.TransExeResult {
|
||||||
|
// logger.Logger.Tracef("ActThrSrvApi start TransType_WebApi OnChildRespWrapper ret:%v childid:%x", retCode, hChild)
|
||||||
|
// userData := &common.M2GWebApiResponse{}
|
||||||
|
// err := netlib.UnmarshalPacketNoPackId(ud.([]byte), userData)
|
||||||
|
// if err == nil {
|
||||||
|
// tNode.TransEnv.SetField(WEBAPI_TRANSACTE_RESPONSE, userData)
|
||||||
|
// } else {
|
||||||
|
// logger.Logger.Trace("trascate.OnChildRespWrapper err:", err)
|
||||||
|
// }
|
||||||
|
// return transact.TransExeResult(retCode)
|
||||||
|
// }),
|
||||||
|
// })
|
||||||
|
//
|
||||||
|
// //测试
|
||||||
|
// admin.MyAdminApp.Route("/api/ActThr/Test", ActThrSrvApi)
|
||||||
|
//
|
||||||
|
// //增加自动黑白名单控制
|
||||||
|
// admin.MyAdminApp.Route("/api/ActThr/Upsert", ActThrSrvApi)
|
||||||
|
//
|
||||||
|
// //删除自动黑白名单控制
|
||||||
|
// admin.MyAdminApp.Route("/api/ActThr/Delete", ActThrSrvApi)
|
||||||
|
//
|
||||||
|
// //删除所有添加的黑名单
|
||||||
|
// admin.MyAdminApp.Route("/api/ActThr/ResetBW", ActThrSrvApi)
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
@ -0,0 +1,186 @@
|
||||||
|
package api
|
||||||
|
|
||||||
|
//
|
||||||
|
//import (
|
||||||
|
// "crypto/md5"
|
||||||
|
// "encoding/hex"
|
||||||
|
// "encoding/json"
|
||||||
|
// "fmt"
|
||||||
|
// "mongo.games.com/game/common"
|
||||||
|
// "mongo.games.com/game/model"
|
||||||
|
// "mongo.games.com/game/webapi"
|
||||||
|
// "mongo.games.com/goserver/core"
|
||||||
|
// "mongo.games.com/goserver/core/admin"
|
||||||
|
// "mongo.games.com/goserver/core/logger"
|
||||||
|
// "mongo.games.com/goserver/core/netlib"
|
||||||
|
// "mongo.games.com/goserver/core/transact"
|
||||||
|
// "mongo.games.com/goserver/core/utils"
|
||||||
|
// "io"
|
||||||
|
// "io/ioutil"
|
||||||
|
// "net/http"
|
||||||
|
// "time"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//const (
|
||||||
|
// RANKSRVAPI_TRANSACTE_EVENT = "GAMESRVAPI_TRANSACTE_EVENT"
|
||||||
|
// RANKSRVAPI_TRANSACTE_RESPONSE = "RANKSRVAPI_TRANSACTE_RESPONSE"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//// 处理 web 请求 rank server 相关的配置协议, 转发至 rank server 处理
|
||||||
|
//
|
||||||
|
//func RankSrvApi(rw http.ResponseWriter, req *http.Request) {
|
||||||
|
// defer utils.DumpStackIfPanic("api.RankSrvApi")
|
||||||
|
// logger.Logger.Info("RankSrvApi receive:", req.URL.Path, req.URL.RawQuery)
|
||||||
|
//
|
||||||
|
// if common.RequestCheck(req, model.GameParamData.WhiteHttpAddr) == false {
|
||||||
|
// logger.Logger.Info("RemoteAddr [%v] require api.", req.RemoteAddr)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// data, err := io.ReadAll(req.Body)
|
||||||
|
// if err != nil {
|
||||||
|
// logger.Logger.Info("Body err.", err)
|
||||||
|
// webApiResponse(rw, map[string]interface{}{
|
||||||
|
// webapi.RESPONSE_STATE: webapi.STATE_ERR,
|
||||||
|
// webapi.RESPONSE_ERRMSG: "Post data is null!",
|
||||||
|
// })
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// logger.Logger.Info(string(data))
|
||||||
|
// m := req.URL.Query()
|
||||||
|
// timestamp := m.Get("nano")
|
||||||
|
// if timestamp == "" {
|
||||||
|
// logger.Logger.Info(req.RemoteAddr, " RankSrvApi param error: nano not allow null")
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// sign := m.Get("sign")
|
||||||
|
// if sign == "" {
|
||||||
|
// logger.Logger.Info(req.RemoteAddr, " RankSrvApi param error: sign not allow null")
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// startTime := time.Now().UnixNano()
|
||||||
|
// args := fmt.Sprintf("%v;%v;%v;%v", common.Config.AppId, req.URL.Path, string(data), timestamp)
|
||||||
|
// h := md5.New()
|
||||||
|
// io.WriteString(h, args)
|
||||||
|
// realSign := hex.EncodeToString(h.Sum(nil))
|
||||||
|
// if realSign != sign && !common.Config.IsDevMode {
|
||||||
|
// logger.Logger.Info(req.RemoteAddr, " srvCtrlMain sign error: expect ", realSign, " ; but get ", sign, " raw=", args)
|
||||||
|
// webApiResponse(rw, map[string]interface{}{webapi.RESPONSE_STATE: webapi.STATE_ERR, webapi.RESPONSE_ERRMSG: "Sign error!"})
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// var rep map[string]interface{}
|
||||||
|
// start := time.Now()
|
||||||
|
// res := make(chan map[string]interface{}, 1)
|
||||||
|
// core.CoreObject().SendCommand(&WebApiEvent{req: req, path: req.URL.Path, h: HandlerWrapper(func(event *WebApiEvent, data []byte) bool {
|
||||||
|
// logger.Logger.Trace("RankSrvApi start transcate")
|
||||||
|
// tnp := &transact.TransNodeParam{
|
||||||
|
// Tt: common.TransType_WebApi_ForRank,
|
||||||
|
// Ot: transact.TransOwnerType(common.GetSelfSrvType()),
|
||||||
|
// Oid: common.GetSelfSrvId(),
|
||||||
|
// AreaID: common.GetSelfAreaId(),
|
||||||
|
// }
|
||||||
|
// logger.Info("call info:", common.GetSelfAreaId(), common.GetSelfSrvType(), common.GetSelfSrvId())
|
||||||
|
// tNode := transact.DTCModule.StartTrans(tnp, event, transact.DefaultTransactTimeout) //超时时间30秒
|
||||||
|
// if tNode != nil {
|
||||||
|
// tNode.TransEnv.SetField(RANKSRVAPI_TRANSACTE_EVENT, event)
|
||||||
|
// tNode.Go(core.CoreObject())
|
||||||
|
// }
|
||||||
|
// return true
|
||||||
|
// }), body: data, rawQuery: req.URL.RawQuery, res: res}, false)
|
||||||
|
// select {
|
||||||
|
// case rep = <-res:
|
||||||
|
// if rep != nil {
|
||||||
|
// webApiResponse(rw, rep)
|
||||||
|
// }
|
||||||
|
// case <-time.After(ApiDefaultTimeout):
|
||||||
|
// rep = make(map[string]interface{})
|
||||||
|
// rep[webapi.RESPONSE_STATE] = webapi.STATE_ERR
|
||||||
|
// rep[webapi.RESPONSE_ERRMSG] = "proccess timeout!"
|
||||||
|
// webApiResponse(rw, rep)
|
||||||
|
// }
|
||||||
|
// ps := int64(time.Now().Sub(start) / time.Millisecond)
|
||||||
|
// result, err := json.Marshal(rep)
|
||||||
|
// if err == nil {
|
||||||
|
// log := model.NewAPILog(req.URL.Path, req.URL.RawQuery, string(data[:]), req.RemoteAddr, string(result[:]), startTime, ps)
|
||||||
|
// APILogChannelSington.Write(log)
|
||||||
|
// }
|
||||||
|
// return
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func init() {
|
||||||
|
// transact.RegisteHandler(common.TransType_WebApi_ForRank, &transact.TransHanderWrapper{
|
||||||
|
// OnExecuteWrapper: transact.OnExecuteWrapper(func(tNode *transact.TransNode, ud interface{}) transact.TransExeResult {
|
||||||
|
// logger.Logger.Trace("RankSrvApi start TransType_WebApi_ForRank OnExecuteWrapper ")
|
||||||
|
// tnp := &transact.TransNodeParam{
|
||||||
|
// Tt: common.TransType_WebApi_ForRank,
|
||||||
|
// Ot: transact.TransOwnerType(common.RankServerType),
|
||||||
|
// Oid: common.GetRankSrvId(),
|
||||||
|
// AreaID: common.GetSelfAreaId(),
|
||||||
|
// Tct: transact.TransactCommitPolicy_TwoPhase,
|
||||||
|
// }
|
||||||
|
// logger.Infof("params: %+v", tnp)
|
||||||
|
// if event, ok := ud.(*WebApiEvent); ok {
|
||||||
|
// userData := &common.M2GWebApiRequest{Path: event.path, RawQuery: event.rawQuery, Body: event.body, ReqIp: event.req.RemoteAddr}
|
||||||
|
// tNode.StartChildTrans(tnp, userData, transact.DefaultTransactTimeout)
|
||||||
|
//
|
||||||
|
// pid := tNode.MyTnp.TId
|
||||||
|
// cid := tnp.TId
|
||||||
|
// logger.Logger.Tracef("RankSrvApi start TransType_WebApi_ForRank OnExecuteWrapper tid:%x childid:%x", pid, cid)
|
||||||
|
// return transact.TransExeResult_Success
|
||||||
|
// }
|
||||||
|
// return transact.TransExeResult_Failed
|
||||||
|
// }),
|
||||||
|
// OnCommitWrapper: transact.OnCommitWrapper(func(tNode *transact.TransNode) transact.TransExeResult {
|
||||||
|
// logger.Logger.Trace("RankSrvApi start TransType_WebApi_ForRank OnCommitWrapper")
|
||||||
|
// event := tNode.TransEnv.GetField(RANKSRVAPI_TRANSACTE_EVENT).(*WebApiEvent)
|
||||||
|
// resp := tNode.TransEnv.GetField(RANKSRVAPI_TRANSACTE_RESPONSE)
|
||||||
|
// if userData, ok := resp.(*common.M2GWebApiResponse); ok {
|
||||||
|
// if len(userData.Body) > 0 {
|
||||||
|
// m := make(map[string]interface{})
|
||||||
|
// err := json.Unmarshal(userData.Body, &m)
|
||||||
|
// if err == nil {
|
||||||
|
// event.Response(m)
|
||||||
|
// return transact.TransExeResult_Success
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// event.Response(map[string]interface{}{webapi.RESPONSE_STATE: webapi.STATE_ERR, webapi.RESPONSE_ERRMSG: "execute failed!"})
|
||||||
|
// return transact.TransExeResult_Success
|
||||||
|
// }),
|
||||||
|
// OnRollBackWrapper: transact.OnRollBackWrapper(func(tNode *transact.TransNode) transact.TransExeResult {
|
||||||
|
// logger.Logger.Trace("RankSrvApi start TransType_WebApi_ForRank OnRollBackWrapper")
|
||||||
|
// event := tNode.TransEnv.GetField(RANKSRVAPI_TRANSACTE_EVENT).(*WebApiEvent)
|
||||||
|
// resp := tNode.TransEnv.GetField(RANKSRVAPI_TRANSACTE_RESPONSE)
|
||||||
|
// if userData, ok := resp.(*common.M2GWebApiResponse); ok {
|
||||||
|
// if len(userData.Body) > 0 {
|
||||||
|
// m := make(map[string]interface{})
|
||||||
|
// err := json.Unmarshal(userData.Body, &m)
|
||||||
|
// if err == nil {
|
||||||
|
// event.Response(m)
|
||||||
|
// return transact.TransExeResult_Success
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return transact.TransExeResult_Success
|
||||||
|
// }
|
||||||
|
// event.Response(map[string]interface{}{webapi.RESPONSE_STATE: webapi.STATE_ERR, webapi.RESPONSE_ERRMSG: "execute failed!"})
|
||||||
|
// return transact.TransExeResult_Success
|
||||||
|
// }),
|
||||||
|
// OnChildRespWrapper: transact.OnChildRespWrapper(func(tNode *transact.TransNode, hChild transact.TransNodeID, retCode int, ud interface{}) transact.TransExeResult {
|
||||||
|
// logger.Logger.Tracef("RankSrvApi start TransType_WebApi_ForRank OnChildRespWrapper ret:%v childid:%x", retCode, hChild)
|
||||||
|
// userData := &common.M2GWebApiResponse{}
|
||||||
|
// err := netlib.UnmarshalPacketNoPackId(ud.([]byte), userData)
|
||||||
|
// if err == nil {
|
||||||
|
// tNode.TransEnv.SetField(RANKSRVAPI_TRANSACTE_RESPONSE, userData)
|
||||||
|
// } else {
|
||||||
|
// logger.Logger.Trace("trascate.OnChildRespWrapper err:", err)
|
||||||
|
// }
|
||||||
|
// return transact.TransExeResult(retCode)
|
||||||
|
// }),
|
||||||
|
// }) //RegisteHandler
|
||||||
|
//
|
||||||
|
// admin.MyAdminApp.Route("/api/rank/getConfig", RankSrvApi)
|
||||||
|
// admin.MyAdminApp.Route("/api/rank/updateConfig", RankSrvApi)
|
||||||
|
// admin.MyAdminApp.Route("/api/rank/debug/settings", RankSrvApi)
|
||||||
|
// admin.MyAdminApp.Route("/api/rank/debug/board", RankSrvApi)
|
||||||
|
// admin.MyAdminApp.Route("/api/rank/reset", RankSrvApi)
|
||||||
|
// admin.MyAdminApp.Route("/api/rank/syncUser", RankSrvApi) // 同步主库玩家信息
|
||||||
|
//}
|
||||||
|
|
@ -83,12 +83,6 @@
|
||||||
"SupportAdmin": true,
|
"SupportAdmin": true,
|
||||||
"AdminHttpPort": 9899
|
"AdminHttpPort": 9899
|
||||||
},
|
},
|
||||||
"etcd": {
|
|
||||||
"Url": ["127.0.0.1:2379"],
|
|
||||||
"UserName": "",
|
|
||||||
"Password": "",
|
|
||||||
"DialTimeout": 60
|
|
||||||
},
|
|
||||||
"costum": {
|
"costum": {
|
||||||
"MgoRpcCliNet": "tcp",
|
"MgoRpcCliNet": "tcp",
|
||||||
"MgoRpcCliAddr": "127.0.0.1:8999",
|
"MgoRpcCliAddr": "127.0.0.1:8999",
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,39 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "mongo.games.com/game"
|
||||||
|
_ "mongo.games.com/game/mgrsrv/api"
|
||||||
|
_ "mongo.games.com/game/srvdata"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core"
|
|
||||||
"mongo.games.com/goserver/core/module"
|
|
||||||
|
|
||||||
_ "mongo.games.com/game"
|
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
_ "mongo.games.com/game/mgrsrv/api"
|
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/mq"
|
"mongo.games.com/game/srvdata"
|
||||||
_ "mongo.games.com/game/srvdata"
|
"mongo.games.com/goserver/core"
|
||||||
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
"mongo.games.com/goserver/core/module"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// 自定义配置文件
|
core.RegisterConfigEncryptor(common.ConfigFE)
|
||||||
model.InitGameParam()
|
|
||||||
// package模块
|
|
||||||
defer core.ClosePackages()
|
defer core.ClosePackages()
|
||||||
core.LoadPackages("config.json")
|
core.LoadPackages("config.json")
|
||||||
// core hook
|
|
||||||
|
model.InitGameParam()
|
||||||
|
logger.Logger.Warnf("log data %v", srvdata.Config.RootPath)
|
||||||
|
waiter := module.Start()
|
||||||
|
waiter.Wait("main()")
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
//首先加载游戏配置
|
||||||
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
||||||
model.StartupRPClient(common.CustomConfig.GetString("MgoRpcCliNet"), common.CustomConfig.GetString("MgoRpcCliAddr"), time.Duration(common.CustomConfig.GetInt("MgoRpcCliReconnInterV"))*time.Second)
|
model.StartupRPClient(common.CustomConfig.GetString("MgoRpcCliNet"), common.CustomConfig.GetString("MgoRpcCliAddr"), time.Duration(common.CustomConfig.GetInt("MgoRpcCliReconnInterV"))*time.Second)
|
||||||
mq.StartPublisher(common.CustomConfig.GetString("RabbitMQURL"), common.CustomConfig.GetString("RMQExchange"), true, common.CustomConfig.GetInt("RMQPublishBacklog"))
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
||||||
mq.StopPublisher()
|
|
||||||
model.ShutdownRPClient()
|
model.ShutdownRPClient()
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
// module模块
|
|
||||||
w := module.Start()
|
|
||||||
w.Wait("main()")
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,6 @@ type GameDetailedLog struct {
|
||||||
Time time.Time //记录时间
|
Time time.Time //记录时间
|
||||||
Trend20Lately string //最近游戏走势
|
Trend20Lately string //最近游戏走势
|
||||||
Ts int64 //时间戳
|
Ts int64 //时间戳
|
||||||
CtrlType int // 1控赢 2控输 0不控
|
|
||||||
PlayerPool map[int]int // 个人水池分
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGameDetailedLog() *GameDetailedLog {
|
func NewGameDetailedLog() *GameDetailedLog {
|
||||||
|
|
@ -65,7 +63,7 @@ func NewGameDetailedLog() *GameDetailedLog {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGameDetailedLogEx(logid string, gameid, sceneid, gamemode, gamefreeid, playercount, gametiming, gamebasebet int32,
|
func NewGameDetailedLogEx(logid string, gameid, sceneid, gamemode, gamefreeid, playercount, gametiming, gamebasebet int32,
|
||||||
gamedetailednote string, platform string, clubId int32, clubRoom string, cpCtx CoinPoolCtx, ver int32, trend20Lately string, ctrlType int, playerPool map[int]int) *GameDetailedLog {
|
gamedetailednote string, platform string, clubId int32, clubRoom string, cpCtx CoinPoolCtx, ver int32, trend20Lately string) *GameDetailedLog {
|
||||||
cl := NewGameDetailedLog()
|
cl := NewGameDetailedLog()
|
||||||
cl.LogId = logid
|
cl.LogId = logid
|
||||||
cl.GameId = gameid
|
cl.GameId = gameid
|
||||||
|
|
@ -85,8 +83,6 @@ func NewGameDetailedLogEx(logid string, gameid, sceneid, gamemode, gamefreeid, p
|
||||||
cl.GameDetailVer = ver
|
cl.GameDetailVer = ver
|
||||||
cl.Trend20Lately = trend20Lately
|
cl.Trend20Lately = trend20Lately
|
||||||
cl.Ts = time.Now().Unix()
|
cl.Ts = time.Now().Unix()
|
||||||
cl.CtrlType = ctrlType
|
|
||||||
cl.PlayerPool = playerPool
|
|
||||||
return cl
|
return cl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1521,8 +1521,6 @@ type TienLenType struct {
|
||||||
TaxRate int32 //税率(万分比)
|
TaxRate int32 //税率(万分比)
|
||||||
PlayerData []TienLenPerson //玩家信息
|
PlayerData []TienLenPerson //玩家信息
|
||||||
RoomMode int
|
RoomMode int
|
||||||
CtrlType int `json:"-"` // 1控赢 2控输 0不控
|
|
||||||
PlayerPool map[int]int `json:"-"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type TienLenAddItem struct {
|
type TienLenAddItem struct {
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,6 @@ type GameParam struct {
|
||||||
TestActSwitch bool // 开启所有活动开关
|
TestActSwitch bool // 开启所有活动开关
|
||||||
RankPlayerLevelMaxNum int //等级榜最大人数
|
RankPlayerLevelMaxNum int //等级榜最大人数
|
||||||
CloseChannelSwitch bool //关闭渠道开关功能
|
CloseChannelSwitch bool //关闭渠道开关功能
|
||||||
BackendTimeLocal int //后台时区
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var GameParamPath = "../data/gameparam.json"
|
var GameParamPath = "../data/gameparam.json"
|
||||||
|
|
@ -239,7 +238,4 @@ func InitGameParam() {
|
||||||
if GameParamData.RankPlayerLevelMaxNum == 0 {
|
if GameParamData.RankPlayerLevelMaxNum == 0 {
|
||||||
GameParamData.RankPlayerLevelMaxNum = 100
|
GameParamData.RankPlayerLevelMaxNum = 100
|
||||||
}
|
}
|
||||||
if GameParamData.BackendTimeLocal == 0 {
|
|
||||||
GameParamData.BackendTimeLocal = 8
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,11 +74,10 @@ type Message struct {
|
||||||
Params []int32 //额外参数
|
Params []int32 //额外参数
|
||||||
Platform string //平台信息
|
Platform string //平台信息
|
||||||
ShowId int64 //区分主子游戏大厅
|
ShowId int64 //区分主子游戏大厅
|
||||||
Channel []string //渠道
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMessage(pid string, srcId int32, srcName string, snid, mType int32, title, content string, coin, diamond int64,
|
func NewMessage(pid string, srcId int32, srcName string, snid, mType int32, title, content string, coin, diamond int64,
|
||||||
state int32, addTime int64, attachState int32, giftId string, params []int32, platform string, showId int64, channel []string) *Message {
|
state int32, addTime int64, attachState int32, giftId string, params []int32, platform string, showId int64) *Message {
|
||||||
if srcName == "" {
|
if srcName == "" {
|
||||||
srcName = "{\"zh\":\"系统\",\"vi\":\"GM\",\"en\":\"GM\",\"kh\":\"GM\"}"
|
srcName = "{\"zh\":\"系统\",\"vi\":\"GM\",\"en\":\"GM\",\"kh\":\"GM\"}"
|
||||||
}
|
}
|
||||||
|
|
@ -100,7 +99,6 @@ func NewMessage(pid string, srcId int32, srcName string, snid, mType int32, titl
|
||||||
Platform: platform,
|
Platform: platform,
|
||||||
Diamond: diamond,
|
Diamond: diamond,
|
||||||
ShowId: showId,
|
ShowId: showId,
|
||||||
Channel: channel,
|
|
||||||
}
|
}
|
||||||
if msg.Pid == "" {
|
if msg.Pid == "" {
|
||||||
msg.Pid = msg.Id.Hex()
|
msg.Pid = msg.Id.Hex()
|
||||||
|
|
|
||||||
|
|
@ -359,7 +359,7 @@ type PlayerData struct {
|
||||||
Coin int64 //金豆
|
Coin int64 //金豆
|
||||||
CoinPayTs int64 //金豆冲账时间戳
|
CoinPayTs int64 //金豆冲账时间戳
|
||||||
CoinPayTotal int64 //在线总充值金额
|
CoinPayTotal int64 //在线总充值金额
|
||||||
MoneyPayTotal int64 //VIP经验值,注意这里是没有乘充V比之前的值
|
MoneyPayTotal int64 //在线总充值金额(实充)
|
||||||
CoinExchangeTotal int64 //总提现金额 兑换
|
CoinExchangeTotal int64 //总提现金额 兑换
|
||||||
SafeBoxCoin int64 //保险箱金币
|
SafeBoxCoin int64 //保险箱金币
|
||||||
SafeBoxPassword string //保险箱密码
|
SafeBoxPassword string //保险箱密码
|
||||||
|
|
@ -458,7 +458,6 @@ type PlayerData struct {
|
||||||
ItemRecExpireTime int64 // 记牌器到期时间
|
ItemRecExpireTime int64 // 记牌器到期时间
|
||||||
RequestAddFriend map[int32]int64 // 玩家申请好友记录
|
RequestAddFriend map[int32]int64 // 玩家申请好友记录
|
||||||
IsTakeExpireItem bool // 是否领取
|
IsTakeExpireItem bool // 是否领取
|
||||||
LastChannel string // 最后包类型
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 七日签到数据
|
// 七日签到数据
|
||||||
|
|
@ -579,18 +578,11 @@ type PlayerDataForWeb struct {
|
||||||
WinTimes int32
|
WinTimes int32
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebItem struct {
|
|
||||||
Id int64
|
|
||||||
N int64
|
|
||||||
Name string
|
|
||||||
}
|
|
||||||
|
|
||||||
type WebPlayerDataParam struct {
|
type WebPlayerDataParam struct {
|
||||||
*PlayerData
|
*PlayerData
|
||||||
RankScore map[int64]int64
|
RankScore map[int64]int64
|
||||||
PlayerPoolUpper, PlayerPoolLower, PlayerPoolCurrent, PlayerPoolOdds int64
|
PlayerPoolUpper, PlayerPoolLower, PlayerPoolCurrent, PlayerPoolOdds int64
|
||||||
RoleAdded, VipAdded, VipExp int64
|
RoleAdded, VipAdded, VipExp int64
|
||||||
Items []*WebItem
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConvertPlayerDataToWebData(param *WebPlayerDataParam) *webapi.PlayerData {
|
func ConvertPlayerDataToWebData(param *WebPlayerDataParam) *webapi.PlayerData {
|
||||||
|
|
@ -659,14 +651,6 @@ func ConvertPlayerDataToWebData(param *WebPlayerDataParam) *webapi.PlayerData {
|
||||||
pdfw.InviteSnId = param.InviteSnId
|
pdfw.InviteSnId = param.InviteSnId
|
||||||
pdfw.InviteScore = param.InviteScore
|
pdfw.InviteScore = param.InviteScore
|
||||||
pdfw.Channel = param.Channel
|
pdfw.Channel = param.Channel
|
||||||
pdfw.LastChannel = param.LastChannel
|
|
||||||
for _, v := range param.Items {
|
|
||||||
pdfw.Items = append(pdfw.Items, &webapi.ItemInfo{
|
|
||||||
ItemId: int32(v.Id),
|
|
||||||
ItemNum: v.N,
|
|
||||||
Name: v.Name,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return pdfw
|
return pdfw
|
||||||
}
|
}
|
||||||
func (this *PlayerData) IsMarkFlag(flag int) bool {
|
func (this *PlayerData) IsMarkFlag(flag int) bool {
|
||||||
|
|
|
||||||
192
mq/consumer.go
192
mq/consumer.go
|
|
@ -18,11 +18,8 @@ import (
|
||||||
为了使用方便,这里统一启动订阅
|
为了使用方便,这里统一启动订阅
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var (
|
var subscriberLock sync.RWMutex
|
||||||
globalConsumer *RabbitMQConsumer
|
var subscriber = make(map[string][]*Subscriber)
|
||||||
subscriberLock sync.RWMutex
|
|
||||||
subscriber = make(map[string][]*Subscriber)
|
|
||||||
)
|
|
||||||
|
|
||||||
type Subscriber struct {
|
type Subscriber struct {
|
||||||
broker.Subscriber
|
broker.Subscriber
|
||||||
|
|
@ -30,96 +27,6 @@ type Subscriber struct {
|
||||||
opts []broker.SubscribeOption
|
opts []broker.SubscribeOption
|
||||||
}
|
}
|
||||||
|
|
||||||
type RabbitMQConsumer struct {
|
|
||||||
broker.Broker
|
|
||||||
url string
|
|
||||||
exchange rabbitmq.Exchange
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewRabbitMQConsumer(url string, exchange rabbitmq.Exchange, opts ...broker.Option) *RabbitMQConsumer {
|
|
||||||
mq := &RabbitMQConsumer{
|
|
||||||
url: url,
|
|
||||||
exchange: exchange,
|
|
||||||
}
|
|
||||||
options := []broker.Option{
|
|
||||||
broker.Addrs(url), rabbitmq.ExchangeName(exchange.Name),
|
|
||||||
}
|
|
||||||
if exchange.Durable {
|
|
||||||
options = append(options, rabbitmq.DurableExchange())
|
|
||||||
}
|
|
||||||
if len(opts) > 0 {
|
|
||||||
options = append(options, opts...)
|
|
||||||
}
|
|
||||||
mq.Broker = rabbitmq.NewBroker(options...)
|
|
||||||
mq.Broker.Init()
|
|
||||||
return mq
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *RabbitMQConsumer) Start() error {
|
|
||||||
if ok, _ := common.PathExists(BackupPath); !ok {
|
|
||||||
os.MkdirAll(BackupPath, os.ModePerm)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := c.Connect(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.Logger.Infof("RabbitMQConsumer.Start() url:%s exchange:%s", c.url, c.exchange.Name)
|
|
||||||
|
|
||||||
for topic, ss := range GetSubscribers() {
|
|
||||||
for _, s := range ss {
|
|
||||||
sub, err := c.Subscribe(topic, func(event broker.Event) error {
|
|
||||||
var err error
|
|
||||||
defer func() {
|
|
||||||
e := recover()
|
|
||||||
if e != nil {
|
|
||||||
logger.Logger.Errorf("RabbitMQConsumer.Subscriber() topic:%v message:%v recover:%v", event.Topic(), event.Message(), e)
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
c.backUp(event, err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
err = s.h(event)
|
|
||||||
return err
|
|
||||||
}, s.opts...)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
s.Subscriber = sub
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *RabbitMQConsumer) Stop() error {
|
|
||||||
logger.Logger.Infof("RabbitMQConsumer.Stop() url:%s exchange:%s", c.url, c.exchange.Name)
|
|
||||||
for _, ss := range GetSubscribers() {
|
|
||||||
for _, s := range ss {
|
|
||||||
s.Unsubscribe()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return c.Disconnect()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *RabbitMQConsumer) backUp(e broker.Event, err error) {
|
|
||||||
tNow := time.Now()
|
|
||||||
filePath := fmt.Sprintf(FilePathFormat, BackupPath, e.Topic(), tNow.Format(TimeFormat), tNow.Nanosecond(), rand.Int31n(10000))
|
|
||||||
f, er := os.Create(filePath)
|
|
||||||
if er != nil {
|
|
||||||
logger.Logger.Errorf("RabbitMQPublisher.public() topic:%v message:%v err:%v", e.Topic(), e.Message(), er)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
var reason string
|
|
||||||
if err != nil {
|
|
||||||
reason = err.Error()
|
|
||||||
}
|
|
||||||
f.WriteString("reason:" + reason + "\n")
|
|
||||||
f.WriteString("data:" + string(e.Message().Body) + "\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterSubscriber 注册订阅处理方法
|
// RegisterSubscriber 注册订阅处理方法
|
||||||
// 不同订阅是在各自的协程中执行的
|
// 不同订阅是在各自的协程中执行的
|
||||||
func RegisterSubscriber(topic string, h broker.Handler, opts ...broker.SubscribeOption) {
|
func RegisterSubscriber(topic string, h broker.Handler, opts ...broker.SubscribeOption) {
|
||||||
|
|
@ -130,7 +37,21 @@ func RegisterSubscriber(topic string, h broker.Handler, opts ...broker.Subscribe
|
||||||
subscriberLock.Lock()
|
subscriberLock.Lock()
|
||||||
subscriber[topic] = append(subscriber[topic], &s)
|
subscriber[topic] = append(subscriber[topic], &s)
|
||||||
subscriberLock.Unlock()
|
subscriberLock.Unlock()
|
||||||
logger.Logger.Infof("RegisterSubscriber topic:%v", topic)
|
}
|
||||||
|
|
||||||
|
func UnregisterSubscriber(topic string) {
|
||||||
|
subscriberLock.Lock()
|
||||||
|
delete(subscriber, topic)
|
||||||
|
subscriberLock.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSubscriber(topic string) []*Subscriber {
|
||||||
|
subscriberLock.RLock()
|
||||||
|
defer subscriberLock.RUnlock()
|
||||||
|
if s, ok := subscriber[topic]; ok {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetSubscribers() map[string][]*Subscriber {
|
func GetSubscribers() map[string][]*Subscriber {
|
||||||
|
|
@ -145,18 +66,75 @@ func GetSubscribers() map[string][]*Subscriber {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartConsumer 启动消费者
|
type RabbitMQConsumer struct {
|
||||||
func StartConsumer(url string, exchange string, durableExchange bool, opts ...broker.Option) {
|
broker.Broker
|
||||||
StopConsumer()
|
url string
|
||||||
globalConsumer = NewRabbitMQConsumer(url, rabbitmq.Exchange{Name: exchange, Durable: durableExchange}, opts...)
|
exchange rabbitmq.Exchange
|
||||||
if err := globalConsumer.Start(); err != nil {
|
|
||||||
panic(fmt.Sprintf("RabbitMQConsumer.Start() url:%v exchange:%v err:%v", url, exchange, err))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// StopConsumer 停止消费者
|
func NewRabbitMQConsumer(url string, exchange rabbitmq.Exchange) *RabbitMQConsumer {
|
||||||
func StopConsumer() {
|
mq := &RabbitMQConsumer{
|
||||||
if globalConsumer != nil {
|
url: url,
|
||||||
globalConsumer.Stop()
|
exchange: exchange,
|
||||||
|
}
|
||||||
|
|
||||||
|
rabbitmq.DefaultRabbitURL = mq.url
|
||||||
|
rabbitmq.DefaultExchange = mq.exchange
|
||||||
|
|
||||||
|
mq.Broker = rabbitmq.NewBroker()
|
||||||
|
mq.Broker.Init()
|
||||||
|
return mq
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *RabbitMQConsumer) Start() error {
|
||||||
|
if err := c.Connect(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
sss := GetSubscribers()
|
||||||
|
for topic, ss := range sss {
|
||||||
|
for _, s := range ss {
|
||||||
|
sub, err := c.Subscribe(topic, s.h, s.opts...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
s.Subscriber = sub
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *RabbitMQConsumer) Stop() error {
|
||||||
|
sss := GetSubscribers()
|
||||||
|
for _, ss := range sss {
|
||||||
|
for _, s := range ss {
|
||||||
|
s.Unsubscribe()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return c.Disconnect()
|
||||||
|
}
|
||||||
|
|
||||||
|
func BackUp(e broker.Event, err error) {
|
||||||
|
tNow := time.Now()
|
||||||
|
filePath := fmt.Sprintf("%s/%s_%s_%09d_%04d.dat", BACKUP_PATH, e.Topic(), tNow.Format(TIME_FORMAT), tNow.Nanosecond(), rand.Int31n(10000))
|
||||||
|
f, err := os.Create(filePath)
|
||||||
|
if err != nil {
|
||||||
|
logger.Logger.Errorf("RabbitMQPublisher.public(%s,%v) err:%v", e.Topic(), e.Message(), err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
var reason string
|
||||||
|
if err != nil {
|
||||||
|
reason = err.Error()
|
||||||
|
}
|
||||||
|
f.WriteString("reason:" + reason + "\n")
|
||||||
|
f.WriteString("data:" + string(e.Message().Body) + "\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if ok, _ := common.PathExists(BACKUP_PATH); !ok {
|
||||||
|
os.MkdirAll(BACKUP_PATH, os.ModePerm)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
220
mq/publisher.go
220
mq/publisher.go
|
|
@ -9,11 +9,10 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/goserver/core/broker"
|
"mongo.games.com/goserver/core/broker"
|
||||||
"mongo.games.com/goserver/core/broker/rabbitmq"
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
|
||||||
"mongo.games.com/game/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -21,176 +20,150 @@ import (
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const (
|
const (
|
||||||
BackupPath = "backup"
|
BACKUP_PATH = "backup"
|
||||||
TimeFormat = "20060102150405"
|
TIME_FORMAT = "20060102150405"
|
||||||
FilePathFormat = "%s/%s_%s_%09d_%04d.dat"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrClosed = errors.New("publisher is closed")
|
var ERR_CLOSED = errors.New("publisher is closed")
|
||||||
|
|
||||||
var globalPublisher *RabbitMQPublisher
|
|
||||||
|
|
||||||
type item struct {
|
type item struct {
|
||||||
topic string
|
topic string
|
||||||
msg interface{}
|
msg interface{}
|
||||||
opts []broker.PublishOption
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type RabbitMQPublisher struct {
|
type RabbitMQPublisher struct {
|
||||||
broker.Broker
|
b broker.Broker
|
||||||
exchange rabbitmq.Exchange
|
exchange rabbitmq.Exchange
|
||||||
url string
|
url string
|
||||||
que chan *item
|
que chan *item
|
||||||
closed chan struct{}
|
closed bool
|
||||||
wg sync.WaitGroup
|
waitor sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRabbitMQPublisher(url string, exchange rabbitmq.Exchange, queueSize int, opts ...broker.Option) *RabbitMQPublisher {
|
func NewRabbitMQPublisher(url string, exchange rabbitmq.Exchange, backlog int) *RabbitMQPublisher {
|
||||||
if queueSize <= 0 {
|
if backlog <= 0 {
|
||||||
queueSize = 1
|
backlog = 1
|
||||||
}
|
}
|
||||||
mq := &RabbitMQPublisher{
|
mq := &RabbitMQPublisher{
|
||||||
url: url,
|
url: url,
|
||||||
exchange: exchange,
|
exchange: exchange,
|
||||||
que: make(chan *item, queueSize),
|
que: make(chan *item, backlog),
|
||||||
closed: make(chan struct{}),
|
|
||||||
}
|
}
|
||||||
options := []broker.Option{
|
|
||||||
broker.Addrs(url), rabbitmq.ExchangeName(exchange.Name),
|
rabbitmq.DefaultRabbitURL = mq.url
|
||||||
}
|
rabbitmq.DefaultExchange = mq.exchange
|
||||||
if exchange.Durable {
|
|
||||||
options = append(options, rabbitmq.DurableExchange())
|
mq.b = rabbitmq.NewBroker()
|
||||||
}
|
mq.b.Init()
|
||||||
if len(opts) > 0 {
|
|
||||||
options = append(options, opts...)
|
|
||||||
}
|
|
||||||
mq.Broker = rabbitmq.NewBroker(options...)
|
|
||||||
mq.Broker.Init()
|
|
||||||
return mq
|
return mq
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发布消息,同步
|
|
||||||
func (p *RabbitMQPublisher) publish(topic string, msg interface{}, opts ...broker.PublishOption) (err error) {
|
|
||||||
defer func() {
|
|
||||||
e := recover()
|
|
||||||
if e != nil {
|
|
||||||
logger.Logger.Errorf("RabbitMQPublisher.public() topic:%v message:%v recover:%v", topic, msg, e)
|
|
||||||
}
|
|
||||||
if err != nil || e != nil {
|
|
||||||
p.backup(topic, msg, err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
var buf []byte
|
|
||||||
switch d := msg.(type) {
|
|
||||||
case []byte:
|
|
||||||
buf = d
|
|
||||||
case string:
|
|
||||||
buf = []byte(d)
|
|
||||||
default:
|
|
||||||
buf, err = json.Marshal(msg)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err = p.Publish(topic, &broker.Message{Body: buf}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
logger.Logger.Error("RabbitMQPublisher.publish() topic:%v message:%v err:%v", topic, msg, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *RabbitMQPublisher) publishRoutine() {
|
|
||||||
p.wg.Add(1)
|
|
||||||
defer p.wg.Done()
|
|
||||||
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case item, ok := <-p.que:
|
|
||||||
if ok {
|
|
||||||
p.publish(item.topic, item.msg, item.opts...)
|
|
||||||
} else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
case <-p.closed:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *RabbitMQPublisher) Start() (err error) {
|
func (p *RabbitMQPublisher) Start() (err error) {
|
||||||
if ok, _ := common.PathExists(BackupPath); !ok {
|
if ok, _ := common.PathExists(BACKUP_PATH); !ok {
|
||||||
err = os.MkdirAll(BackupPath, os.ModePerm)
|
err = os.MkdirAll(BACKUP_PATH, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = p.Connect(); err != nil {
|
err = p.b.Connect()
|
||||||
return err
|
if err != nil {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Logger.Infof("RabbitMQPublisher.Start() url:%s exchange:%s", p.url, p.exchange.Name)
|
go p.workerRoutine()
|
||||||
|
|
||||||
go p.publishRoutine()
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *RabbitMQPublisher) Stop() error {
|
func (p *RabbitMQPublisher) Stop() error {
|
||||||
logger.Logger.Infof("RabbitMQPublisher.Stop() url:%s exchange:%s", p.url, p.exchange.Name)
|
if p.closed {
|
||||||
select {
|
return ERR_CLOSED
|
||||||
case <-p.closed:
|
|
||||||
return ErrClosed
|
|
||||||
default:
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close(p.closed)
|
p.closed = true
|
||||||
close(p.que)
|
close(p.que)
|
||||||
for item := range p.que {
|
for item := range p.que {
|
||||||
p.publish(item.topic, item.msg, item.opts...)
|
p.publish(item.topic, item.msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
//等待所有投递出去的任务全部完成
|
//等待所有投递出去的任务全部完成
|
||||||
p.wg.Wait()
|
p.waitor.Wait()
|
||||||
|
|
||||||
return p.Disconnect()
|
return p.b.Disconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send 发布消息,异步
|
// Send 发布消息,异步
|
||||||
func (p *RabbitMQPublisher) Send(topic string, msg interface{}, opts ...broker.PublishOption) (err error) {
|
func (p *RabbitMQPublisher) Send(topic string, msg interface{}) (err error) {
|
||||||
select {
|
if p.closed {
|
||||||
case <-p.closed:
|
return ERR_CLOSED
|
||||||
return ErrClosed
|
|
||||||
default:
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i := &item{topic: topic, msg: msg, opts: opts}
|
i := &item{topic: topic, msg: msg}
|
||||||
select {
|
select {
|
||||||
case p.que <- i:
|
case p.que <- i:
|
||||||
default:
|
default:
|
||||||
//会不会情况更糟糕
|
//会不会情况更糟糕
|
||||||
go func() {
|
go p.concurrentPublish(topic, msg)
|
||||||
p.wg.Add(1)
|
|
||||||
defer p.wg.Done()
|
|
||||||
p.publish(topic, msg)
|
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *RabbitMQPublisher) concurrentPublish(topic string, msg interface{}) (err error) {
|
||||||
|
p.waitor.Add(1)
|
||||||
|
defer p.waitor.Done()
|
||||||
|
return p.publish(topic, msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发布消息,同步
|
||||||
|
func (p *RabbitMQPublisher) publish(topic string, msg interface{}) (err error) {
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
p.backup(topic, msg, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
recover()
|
||||||
|
}()
|
||||||
|
|
||||||
|
buf, err := json.Marshal(msg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = p.b.Publish(topic, &broker.Message{Body: buf})
|
||||||
|
if err != nil {
|
||||||
|
logger.Logger.Error("RabbitMQPublisher.publish err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *RabbitMQPublisher) workerRoutine() {
|
||||||
|
p.waitor.Add(1)
|
||||||
|
defer p.waitor.Done()
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case item, ok := <-p.que:
|
||||||
|
if ok {
|
||||||
|
p.publish(item.topic, item.msg)
|
||||||
|
} else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (p *RabbitMQPublisher) backup(topic string, msg interface{}, err error) {
|
func (p *RabbitMQPublisher) backup(topic string, msg interface{}, err error) {
|
||||||
buf, er := json.Marshal(msg)
|
buf, err := json.Marshal(msg)
|
||||||
if er != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tNow := time.Now()
|
tNow := time.Now()
|
||||||
filePath := fmt.Sprintf(FilePathFormat, BackupPath, topic, tNow.Format(TimeFormat), tNow.Nanosecond(), rand.Int31n(10000))
|
filePath := fmt.Sprintf("%s/%s_%s_%09d_%04d.dat", BACKUP_PATH, topic, tNow.Format(TIME_FORMAT), tNow.Nanosecond(), rand.Int31n(10000))
|
||||||
f, er := os.Create(filePath)
|
f, err := os.Create(filePath)
|
||||||
if er != nil {
|
if err != nil {
|
||||||
logger.Logger.Errorf("RabbitMQPublisher.public() topic:%v message:%v err:%v", topic, msg, er)
|
logger.Logger.Errorf("RabbitMQPublisher.public(%s,%v) err:%v", topic, msg, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
@ -201,26 +174,3 @@ func (p *RabbitMQPublisher) backup(topic string, msg interface{}, err error) {
|
||||||
f.WriteString("reason:" + reason + "\n")
|
f.WriteString("reason:" + reason + "\n")
|
||||||
f.WriteString("data:" + string(buf) + "\n")
|
f.WriteString("data:" + string(buf) + "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartPublisher 启动发布者
|
|
||||||
func StartPublisher(url string, exchange string, durableExchange bool, queueSize int, opts ...broker.Option) {
|
|
||||||
StopPublisher()
|
|
||||||
globalPublisher = NewRabbitMQPublisher(url, rabbitmq.Exchange{Name: exchange, Durable: durableExchange}, queueSize, opts...)
|
|
||||||
if err := globalPublisher.Start(); err != nil {
|
|
||||||
panic(fmt.Sprintf("RabbitMQPublisher.Start() url:%v exchange:%v err:%v", url, exchange, err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// StopPublisher 停止发布者
|
|
||||||
func StopPublisher() {
|
|
||||||
if globalPublisher != nil {
|
|
||||||
globalPublisher.Stop()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Send(topic string, msg interface{}, opts ...broker.PublishOption) (err error) {
|
|
||||||
if globalPublisher != nil {
|
|
||||||
return globalPublisher.Send(topic, msg, opts...)
|
|
||||||
}
|
|
||||||
return ErrClosed
|
|
||||||
}
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -615,7 +615,6 @@ message CSQueryRoomInfo{
|
||||||
repeated int32 GameIds = 1;
|
repeated int32 GameIds = 1;
|
||||||
int32 GameSite = 2; //1.初级 2.中级 3.高级
|
int32 GameSite = 2; //1.初级 2.中级 3.高级
|
||||||
repeated int32 Id = 3; //gamefreeid
|
repeated int32 Id = 3; //gamefreeid
|
||||||
int32 SceneMode = 4; // 0公共房 1私人房
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//个人创建的房间信息
|
//个人创建的房间信息
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -992,7 +992,6 @@ message VIPcfg {
|
||||||
int32 ShopId2 = 15;
|
int32 ShopId2 = 15;
|
||||||
int32 ShopId7 = 16;
|
int32 ShopId7 = 16;
|
||||||
repeated int32 BagStatus = 17;//每日礼包|每日金币礼包|固定VIP礼包 0可领取 1不可领取
|
repeated int32 BagStatus = 17;//每日礼包|每日金币礼包|固定VIP礼包 0可领取 1不可领取
|
||||||
int32 MatchFreeTimes = 18;// 比赛免费次数
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//VIP信息
|
//VIP信息
|
||||||
|
|
@ -1183,16 +1182,9 @@ message SCPigBankCoin {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PACKET_CSExchangeChannel
|
// PACKET_CSExchangeChannel
|
||||||
message CSExchangeChannel{
|
message CSExchangeChannel{}
|
||||||
int32 Tp = 1; // 开关类型 0所有 1:兑换 2:v卡掉落
|
|
||||||
}
|
|
||||||
|
|
||||||
message ChannelSwitch {
|
|
||||||
repeated string OnChannelName = 1; // 开启渠道
|
|
||||||
int32 Tp = 2; // 开关类型 1:兑换 2:v卡掉落
|
|
||||||
}
|
|
||||||
|
|
||||||
// PACKET_SCExchangeChannel
|
// PACKET_SCExchangeChannel
|
||||||
message SCExchangeChannel{
|
message SCExchangeChannel{
|
||||||
repeated ChannelSwitch Datas = 1;
|
repeated string OnChannelName = 1; // 开启渠道
|
||||||
}
|
}
|
||||||
|
|
@ -9916,7 +9916,6 @@ type DB_VIP struct {
|
||||||
Param []int32 `protobuf:"varint,16,rep,packed,name=Param,proto3" json:"Param,omitempty"`
|
Param []int32 `protobuf:"varint,16,rep,packed,name=Param,proto3" json:"Param,omitempty"`
|
||||||
RewardOutlineID []int32 `protobuf:"varint,17,rep,packed,name=RewardOutlineID,proto3" json:"RewardOutlineID,omitempty"`
|
RewardOutlineID []int32 `protobuf:"varint,17,rep,packed,name=RewardOutlineID,proto3" json:"RewardOutlineID,omitempty"`
|
||||||
Award map[int64]int64 `protobuf:"bytes,18,rep,name=Award,proto3" json:"Award,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
Award map[int64]int64 `protobuf:"bytes,18,rep,name=Award,proto3" json:"Award,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||||
MatchFreeTimes int32 `protobuf:"varint,19,opt,name=MatchFreeTimes,proto3" json:"MatchFreeTimes,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DB_VIP) Reset() {
|
func (x *DB_VIP) Reset() {
|
||||||
|
|
@ -10077,13 +10076,6 @@ func (x *DB_VIP) GetAward() map[int64]int64 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DB_VIP) GetMatchFreeTimes() int32 {
|
|
||||||
if x != nil {
|
|
||||||
return x.MatchFreeTimes
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
type DB_VIPArray struct {
|
type DB_VIPArray struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
|
|
@ -11403,7 +11395,7 @@ var file_pbdata_proto_rawDesc = []byte{
|
||||||
0x31, 0x0a, 0x0c, 0x44, 0x42, 0x5f, 0x54, 0x69, 0x70, 0x73, 0x41, 0x72, 0x72, 0x61, 0x79, 0x12,
|
0x31, 0x0a, 0x0c, 0x44, 0x42, 0x5f, 0x54, 0x69, 0x70, 0x73, 0x41, 0x72, 0x72, 0x61, 0x79, 0x12,
|
||||||
0x21, 0x0a, 0x03, 0x41, 0x72, 0x72, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73,
|
0x21, 0x0a, 0x03, 0x41, 0x72, 0x72, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73,
|
||||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x44, 0x42, 0x5f, 0x54, 0x69, 0x70, 0x73, 0x52, 0x03, 0x41,
|
0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x44, 0x42, 0x5f, 0x54, 0x69, 0x70, 0x73, 0x52, 0x03, 0x41,
|
||||||
0x72, 0x72, 0x22, 0xea, 0x05, 0x0a, 0x06, 0x44, 0x42, 0x5f, 0x56, 0x49, 0x50, 0x12, 0x0e, 0x0a,
|
0x72, 0x72, 0x22, 0xc2, 0x05, 0x0a, 0x06, 0x44, 0x42, 0x5f, 0x56, 0x49, 0x50, 0x12, 0x0e, 0x0a,
|
||||||
0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x49, 0x64, 0x12, 0x12, 0x0a,
|
0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x49, 0x64, 0x12, 0x12, 0x0a,
|
||||||
0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d,
|
0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d,
|
||||||
0x65, 0x12, 0x14, 0x0a, 0x05, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05,
|
0x65, 0x12, 0x14, 0x0a, 0x05, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05,
|
||||||
|
|
@ -11439,23 +11431,21 @@ var file_pbdata_proto_rawDesc = []byte{
|
||||||
0x77, 0x61, 0x72, 0x64, 0x4f, 0x75, 0x74, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x44, 0x12, 0x2f, 0x0a,
|
0x77, 0x61, 0x72, 0x64, 0x4f, 0x75, 0x74, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x44, 0x12, 0x2f, 0x0a,
|
||||||
0x05, 0x41, 0x77, 0x61, 0x72, 0x64, 0x18, 0x12, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x73,
|
0x05, 0x41, 0x77, 0x61, 0x72, 0x64, 0x18, 0x12, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x73,
|
||||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x44, 0x42, 0x5f, 0x56, 0x49, 0x50, 0x2e, 0x41, 0x77, 0x61,
|
0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x44, 0x42, 0x5f, 0x56, 0x49, 0x50, 0x2e, 0x41, 0x77, 0x61,
|
||||||
0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x41, 0x77, 0x61, 0x72, 0x64, 0x12, 0x26,
|
0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x41, 0x77, 0x61, 0x72, 0x64, 0x1a, 0x3d,
|
||||||
0x0a, 0x0e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x46, 0x72, 0x65, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73,
|
0x0a, 0x0f, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x37, 0x45, 0x6e, 0x74, 0x72,
|
||||||
0x18, 0x13, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x46, 0x72, 0x65,
|
0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03,
|
||||||
0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x1a, 0x3d, 0x0a, 0x0f, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c,
|
0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01,
|
||||||
0x65, 0x67, 0x65, 0x37, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79,
|
0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x38, 0x0a,
|
||||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76,
|
0x0a, 0x41, 0x77, 0x61, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b,
|
||||||
0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75,
|
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a,
|
||||||
0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x38, 0x0a, 0x0a, 0x41, 0x77, 0x61, 0x72, 0x64, 0x45, 0x6e,
|
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61,
|
||||||
0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
|
0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x2f, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x56, 0x49,
|
||||||
0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02,
|
0x50, 0x41, 0x72, 0x72, 0x61, 0x79, 0x12, 0x20, 0x0a, 0x03, 0x41, 0x72, 0x72, 0x18, 0x01, 0x20,
|
||||||
0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22,
|
0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x44, 0x42, 0x5f,
|
||||||
0x2f, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x56, 0x49, 0x50, 0x41, 0x72, 0x72, 0x61, 0x79, 0x12, 0x20,
|
0x56, 0x49, 0x50, 0x52, 0x03, 0x41, 0x72, 0x72, 0x42, 0x26, 0x5a, 0x24, 0x6d, 0x6f, 0x6e, 0x67,
|
||||||
0x0a, 0x03, 0x41, 0x72, 0x72, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x73, 0x65,
|
0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65,
|
||||||
0x72, 0x76, 0x65, 0x72, 0x2e, 0x44, 0x42, 0x5f, 0x56, 0x49, 0x50, 0x52, 0x03, 0x41, 0x72, 0x72,
|
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
|
||||||
0x42, 0x26, 0x5a, 0x24, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e,
|
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f,
|
|
||||||
0x6c, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
||||||
|
|
@ -1633,8 +1633,6 @@ message DB_VIP {
|
||||||
|
|
||||||
map<int64, int64> Award = 18;
|
map<int64, int64> Award = 18;
|
||||||
|
|
||||||
int32 MatchFreeTimes = 19;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message DB_VIPArray {
|
message DB_VIPArray {
|
||||||
|
|
|
||||||
|
|
@ -1307,6 +1307,7 @@ type WGPlayerEnter struct {
|
||||||
Items map[int32]int64 `protobuf:"bytes,17,rep,name=Items,proto3" json:"Items,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
Items map[int32]int64 `protobuf:"bytes,17,rep,name=Items,proto3" json:"Items,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||||
MatchParams []int32 `protobuf:"varint,18,rep,packed,name=MatchParams,proto3" json:"MatchParams,omitempty"` //比赛参数
|
MatchParams []int32 `protobuf:"varint,18,rep,packed,name=MatchParams,proto3" json:"MatchParams,omitempty"` //比赛参数
|
||||||
RankScore map[int32]int64 `protobuf:"bytes,19,rep,name=RankScore,proto3" json:"RankScore,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 排位积分
|
RankScore map[int32]int64 `protobuf:"bytes,19,rep,name=RankScore,proto3" json:"RankScore,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 排位积分
|
||||||
|
AppChannel string `protobuf:"bytes,20,opt,name=AppChannel,proto3" json:"AppChannel,omitempty"` // 包渠道
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *WGPlayerEnter) Reset() {
|
func (x *WGPlayerEnter) Reset() {
|
||||||
|
|
@ -1474,6 +1475,13 @@ func (x *WGPlayerEnter) GetRankScore() map[int32]int64 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *WGPlayerEnter) GetAppChannel() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.AppChannel
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
//从观众席坐到座位
|
//从观众席坐到座位
|
||||||
//PACKET_WG_AUDIENCESIT
|
//PACKET_WG_AUDIENCESIT
|
||||||
type WGAudienceSit struct {
|
type WGAudienceSit struct {
|
||||||
|
|
@ -8770,7 +8778,7 @@ var file_server_proto_rawDesc = []byte{
|
||||||
0x52, 0x0c, 0x52, 0x65, 0x62, 0x61, 0x74, 0x65, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x12, 0x24,
|
0x52, 0x0c, 0x52, 0x65, 0x62, 0x61, 0x74, 0x65, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x12, 0x24,
|
||||||
0x0a, 0x0d, 0x52, 0x65, 0x62, 0x61, 0x74, 0x65, 0x47, 0x61, 0x6d, 0x65, 0x43, 0x66, 0x67, 0x18,
|
0x0a, 0x0d, 0x52, 0x65, 0x62, 0x61, 0x74, 0x65, 0x47, 0x61, 0x6d, 0x65, 0x43, 0x66, 0x67, 0x18,
|
||||||
0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x52, 0x65, 0x62, 0x61, 0x74, 0x65, 0x47, 0x61, 0x6d,
|
0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x52, 0x65, 0x62, 0x61, 0x74, 0x65, 0x47, 0x61, 0x6d,
|
||||||
0x65, 0x43, 0x66, 0x67, 0x22, 0xa3, 0x06, 0x0a, 0x0d, 0x57, 0x47, 0x50, 0x6c, 0x61, 0x79, 0x65,
|
0x65, 0x43, 0x66, 0x67, 0x22, 0xc3, 0x06, 0x0a, 0x0d, 0x57, 0x47, 0x50, 0x6c, 0x61, 0x79, 0x65,
|
||||||
0x72, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x53, 0x69, 0x64, 0x18, 0x01, 0x20,
|
0x72, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x53, 0x69, 0x64, 0x18, 0x01, 0x20,
|
||||||
0x01, 0x28, 0x03, 0x52, 0x03, 0x53, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x47, 0x61, 0x74, 0x65,
|
0x01, 0x28, 0x03, 0x52, 0x03, 0x53, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x47, 0x61, 0x74, 0x65,
|
||||||
0x53, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x47, 0x61, 0x74, 0x65, 0x53,
|
0x53, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x47, 0x61, 0x74, 0x65, 0x53,
|
||||||
|
|
@ -8813,7 +8821,9 @@ var file_server_proto_rawDesc = []byte{
|
||||||
0x0b, 0x32, 0x24, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x57, 0x47, 0x50, 0x6c, 0x61,
|
0x0b, 0x32, 0x24, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x57, 0x47, 0x50, 0x6c, 0x61,
|
||||||
0x79, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x52, 0x61, 0x6e, 0x6b, 0x53, 0x63, 0x6f,
|
0x79, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x52, 0x61, 0x6e, 0x6b, 0x53, 0x63, 0x6f,
|
||||||
0x72, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x52, 0x61, 0x6e, 0x6b, 0x53, 0x63, 0x6f,
|
0x72, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x52, 0x61, 0x6e, 0x6b, 0x53, 0x63, 0x6f,
|
||||||
0x72, 0x65, 0x1a, 0x38, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79,
|
0x72, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x41, 0x70, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c,
|
||||||
|
0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x41, 0x70, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x6e,
|
||||||
|
0x65, 0x6c, 0x1a, 0x38, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79,
|
||||||
0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b,
|
0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b,
|
||||||
0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
|
0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||||
0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e,
|
0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e,
|
||||||
|
|
|
||||||
|
|
@ -229,6 +229,7 @@ message WGPlayerEnter {
|
||||||
map<int32, int64> Items = 17;
|
map<int32, int64> Items = 17;
|
||||||
repeated int32 MatchParams = 18;//比赛参数
|
repeated int32 MatchParams = 18;//比赛参数
|
||||||
map<int32, int64> RankScore = 19;// 排位积分
|
map<int32, int64> RankScore = 19;// 排位积分
|
||||||
|
string AppChannel = 20; // 包渠道
|
||||||
}
|
}
|
||||||
|
|
||||||
//从观众席坐到座位
|
//从观众席坐到座位
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -199,9 +199,7 @@ message PlayerData{
|
||||||
string InviteCode = 50;//邀请码
|
string InviteCode = 50;//邀请码
|
||||||
int32 InviteSnId = 51;//邀请人
|
int32 InviteSnId = 51;//邀请人
|
||||||
int64 InviteScore = 52;//邀请积分
|
int64 InviteScore = 52;//邀请积分
|
||||||
string Channel = 53; // 首次安装渠道
|
string Channel = 53; // 渠道名称
|
||||||
string LastChannel = 54; // 最近使用的包渠道
|
|
||||||
repeated ItemInfo Items = 55; // 背包物品
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message RoomInfo{
|
message RoomInfo{
|
||||||
|
|
@ -563,7 +561,6 @@ message VIPcfg {
|
||||||
repeated int32 RewardOutlineID = 14;
|
repeated int32 RewardOutlineID = 14;
|
||||||
int32 ShopId2 = 15;
|
int32 ShopId2 = 15;
|
||||||
int32 ShopId7 = 16;
|
int32 ShopId7 = 16;
|
||||||
int32 MatchFreeTimes = 17; // vip比赛场免费次数
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// etcd /game/VIPcfg VIP配置
|
// etcd /game/VIPcfg VIP配置
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -468,7 +468,6 @@ message ASCreateShortMessage{
|
||||||
int64 Diamond = 8;
|
int64 Diamond = 8;
|
||||||
int64 ShowId = 9;
|
int64 ShowId = 9;
|
||||||
repeated int32 Params = 10;
|
repeated int32 Params = 10;
|
||||||
repeated string OnChannelName = 11;
|
|
||||||
}
|
}
|
||||||
message SACreateShortMessage{
|
message SACreateShortMessage{
|
||||||
TagCode Tag = 1; //错误码
|
TagCode Tag = 1; //错误码
|
||||||
|
|
@ -914,8 +913,6 @@ message ASAddItemById{
|
||||||
int32 Snid = 1; // 玩家id
|
int32 Snid = 1; // 玩家id
|
||||||
string Platform = 2; // 平台id
|
string Platform = 2; // 平台id
|
||||||
repeated ItemInfo ItemInfo = 3;//道具
|
repeated ItemInfo ItemInfo = 3;//道具
|
||||||
int32 TypeId = 4; // 变化类型
|
|
||||||
string Remark = 5; // 描述
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message SAAddItemById{
|
message SAAddItemById{
|
||||||
|
|
|
||||||
2
public
2
public
|
|
@ -1 +1 @@
|
||||||
Subproject commit 7f2452e10c176dc35fc5ed1ffdb0b4145aec8160
|
Subproject commit a7fc5af077865e1daf27c8e04ff3247aa643a815
|
||||||
|
|
@ -19,7 +19,7 @@ func Register(mainId int, msgType interface{}, h func(s *netlib.Session, g *rank
|
||||||
return reflect.New(tp).Interface()
|
return reflect.New(tp).Interface()
|
||||||
}
|
}
|
||||||
|
|
||||||
common.Register(mainId, rankproto.GateTransmit{}, func(s *netlib.Session, packetId int, data interface{}, sid int64) error {
|
common.RegisterHandler(mainId, common.HandlerWrapper(func(s *netlib.Session, packetId int, data interface{}, sid int64) error {
|
||||||
d, ok := data.(*rankproto.GateTransmit)
|
d, ok := data.(*rankproto.GateTransmit)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -36,5 +36,9 @@ func Register(mainId int, msgType interface{}, h func(s *netlib.Session, g *rank
|
||||||
}
|
}
|
||||||
|
|
||||||
return h(s, d, packetId, msg, sid)
|
return h(s, d, packetId, msg, sid)
|
||||||
})
|
}))
|
||||||
|
|
||||||
|
netlib.RegisterFactory(mainId, netlib.PacketFactoryWrapper(func() interface{} {
|
||||||
|
return &rankproto.GateTransmit{}
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,12 +97,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"etcd": {
|
|
||||||
"Url": ["127.0.0.1:2379"],
|
|
||||||
"UserName": "",
|
|
||||||
"Password": "",
|
|
||||||
"DialTimeout": 60
|
|
||||||
},
|
|
||||||
"costum": {
|
"costum": {
|
||||||
"MgoRpcCliNet": "tcp",
|
"MgoRpcCliNet": "tcp",
|
||||||
"MgoRpcCliAddr": "127.0.0.1:8999",
|
"MgoRpcCliAddr": "127.0.0.1:8999",
|
||||||
|
|
@ -111,6 +106,13 @@
|
||||||
"RabbitMQURL": "amqp://win88:123456@127.0.0.1:5672/win88",
|
"RabbitMQURL": "amqp://win88:123456@127.0.0.1:5672/win88",
|
||||||
"RMQExchange": "win88",
|
"RMQExchange": "win88",
|
||||||
"RMQPublishBacklog": 1024,
|
"RMQPublishBacklog": 1024,
|
||||||
|
|
||||||
|
"etcdurl":[
|
||||||
|
"127.0.0.1:2379"
|
||||||
|
],
|
||||||
|
"etcduser": "root",
|
||||||
|
"etcdpwd": "win88",
|
||||||
|
|
||||||
"GameIdFilter": []
|
"GameIdFilter": []
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"mongo.games.com/game/common"
|
||||||
|
"mongo.games.com/game/model"
|
||||||
|
"mongo.games.com/game/mq"
|
||||||
|
"mongo.games.com/goserver/core"
|
||||||
|
"mongo.games.com/goserver/core/broker/rabbitmq"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var RabbitMQPublisher *mq.RabbitMQPublisher
|
||||||
|
var RabbitMqConsumer *mq.RabbitMQConsumer
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
//首先加载游戏配置
|
||||||
|
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
||||||
|
//初始化rpc
|
||||||
|
model.StartupRPClient(common.CustomConfig.GetString("MgoRpcCliNet"), common.CustomConfig.GetString("MgoRpcCliAddr"), time.Duration(common.CustomConfig.GetInt("MgoRpcCliReconnInterV"))*time.Second)
|
||||||
|
|
||||||
|
//rabbitmq打开链接
|
||||||
|
RabbitMqConsumer = mq.NewRabbitMQConsumer(common.CustomConfig.GetString("RabbitMQURL"), rabbitmq.Exchange{Name: common.CustomConfig.GetString("RMQExchange"), Durable: true})
|
||||||
|
if RabbitMqConsumer != nil {
|
||||||
|
RabbitMqConsumer.Start()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
||||||
|
if RabbitMqConsumer != nil {
|
||||||
|
RabbitMqConsumer.Stop()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -1,37 +1,21 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"mongo.games.com/game/model"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core"
|
"mongo.games.com/goserver/core"
|
||||||
"mongo.games.com/goserver/core/etcd"
|
|
||||||
"mongo.games.com/goserver/core/module"
|
"mongo.games.com/goserver/core/module"
|
||||||
|
|
||||||
_ "mongo.games.com/game"
|
_ "mongo.games.com/game"
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/model"
|
|
||||||
"mongo.games.com/game/mq"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// 自定义配置文件
|
core.RegisterConfigEncryptor(common.ConfigFE)
|
||||||
model.InitGameParam()
|
|
||||||
// package模块
|
|
||||||
core.LoadPackages("config.json")
|
core.LoadPackages("config.json")
|
||||||
defer core.ClosePackages()
|
defer core.ClosePackages()
|
||||||
// core hook
|
|
||||||
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
model.InitGameParam()
|
||||||
etcd.Start()
|
|
||||||
model.StartupRPClient(common.CustomConfig.GetString("MgoRpcCliNet"), common.CustomConfig.GetString("MgoRpcCliAddr"), time.Duration(common.CustomConfig.GetInt("MgoRpcCliReconnInterV"))*time.Second)
|
waitor := module.Start()
|
||||||
mq.StartConsumer(common.CustomConfig.GetString("RabbitMQURL"), common.CustomConfig.GetString("RMQExchange"), true)
|
waitor.Wait("ranksrv")
|
||||||
return nil
|
|
||||||
})
|
|
||||||
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
|
||||||
mq.StopConsumer()
|
|
||||||
model.ShutdownRPClient()
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
// module模块
|
|
||||||
w := module.Start()
|
|
||||||
w.Wait("ranksrv")
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,11 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/globalsign/mgo/bson"
|
"github.com/globalsign/mgo/bson"
|
||||||
|
"mongo.games.com/goserver/core"
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
|
||||||
|
"mongo.games.com/game/common"
|
||||||
|
"mongo.games.com/game/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AccountData struct {
|
type AccountData struct {
|
||||||
|
|
@ -23,8 +27,19 @@ var (
|
||||||
)
|
)
|
||||||
var accountFileName = "robotaccount.json"
|
var accountFileName = "robotaccount.json"
|
||||||
|
|
||||||
// InitAccountData 初始化机器人账号
|
func init() {
|
||||||
func InitAccountData() {
|
model.InitGameParam()
|
||||||
|
|
||||||
|
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
||||||
|
initAccountData()
|
||||||
|
// 连接数据库服务
|
||||||
|
model.StartupRPClient(common.CustomConfig.GetString("MgoRpcCliNet"), common.CustomConfig.GetString("MgoRpcCliAddr"), time.Duration(common.CustomConfig.GetInt("MgoRpcCliReconnInterV"))*time.Second)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化机器人账号
|
||||||
|
func initAccountData() {
|
||||||
dirty := false
|
dirty := false
|
||||||
newFunc := func(n int) {
|
newFunc := func(n int) {
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,11 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"mongo.games.com/goserver/core"
|
"mongo.games.com/goserver/core"
|
||||||
"mongo.games.com/goserver/core/module"
|
"mongo.games.com/goserver/core/module"
|
||||||
|
|
||||||
_ "mongo.games.com/game"
|
_ "mongo.games.com/game"
|
||||||
"mongo.games.com/game/common"
|
_ "mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/model"
|
|
||||||
"mongo.games.com/game/robot/base"
|
|
||||||
_ "mongo.games.com/game/robot/base"
|
_ "mongo.games.com/game/robot/base"
|
||||||
_ "mongo.games.com/game/robot/chess"
|
_ "mongo.games.com/game/robot/chess"
|
||||||
_ "mongo.games.com/game/robot/thirteen"
|
_ "mongo.games.com/game/robot/thirteen"
|
||||||
|
|
@ -18,22 +14,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// 自定义配置文件
|
|
||||||
model.InitGameParam()
|
|
||||||
// package模块
|
|
||||||
defer core.ClosePackages()
|
defer core.ClosePackages()
|
||||||
core.LoadPackages("config.json")
|
core.LoadPackages("config.json")
|
||||||
// core hook
|
|
||||||
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
|
||||||
model.StartupRPClient(common.CustomConfig.GetString("MgoRpcCliNet"), common.CustomConfig.GetString("MgoRpcCliAddr"), time.Duration(common.CustomConfig.GetInt("MgoRpcCliReconnInterV"))*time.Second)
|
|
||||||
base.InitAccountData()
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
|
||||||
model.ShutdownRPClient()
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
// module模块
|
|
||||||
waiter := module.Start()
|
waiter := module.Start()
|
||||||
waiter.Wait("main()")
|
waiter.Wait("main()")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -154,9 +154,7 @@ func (this *Configuration) Init() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Configuration) Close() error {
|
func (this *Configuration) Close() error {
|
||||||
if this.watcher != nil {
|
|
||||||
this.watcher.Close()
|
this.watcher.Close()
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e
|
||||||
ItemId: msg.ItemId,
|
ItemId: msg.ItemId,
|
||||||
ItemNum: int64(msg.ItemNum),
|
ItemNum: int64(msg.ItemNum),
|
||||||
}}
|
}}
|
||||||
BagMgrSingleton.AddItems(p, items, 0, common.GainWay_ItemUse, "system", "测试", 0, 0, false)
|
BagMgrSingleton.AddItems(p, items, 0, common.GainWay_AddBag, "system", "测试", 0, 0, false)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -112,41 +112,23 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e
|
||||||
|
|
||||||
items := map[int32]*Item{}
|
items := map[int32]*Item{}
|
||||||
var useFunc func()
|
var useFunc func()
|
||||||
saleFunc := func(gainWay int32, oper, remark string) {
|
saleFunc := func() {
|
||||||
if gainWay == 0 {
|
|
||||||
gainWay = common.GainWay_ItemUse
|
|
||||||
}
|
|
||||||
if oper == "" {
|
|
||||||
oper = "player"
|
|
||||||
}
|
|
||||||
if remark == "" {
|
|
||||||
remark = "道具使用"
|
|
||||||
}
|
|
||||||
// 使用道具,减少道具
|
// 使用道具,减少道具
|
||||||
BagMgrSingleton.AddItem(p, int64(item.ItemId), int64(-msg.ItemNum), 0, gainWay, oper, remark, 0, 0, false)
|
BagMgrSingleton.AddItem(p, int64(item.ItemId), int64(-msg.ItemNum), 0, common.GainWay_ItemUse, "player", "道具使用", 0, 0, false)
|
||||||
pack.RetCode = bag.OpResultCode_OPRC_Sucess
|
pack.RetCode = bag.OpResultCode_OPRC_Sucess
|
||||||
pack.NowItemId = item.ItemId
|
pack.NowItemId = item.ItemId
|
||||||
pack.NowItemNum = item.ItemNum
|
pack.NowItemNum = item.ItemNum
|
||||||
}
|
}
|
||||||
gainFunc := func(gainWay int32, oper, remark string) {
|
gainFunc := func() {
|
||||||
for i := 0; i < int(msg.ItemNum); i++ {
|
for i := 0; i < int(msg.ItemNum); i++ {
|
||||||
useFunc()
|
useFunc()
|
||||||
}
|
}
|
||||||
if gainWay == 0 {
|
|
||||||
gainWay = common.GainWay_ItemUse
|
|
||||||
}
|
|
||||||
if oper == "" {
|
|
||||||
oper = "player"
|
|
||||||
}
|
|
||||||
if remark == "" {
|
|
||||||
remark = "道具使用"
|
|
||||||
}
|
|
||||||
if len(items) > 0 {
|
if len(items) > 0 {
|
||||||
var itemArr []*Item
|
var itemArr []*Item
|
||||||
for _, v := range items {
|
for _, v := range items {
|
||||||
itemArr = append(itemArr, v)
|
itemArr = append(itemArr, v)
|
||||||
}
|
}
|
||||||
BagMgrSingleton.AddItems(p, itemArr, 0, gainWay, oper, remark, 0, 0, false)
|
BagMgrSingleton.AddItems(p, itemArr, 0, common.GainWay_ItemUse, "player", "道具使用", 0, 0, false)
|
||||||
for _, v := range itemArr {
|
for _, v := range itemArr {
|
||||||
pack.Infos = append(pack.Infos, &bag.ItemInfo{
|
pack.Infos = append(pack.Infos, &bag.ItemInfo{
|
||||||
ItemId: v.ItemId,
|
ItemId: v.ItemId,
|
||||||
|
|
@ -159,7 +141,7 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e
|
||||||
|
|
||||||
switch item.ItemId {
|
switch item.ItemId {
|
||||||
case common.ItemIDGiftBox:
|
case common.ItemIDGiftBox:
|
||||||
saleFunc(0, "", "")
|
saleFunc()
|
||||||
useFunc = func() {
|
useFunc = func() {
|
||||||
sum := 0
|
sum := 0
|
||||||
for _, v := range srvdata.PBDB_GiftBoxMgr.Datas.GetArr() {
|
for _, v := range srvdata.PBDB_GiftBoxMgr.Datas.GetArr() {
|
||||||
|
|
@ -190,10 +172,10 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gainFunc(0, "", "")
|
gainFunc()
|
||||||
|
|
||||||
case common.ItemIDCollectBox:
|
case common.ItemIDCollectBox:
|
||||||
saleFunc(0, "", "")
|
saleFunc()
|
||||||
useFunc = func() {
|
useFunc = func() {
|
||||||
sum := 0
|
sum := 0
|
||||||
for _, v := range srvdata.PBDB_CollectBoxMgr.Datas.GetArr() {
|
for _, v := range srvdata.PBDB_CollectBoxMgr.Datas.GetArr() {
|
||||||
|
|
@ -224,7 +206,7 @@ func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gainFunc(common.GainWay_Collect, "player", "集卡活动")
|
gainFunc()
|
||||||
|
|
||||||
default:
|
default:
|
||||||
logger.Logger.Warnf("道具使用未定义", msg.ItemId)
|
logger.Logger.Warnf("道具使用未定义", msg.ItemId)
|
||||||
|
|
@ -391,10 +373,10 @@ func CSPropExchange(s *netlib.Session, packetid int, data interface{}, sid int64
|
||||||
}
|
}
|
||||||
// 扣除背包物品
|
// 扣除背包物品
|
||||||
for _, item := range costItems {
|
for _, item := range costItems {
|
||||||
BagMgrSingleton.AddItem(p, int64(item.ItemId), -item.ItemNum, 0, common.GainWayItemCollectExchange, "system", "集卡活动兑换", 0, 0, false)
|
BagMgrSingleton.AddItem(p, int64(item.ItemId), -item.ItemNum, 0, common.GainWay_Collect, "system", "集卡活动兑换", 0, 0, false)
|
||||||
}
|
}
|
||||||
// 增加背包物品
|
// 增加背包物品
|
||||||
BagMgrSingleton.AddItems(p, items, 0, common.GainWayItemCollectExchange, "system", "集卡活动兑换", 0, 0, false)
|
BagMgrSingleton.AddItems(p, items, 0, common.GainWay_Collect, "system", "集卡活动兑换", 0, 0, false)
|
||||||
for _, v := range items {
|
for _, v := range items {
|
||||||
pack.Items = append(pack.Items, &bag.PropInfo{
|
pack.Items = append(pack.Items, &bag.PropInfo{
|
||||||
ItemId: v.ItemId,
|
ItemId: v.ItemId,
|
||||||
|
|
|
||||||
|
|
@ -520,7 +520,7 @@ func (this *CSInviteFriendOpHandler) Process(s *netlib.Session, packetid int, da
|
||||||
send(p)
|
send(p)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !scene.PlayerEnter(p, pos, true) {
|
if !p.EnterScene(scene, true, pos) {
|
||||||
logger.Logger.Trace("CSInviteFriendHandler EnterScene fail")
|
logger.Logger.Trace("CSInviteFriendHandler EnterScene fail")
|
||||||
opRetCode = friend.OpResultCode_OPRC_Error //进入房间失败
|
opRetCode = friend.OpResultCode_OPRC_Error //进入房间失败
|
||||||
send(p)
|
send(p)
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,11 @@ func (this *CSEnterRoomHandler) Process(s *netlib.Session, packetid int, data in
|
||||||
if scene.IsMatchScene() && p.IsRob {
|
if scene.IsMatchScene() && p.IsRob {
|
||||||
grade := int32(1000)
|
grade := int32(1000)
|
||||||
snid := p.SnId
|
snid := p.SnId
|
||||||
|
ms := MatchSeasonMgrSington.GetMatchSeason(snid) // 玩家赛季信息
|
||||||
|
lv := MatchSeasonRankMgrSington.CreateRobotLv() //
|
||||||
|
if ms != nil {
|
||||||
|
lv = ms.Lv
|
||||||
|
}
|
||||||
roleId := int32(2000001)
|
roleId := int32(2000001)
|
||||||
if p.Roles != nil {
|
if p.Roles != nil {
|
||||||
roleId = p.Roles.ModId
|
roleId = p.Roles.ModId
|
||||||
|
|
@ -154,18 +159,19 @@ func (this *CSEnterRoomHandler) Process(s *netlib.Session, packetid int, data in
|
||||||
randIndex := rand.Intn(len(tm.copyRobotGrades))
|
randIndex := rand.Intn(len(tm.copyRobotGrades))
|
||||||
grade = tm.copyRobotGrades[randIndex].grade
|
grade = tm.copyRobotGrades[randIndex].grade
|
||||||
snid = tm.copyRobotGrades[randIndex].copySnid
|
snid = tm.copyRobotGrades[randIndex].copySnid
|
||||||
|
lv = tm.copyRobotGrades[randIndex].copyLv
|
||||||
roleId = tm.copyRobotGrades[randIndex].copyRoleId
|
roleId = tm.copyRobotGrades[randIndex].copyRoleId
|
||||||
tm.copyRobotGrades = append(tm.copyRobotGrades[:randIndex], tm.copyRobotGrades[randIndex+1:]...)
|
tm.copyRobotGrades = append(tm.copyRobotGrades[:randIndex], tm.copyRobotGrades[randIndex+1:]...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mc := NewMatchContext(p, tm, grade, snid, 1, roleId, 0)
|
mc := NewMatchContext(p, tm, grade, snid, lv, roleId, 0)
|
||||||
if mc != nil {
|
if mc != nil {
|
||||||
mc.gaming = true
|
mc.gaming = true
|
||||||
p.matchCtx = mc
|
p.matchCtx = mc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !scene.PlayerEnter(p, -1, true) {
|
if !p.EnterScene(scene, true, -1) {
|
||||||
code = gamehall.OpResultCode_Game_OPRC_Error_Game
|
code = gamehall.OpResultCode_Game_OPRC_Error_Game
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1304,9 +1310,6 @@ func (this *CSQueryRoomInfoHandler) ProcessLocalGame(s *netlib.Session, packetid
|
||||||
pack.GameIds = append(pack.GameIds, gameid)
|
pack.GameIds = append(pack.GameIds, gameid)
|
||||||
scenes := SceneMgrSingleton.GetScenesByGame(int(gameid))
|
scenes := SceneMgrSingleton.GetScenesByGame(int(gameid))
|
||||||
for _, scene := range scenes {
|
for _, scene := range scenes {
|
||||||
if scene == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
var isShow bool
|
var isShow bool
|
||||||
if mapGameCfg != nil {
|
if mapGameCfg != nil {
|
||||||
if cfg, have := mapGameCfg[scene.dbGameFree.Id]; have && cfg.GroupId != 0 && cfg.GroupId == scene.groupId {
|
if cfg, have := mapGameCfg[scene.dbGameFree.Id]; have && cfg.GroupId != 0 && cfg.GroupId == scene.groupId {
|
||||||
|
|
@ -1314,16 +1317,8 @@ func (this *CSQueryRoomInfoHandler) ProcessLocalGame(s *netlib.Session, packetid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if p.Platform == scene.limitPlatform.IdStr || isShow {
|
if p.Platform == scene.limitPlatform.IdStr || isShow {
|
||||||
if scene.sceneMode == int(msg.GetSceneMode()) && len(scene.players) != 0 {
|
if scene != nil && scene.sceneMode == common.SceneMode_Public && len(scene.players) != 0 {
|
||||||
if scene.gameId == int(gameid) && scene.gameSite == int(msg.GetGameSite()) {
|
if scene.gameId == int(gameid) && scene.gameSite == int(msg.GetGameSite()) {
|
||||||
|
|
||||||
// 私人房需要是好友
|
|
||||||
if scene.sceneMode == common.SceneMode_Private {
|
|
||||||
if !FriendMgrSington.IsFriend(p.Platform, p.SnId, scene.creator) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
roomInfo := &gamehall.QRoomInfo{
|
roomInfo := &gamehall.QRoomInfo{
|
||||||
GameFreeId: proto.Int32(scene.dbGameFree.GetId()),
|
GameFreeId: proto.Int32(scene.dbGameFree.GetId()),
|
||||||
GameId: proto.Int32(scene.dbGameFree.GetGameId()),
|
GameId: proto.Int32(scene.dbGameFree.GetGameId()),
|
||||||
|
|
@ -1350,6 +1345,58 @@ func (this *CSQueryRoomInfoHandler) ProcessLocalGame(s *netlib.Session, packetid
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *CSQueryRoomInfoHandler) ProcessId(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||||
|
logger.Logger.Trace("CSQueryRoomInfoHandler Process recv ProcessId", data)
|
||||||
|
if msg, ok := data.(*gamehall.CSQueryRoomInfo); ok {
|
||||||
|
p := PlayerMgrSington.GetPlayer(sid)
|
||||||
|
if p == nil {
|
||||||
|
logger.Logger.Warn("CSQueryRoomInfoHandler p == nil")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
pack := &gamehall.SCQueryRoomInfo{}
|
||||||
|
mapGameCfg := PlatformMgrSingleton.GetGameFrees(p.Platform)
|
||||||
|
for _, v := range msg.GetId() {
|
||||||
|
gameid := v / 10000
|
||||||
|
pack.GameIds = append(pack.GameIds, gameid)
|
||||||
|
scenes := SceneMgrSingleton.GetScenesByGame(int(gameid))
|
||||||
|
for _, scene := range scenes {
|
||||||
|
var isShow bool
|
||||||
|
if mapGameCfg != nil {
|
||||||
|
if cfg, have := mapGameCfg[scene.dbGameFree.Id]; have && cfg.GroupId != 0 && cfg.GroupId == scene.groupId {
|
||||||
|
isShow = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if p.Platform == scene.limitPlatform.IdStr || isShow {
|
||||||
|
if scene != nil && scene.sceneMode == common.SceneMode_Public && len(scene.players) != 0 {
|
||||||
|
if scene.dbGameFree.Id == v {
|
||||||
|
roomInfo := &gamehall.QRoomInfo{
|
||||||
|
GameFreeId: proto.Int32(scene.dbGameFree.GetId()),
|
||||||
|
GameId: proto.Int32(scene.dbGameFree.GetGameId()),
|
||||||
|
RoomId: proto.Int(scene.sceneId),
|
||||||
|
BaseCoin: proto.Int64(int64(scene.BaseScore)),
|
||||||
|
LimitCoin: proto.Int64(scene.dbGameFree.GetLimitCoin()),
|
||||||
|
CurrNum: proto.Int(scene.GetPlayerCnt()),
|
||||||
|
MaxPlayer: proto.Int(scene.playerNum),
|
||||||
|
Creator: proto.Int32(scene.creator),
|
||||||
|
CreateTs: proto.Int32(int32(scene.createTime.Unix())),
|
||||||
|
Params: common.CopySliceInt64ToInt32(scene.params),
|
||||||
|
}
|
||||||
|
pack.RoomInfo = append(pack.RoomInfo, roomInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pack.OpRetCode = gamehall.OpResultCode_Game_OPRC_Sucess_Game
|
||||||
|
proto.SetDefaults(pack)
|
||||||
|
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_QUERYROOMINFO), pack)
|
||||||
|
logger.Logger.Trace("SCQueryRoomInfo: ", pack)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type CSLotteryLogPacketFactory struct {
|
type CSLotteryLogPacketFactory struct {
|
||||||
}
|
}
|
||||||
type CSLotteryLogHandler struct {
|
type CSLotteryLogHandler struct {
|
||||||
|
|
@ -1893,13 +1940,17 @@ func (this *CSCreateRoomHandler) ProcessLocalGame(s *netlib.Session, packetid in
|
||||||
}
|
}
|
||||||
scene, code = p.CreateLocalGameScene(roomId, int(gameId), int(gameSite), int(msg.GetSceneMode()), maxPlayerNum,
|
scene, code = p.CreateLocalGameScene(roomId, int(gameId), int(gameSite), int(msg.GetSceneMode()), maxPlayerNum,
|
||||||
params, dbGameFree, baseScore, csp.groupId)
|
params, dbGameFree, baseScore, csp.groupId)
|
||||||
if scene != nil && code == gamehall.OpResultCode_Game_OPRC_Sucess_Game {
|
if scene != nil {
|
||||||
|
if code == gamehall.OpResultCode_Game_OPRC_Sucess_Game {
|
||||||
logger.Logger.Tracef("CSCreateRoomHandler SnId:%v Create Sucess GameId:%v", p.SnId, gameId)
|
logger.Logger.Tracef("CSCreateRoomHandler SnId:%v Create Sucess GameId:%v", p.SnId, gameId)
|
||||||
csp.AddScene(scene)
|
// try enter scene
|
||||||
if !scene.PlayerEnter(p, -1, true) {
|
csp.scenes[scene.sceneId] = scene
|
||||||
|
scene.csp = csp
|
||||||
|
if !p.EnterScene(scene, true, -1) {
|
||||||
code = gamehall.OpResultCode_Game_OPRC_Error_Game
|
code = gamehall.OpResultCode_Game_OPRC_Error_Game
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
resp := &gamehall.SCCreateRoom{
|
resp := &gamehall.SCCreateRoom{
|
||||||
|
|
@ -2003,7 +2054,7 @@ func (this *CSCreateRoomHandler) ProcessThirteen(s *netlib.Session, packetid int
|
||||||
// try enter scene
|
// try enter scene
|
||||||
csp.scenes[scene.sceneId] = scene
|
csp.scenes[scene.sceneId] = scene
|
||||||
scene.csp = csp
|
scene.csp = csp
|
||||||
if !scene.PlayerEnter(p, -1, true) {
|
if !p.EnterScene(scene, true, -1) {
|
||||||
code = gamehall.OpResultCode_Game_OPRC_Error_Game
|
code = gamehall.OpResultCode_Game_OPRC_Error_Game
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ func (this *CSInviteCodePlayerHandler) Process(s *netlib.Session, packetid int,
|
||||||
//发送邮件
|
//发送邮件
|
||||||
var otherParams []int32
|
var otherParams []int32
|
||||||
newMsg := model.NewMessage("", p.SnId, "", p.SnId, model.MSGTYPE_INVITECODE, p.Name, inviteCode, coin, 0,
|
newMsg := model.NewMessage("", p.SnId, "", p.SnId, model.MSGTYPE_INVITECODE, p.Name, inviteCode, coin, 0,
|
||||||
model.MSGSTATE_UNREAD, time.Now().Unix(), 0, "", otherParams, p.Platform, model.HallAll, nil)
|
model.MSGSTATE_UNREAD, time.Now().Unix(), 0, "", otherParams, p.Platform, model.HallAll)
|
||||||
err = model.InsertMessage(p.Platform, newMsg)
|
err = model.InsertMessage(p.Platform, newMsg)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
||||||
|
|
@ -1777,7 +1777,7 @@ func (this *CSVIPPrivilegeInfoHandler) Process(s *netlib.Session, packetid int,
|
||||||
}
|
}
|
||||||
switch code {
|
switch code {
|
||||||
case 1: //1.VIP比赛场免费次数
|
case 1: //1.VIP比赛场免费次数
|
||||||
pack.Value = p.GetMatchFreeTimes()
|
pack.Value = p.GetVIPPrivilege1()
|
||||||
pack.NowValue = p.VipMatchTimes
|
pack.NowValue = p.VipMatchTimes
|
||||||
}
|
}
|
||||||
p.SendToClient(int(player_proto.PlayerPacketID_PACKET_SC_VIPPrivilegeInfo), pack)
|
p.SendToClient(int(player_proto.PlayerPacketID_PACKET_SC_VIPPrivilegeInfo), pack)
|
||||||
|
|
@ -1854,7 +1854,7 @@ func init() {
|
||||||
|
|
||||||
func CSExchangeChannel(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
func CSExchangeChannel(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||||
logger.Logger.Trace("CSExchangeChannel Process recv ", data)
|
logger.Logger.Trace("CSExchangeChannel Process recv ", data)
|
||||||
msg, ok := data.(*player_proto.CSExchangeChannel)
|
_, ok := data.(*player_proto.CSExchangeChannel)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -1865,28 +1865,15 @@ func CSExchangeChannel(s *netlib.Session, packetid int, data interface{}, sid in
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
pack := &player_proto.SCExchangeChannel{}
|
var onChannelName []string
|
||||||
|
conf := PlatformMgrSingleton.GetConfig(p.Platform).ChannelSwitch[common.ChannelSwitchExchange]
|
||||||
if msg.Tp == 0 {
|
if conf != nil {
|
||||||
for _, v := range PlatformMgrSingleton.GetConfig(p.Platform).ChannelSwitch {
|
onChannelName = conf.OnChannelName
|
||||||
if v == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
pack.Datas = append(pack.Datas, &player_proto.ChannelSwitch{
|
|
||||||
OnChannelName: v.OnChannelName,
|
|
||||||
Tp: v.Tp,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
v := PlatformMgrSingleton.GetConfig(p.Platform).ChannelSwitch[msg.GetTp()]
|
|
||||||
if v != nil {
|
|
||||||
pack.Datas = append(pack.Datas, &player_proto.ChannelSwitch{
|
|
||||||
OnChannelName: v.OnChannelName,
|
|
||||||
Tp: v.Tp,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pack := &player_proto.SCExchangeChannel{
|
||||||
|
OnChannelName: onChannelName,
|
||||||
|
}
|
||||||
p.SendToClient(int(player_proto.PlayerPacketID_PACKET_SCExchangeChannel), pack)
|
p.SendToClient(int(player_proto.PlayerPacketID_PACKET_SCExchangeChannel), pack)
|
||||||
logger.Logger.Tracef("SCExchangeChannel %v", pack)
|
logger.Logger.Tracef("SCExchangeChannel %v", pack)
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -1933,7 +1920,6 @@ func CSPlayerData(s *netlib.Session, packetid int, data interface{}, sid int64)
|
||||||
p.AppVersion = msg.GetAppVersion()
|
p.AppVersion = msg.GetAppVersion()
|
||||||
p.BuildVersion = msg.GetBuildVersion()
|
p.BuildVersion = msg.GetBuildVersion()
|
||||||
p.AppChannel = msg.GetAppChannel()
|
p.AppChannel = msg.GetAppChannel()
|
||||||
p.LastChannel = p.AppChannel
|
|
||||||
if (p.Channel == "" || p.Channel == "0") && p.Channel != msg.AppChannel {
|
if (p.Channel == "" || p.Channel == "0") && p.Channel != msg.AppChannel {
|
||||||
p.Channel = msg.AppChannel
|
p.Channel = msg.AppChannel
|
||||||
}
|
}
|
||||||
|
|
@ -2853,6 +2839,6 @@ func init() {
|
||||||
common.Register(int(player_proto.PlayerPacketID_PACKET_CSBillList), player_proto.CSBillList{}, CSBillList)
|
common.Register(int(player_proto.PlayerPacketID_PACKET_CSBillList), player_proto.CSBillList{}, CSBillList)
|
||||||
// 看广告一次
|
// 看广告一次
|
||||||
common.Register(int(player_proto.PlayerPacketID_PACKET_CSADV), player_proto.CSADV{}, CSADV)
|
common.Register(int(player_proto.PlayerPacketID_PACKET_CSADV), player_proto.CSADV{}, CSADV)
|
||||||
// 渠道开关
|
// 开启兑换的渠道
|
||||||
common.Register(int(player_proto.PlayerPacketID_PACKET_CSExchangeChannel), player_proto.CSExchangeChannel{}, CSExchangeChannel)
|
common.Register(int(player_proto.PlayerPacketID_PACKET_CSExchangeChannel), player_proto.CSExchangeChannel{}, CSExchangeChannel)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ func CSRMAward(s *netlib.Session, packetId int, data interface{}, sid int64) err
|
||||||
ItemId: v.Id,
|
ItemId: v.Id,
|
||||||
ItemNum: int64(v.Num),
|
ItemNum: int64(v.Num),
|
||||||
}
|
}
|
||||||
BagMgrSingleton.AddItems(p, []*Item{item}, 0, common.GainWay_RankMatch, "system", "段位奖励", 0, 0, false)
|
BagMgrSingleton.AddItems(p, []*Item{item}, 0, common.GainWay_RankReward, "system", "段位奖励", 0, 0, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"mongo.games.com/game/common"
|
||||||
|
"mongo.games.com/game/proto"
|
||||||
|
"mongo.games.com/game/protocol/activity"
|
||||||
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
"mongo.games.com/goserver/core/netlib"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ------------------------------------------------
|
||||||
|
type CSSignPacketFactory struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type CSSignHandler struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *CSSignPacketFactory) CreatePacket() interface{} {
|
||||||
|
pack := &activity.CSSign{}
|
||||||
|
return pack
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *CSSignHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||||
|
logger.Logger.Trace("CSSignHandler Process recv ", data)
|
||||||
|
if msg, ok := data.(*activity.CSSign); ok {
|
||||||
|
p := PlayerMgrSington.GetPlayer(sid)
|
||||||
|
if p == nil {
|
||||||
|
logger.Logger.Warn("CSSignHandler p == nil")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
pack := &activity.SCSign{}
|
||||||
|
pack.SignIndex = proto.Int32(msg.GetSignIndex())
|
||||||
|
pack.SignType = proto.Int32(msg.GetSignType())
|
||||||
|
|
||||||
|
retCode := ActSignMgrSington.CanSign(p, int(msg.GetSignIndex()))
|
||||||
|
if retCode != activity.OpResultCode_ActSign_OPRC_Activity_Sign_Sucess {
|
||||||
|
pack.OpRetCode = retCode
|
||||||
|
proto.SetDefaults(pack)
|
||||||
|
p.SendToClient(int(activity.ActSignPacketID_PACKET_SCSign), pack)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
retCode = ActSignMgrSington.Sign(p, int(msg.GetSignIndex()), msg.GetSignType())
|
||||||
|
if retCode != activity.OpResultCode_ActSign_OPRC_Activity_Sign_Sucess {
|
||||||
|
pack.OpRetCode = retCode
|
||||||
|
proto.SetDefaults(pack)
|
||||||
|
p.SendToClient(int(activity.ActSignPacketID_PACKET_SCSign), pack)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
pack.OpRetCode = activity.OpResultCode_ActSign_OPRC_Activity_Sign_Sucess
|
||||||
|
proto.SetDefaults(pack)
|
||||||
|
p.SendToClient(int(activity.ActSignPacketID_PACKET_SCSign), pack)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------
|
||||||
|
type CSSignDataPacketFactory struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type CSSignDataHandler struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *CSSignDataPacketFactory) CreatePacket() interface{} {
|
||||||
|
pack := &activity.CSSignData{}
|
||||||
|
return pack
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *CSSignDataHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||||
|
logger.Logger.Trace("CSSignDataHandler Process recv ", data)
|
||||||
|
if _, ok := data.(*activity.CSSignData); ok {
|
||||||
|
p := PlayerMgrSington.GetPlayer(sid)
|
||||||
|
if p == nil {
|
||||||
|
logger.Logger.Warn("CSSignDataHandler p == nil")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
ActSignMgrSington.SendSignDataToPlayer(p)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
//签到
|
||||||
|
common.RegisterHandler(int(activity.ActSignPacketID_PACKET_CSSign), &CSSignHandler{})
|
||||||
|
netlib.RegisterFactory(int(activity.ActSignPacketID_PACKET_CSSign), &CSSignPacketFactory{})
|
||||||
|
//签到数据
|
||||||
|
common.RegisterHandler(int(activity.ActSignPacketID_PACKET_CSSignData), &CSSignDataHandler{})
|
||||||
|
netlib.RegisterFactory(int(activity.ActSignPacketID_PACKET_CSSignData), &CSSignDataPacketFactory{})
|
||||||
|
}
|
||||||
|
|
@ -71,7 +71,7 @@ func IsTaskReward(p *Player, id int32) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendReward(p *Player, m map[int64]int64, tp int32) {
|
func SendReward(p *Player, m map[int64]int64) {
|
||||||
var items []*Item
|
var items []*Item
|
||||||
for k, v := range m {
|
for k, v := range m {
|
||||||
items = append(items, &Item{
|
items = append(items, &Item{
|
||||||
|
|
@ -79,20 +79,7 @@ func SendReward(p *Player, m map[int64]int64, tp int32) {
|
||||||
ItemNum: v,
|
ItemNum: v,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
gain := int32(0)
|
BagMgrSingleton.AddItems(p, items, 0, common.GainWay_TaskReward, "system", "任务奖励", 0, 0, false)
|
||||||
switch tp {
|
|
||||||
case 1:
|
|
||||||
gain = common.GainWayItemTaskEveryDay
|
|
||||||
case 2:
|
|
||||||
gain = common.GainWayItemWeekActive
|
|
||||||
case 3:
|
|
||||||
gain = common.GainWayItemTaskNewPlayer
|
|
||||||
case 4:
|
|
||||||
gain = common.GainWayItemTaskInvite
|
|
||||||
case 5:
|
|
||||||
gain = common.GainWayItemTaskAchievement
|
|
||||||
}
|
|
||||||
BagMgrSingleton.AddItems(p, items, 0, gain, "system", "任务奖励", 0, 0, false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func CSTaskList(s *netlib.Session, packetId int, data interface{}, sid int64) error {
|
func CSTaskList(s *netlib.Session, packetId int, data interface{}, sid int64) error {
|
||||||
|
|
@ -155,7 +142,7 @@ func CSTaskReward(s *netlib.Session, packetId int, data interface{}, sid int64)
|
||||||
p.WelfData.Task[msg.GetId()].Ts = time.Now().Unix()
|
p.WelfData.Task[msg.GetId()].Ts = time.Now().Unix()
|
||||||
data := srvdata.PBDB_TaskMgr.GetData(msg.GetId())
|
data := srvdata.PBDB_TaskMgr.GetData(msg.GetId())
|
||||||
if data != nil {
|
if data != nil {
|
||||||
SendReward(p, data.Award, msg.Tp)
|
SendReward(p, data.Award)
|
||||||
}
|
}
|
||||||
ret.OpCode = taskproto.OpResultCode_OPRC_Success
|
ret.OpCode = taskproto.OpResultCode_OPRC_Success
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -454,7 +454,7 @@ func (this *CSPigBankGetInfoHandler) Process(s *netlib.Session, packetid int, da
|
||||||
if _, ok := data.(*welfare.CSPigbankGetInfo); ok {
|
if _, ok := data.(*welfare.CSPigbankGetInfo); ok {
|
||||||
p := PlayerMgrSington.GetPlayer(sid)
|
p := PlayerMgrSington.GetPlayer(sid)
|
||||||
if p == nil {
|
if p == nil {
|
||||||
logger.Logger.Warnf("CSPigBankGetInfoHandler p == nil")
|
logger.Logger.Warnf("CSPigBankGetInfoHandler p == nil p.SnId = %v", p.SnId)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
WelfareMgrSington.PigbankGetInfo(p)
|
WelfareMgrSington.PigbankGetInfo(p)
|
||||||
|
|
@ -479,7 +479,7 @@ func (this *CSPigBankTakeCoinHandler) Process(s *netlib.Session, packetid int, d
|
||||||
if _, ok := data.(*welfare.CSPigbankTakeCoin); ok {
|
if _, ok := data.(*welfare.CSPigbankTakeCoin); ok {
|
||||||
p := PlayerMgrSington.GetPlayer(sid)
|
p := PlayerMgrSington.GetPlayer(sid)
|
||||||
if p == nil {
|
if p == nil {
|
||||||
logger.Logger.Warnf("CSPigBankTakeCoinHandler p == nil")
|
logger.Logger.Warnf("CSPigBankTakeCoinHandler p == nil p.SnId = %v", p.SnId)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
WelfareMgrSington.PigbankTakeCoin(p)
|
WelfareMgrSington.PigbankTakeCoin(p)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,14 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"mongo.games.com/game/common"
|
||||||
|
"mongo.games.com/game/webapi"
|
||||||
|
|
||||||
|
"encoding/json"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"mongo.games.com/game/model"
|
||||||
|
"mongo.games.com/goserver/core/logger"
|
||||||
"mongo.games.com/goserver/core/module"
|
"mongo.games.com/goserver/core/module"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -98,6 +104,33 @@ func (this *ActMgr) Init() {
|
||||||
if this.ConfigByPlateform == nil {
|
if this.ConfigByPlateform == nil {
|
||||||
this.ConfigByPlateform = make(map[string]*ActGivePlateformConfig)
|
this.ConfigByPlateform = make(map[string]*ActGivePlateformConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ApiResult struct {
|
||||||
|
Tag int
|
||||||
|
Msg []ActGivePlateformConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
//不使用etcd的情况下走api获取
|
||||||
|
if !model.GameParamData.UseEtcd {
|
||||||
|
buff, err := webapi.API_GetActConfig(common.GetAppId())
|
||||||
|
if err == nil {
|
||||||
|
ar := ApiResult{}
|
||||||
|
err = json.Unmarshal(buff, &ar)
|
||||||
|
if err == nil {
|
||||||
|
for _, plateformConfig := range ar.Msg {
|
||||||
|
t := plateformConfig
|
||||||
|
this.AddGiveConfig(&t, plateformConfig.Platform)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Logger.Error("Unmarshal ActMgr data error:", err, " buff:", string(buff))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Logger.Error("Init ActMgr list failed.")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
EtcdMgrSington.InitPlatformAct()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ActMgr) Update() {
|
func (this *ActMgr) Update() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,159 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/globalsign/mgo"
|
||||||
|
"mongo.games.com/game/common"
|
||||||
|
"mongo.games.com/game/model"
|
||||||
|
"mongo.games.com/game/proto"
|
||||||
|
"mongo.games.com/game/protocol/activity"
|
||||||
|
"mongo.games.com/game/protocol/server"
|
||||||
|
"mongo.games.com/game/srvdata"
|
||||||
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var ActSignMgrSington = &ActSignMgr{
|
||||||
|
SignConfigs: make(map[int]*server.DB_ActSign),
|
||||||
|
}
|
||||||
|
|
||||||
|
type ActSignMgr struct {
|
||||||
|
SignConfigs map[int]*server.DB_ActSign
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ActSignMgr) Init() {
|
||||||
|
if this.SignConfigs == nil {
|
||||||
|
this.SignConfigs = make(map[int]*server.DB_ActSign)
|
||||||
|
}
|
||||||
|
for _, v := range srvdata.PBDB_ActSignMgr.Datas.GetArr() {
|
||||||
|
this.SignConfigs[int(v.Id)] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ActSignMgr) GetConfig(id int) *server.DB_ActSign {
|
||||||
|
signConfig, ok := this.SignConfigs[id]
|
||||||
|
if ok {
|
||||||
|
return signConfig
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ActSignMgr) OnPlayerLogin(player *Player) error {
|
||||||
|
return this.RefixedPlayerData(player)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ActSignMgr) OnDayChanged(player *Player) error {
|
||||||
|
//跨天不需要
|
||||||
|
//this.RefixedPlayerData(player)
|
||||||
|
//this.SendSignDataToPlayer(player)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ActSignMgr) RefixedPlayerData(player *Player) error {
|
||||||
|
if player.IsRob {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if player.SignData == nil {
|
||||||
|
player.SignData = &model.SignData{
|
||||||
|
SignIndex: 0,
|
||||||
|
LastSignTickets: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ActSignMgr) SendSignDataToPlayer(player *Player) {
|
||||||
|
if player.IsRob {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
pack := &activity.SCSignData{}
|
||||||
|
//已经领取第几个
|
||||||
|
pack.SignCount = proto.Int(player.SignData.SignIndex)
|
||||||
|
if player.SignData.LastSignTickets != 0 {
|
||||||
|
lastSignTime := time.Unix(player.SignData.LastSignTickets, 0)
|
||||||
|
dayDiff := int32(common.DiffDay(time.Now(), lastSignTime))
|
||||||
|
if dayDiff == 0 {
|
||||||
|
pack.TodaySign = proto.Int32(1)
|
||||||
|
} else {
|
||||||
|
pack.TodaySign = proto.Int32(0)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pack.TodaySign = proto.Int32(0)
|
||||||
|
}
|
||||||
|
proto.SetDefaults(pack)
|
||||||
|
player.SendToClient(int(activity.ActSignPacketID_PACKET_SCSignData), pack)
|
||||||
|
logger.Logger.Trace("SCSignData: ", pack)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ActSignMgr) CanSign(player *Player, signIndex int) activity.OpResultCode_ActSign {
|
||||||
|
signConfig := this.GetConfig(signIndex)
|
||||||
|
if signConfig == nil {
|
||||||
|
return activity.OpResultCode_ActSign_OPRC_Activity_Sign_Error
|
||||||
|
}
|
||||||
|
|
||||||
|
if player.SignData.LastSignTickets != 0 {
|
||||||
|
lastSignTime := time.Unix(player.SignData.LastSignTickets, 0)
|
||||||
|
dayDiff := int32(common.DiffDay(time.Now(), lastSignTime))
|
||||||
|
if dayDiff == 0 {
|
||||||
|
if player.SignData.SignIndex == signIndex {
|
||||||
|
return activity.OpResultCode_ActSign_OPRC_Activity_Sign_Repeat
|
||||||
|
} else {
|
||||||
|
return activity.OpResultCode_ActSign_OPRC_Activity_Sign_Config_Day_Error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if player.SignData.SignIndex != (signIndex - 1) {
|
||||||
|
return activity.OpResultCode_ActSign_OPRC_Activity_Sign_Config_Day_Error
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if signIndex != 1 {
|
||||||
|
return activity.OpResultCode_ActSign_OPRC_Activity_Sign_Config_Day_Error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return activity.OpResultCode_ActSign_OPRC_Activity_Sign_Sucess
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ActSignMgr) Sign(player *Player, signIndex int, signType int32) activity.OpResultCode_ActSign {
|
||||||
|
errCode := this.CanSign(player, signIndex)
|
||||||
|
if errCode != activity.OpResultCode_ActSign_OPRC_Activity_Sign_Sucess {
|
||||||
|
return errCode
|
||||||
|
}
|
||||||
|
|
||||||
|
signConfig := this.GetConfig(signIndex)
|
||||||
|
if signConfig == nil {
|
||||||
|
return activity.OpResultCode_ActSign_OPRC_Activity_Sign_Error
|
||||||
|
}
|
||||||
|
|
||||||
|
player.SignData.LastSignTickets = time.Now().Unix()
|
||||||
|
player.SignData.SignIndex = signIndex
|
||||||
|
|
||||||
|
logger.Logger.Info("签到成功: ", signConfig)
|
||||||
|
grade := signConfig.Grade
|
||||||
|
switch signType {
|
||||||
|
case 0: //普通签到
|
||||||
|
case 1: //双倍签到
|
||||||
|
grade *= 2
|
||||||
|
}
|
||||||
|
switch signConfig.Type {
|
||||||
|
case 1: //金币
|
||||||
|
player.AddCoin(int64(grade), 0, common.GainWay_ActSign, strconv.Itoa(signIndex), time.Now().Format("2006-01-02 15:04:05"))
|
||||||
|
case 2: //钻石
|
||||||
|
player.AddDiamond(int64(grade), 0, common.GainWay_ActSign, strconv.Itoa(signIndex), time.Now().Format("2006-01-02 15:04:05"))
|
||||||
|
case 3: //道具
|
||||||
|
item := &Item{
|
||||||
|
ItemId: signConfig.Item_Id,
|
||||||
|
ItemNum: int64(grade),
|
||||||
|
}
|
||||||
|
BagMgrSingleton.AddItems(player, []*Item{item}, 0, common.GainWay_ActSign, strconv.Itoa(signIndex), time.Now().Format("2006-01-02 15:04:05"), 0, 0, false)
|
||||||
|
}
|
||||||
|
return activity.OpResultCode_ActSign_OPRC_Activity_Sign_Sucess
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
mgo.SetStats(true)
|
||||||
|
RegisterParallelLoadFunc("14日签到", func() error {
|
||||||
|
ActSignMgrSington.Init()
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -256,11 +256,9 @@ func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int
|
||||||
|
|
||||||
// 道具日志
|
// 道具日志
|
||||||
if !noLog {
|
if !noLog {
|
||||||
num := v.ItemNum
|
|
||||||
logType := ItemObtain
|
logType := ItemObtain
|
||||||
if v.ItemNum < 0 {
|
if v.ItemNum < 0 {
|
||||||
logType = ItemConsume
|
logType = ItemConsume
|
||||||
num = -v.ItemNum
|
|
||||||
}
|
}
|
||||||
log := model.NewItemLogEx(model.ItemParam{
|
log := model.NewItemLogEx(model.ItemParam{
|
||||||
Platform: p.Platform,
|
Platform: p.Platform,
|
||||||
|
|
@ -268,7 +266,7 @@ func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int
|
||||||
LogType: int32(logType),
|
LogType: int32(logType),
|
||||||
ItemId: v.ItemId,
|
ItemId: v.ItemId,
|
||||||
ItemName: item.Name,
|
ItemName: item.Name,
|
||||||
Count: num,
|
Count: v.ItemNum,
|
||||||
Remark: remark,
|
Remark: remark,
|
||||||
TypeId: gainWay,
|
TypeId: gainWay,
|
||||||
GameId: gameId,
|
GameId: gameId,
|
||||||
|
|
@ -279,7 +277,7 @@ func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.ItemId == common.ItemIDWeekScore && v.ItemNum > 0 {
|
if v.ItemId == common.ItemIDWeekScore && v.ItemNum != 0 {
|
||||||
TaskSubjectSingleton.Touch(common.TaskTypeActivityScore, &TaskData{
|
TaskSubjectSingleton.Touch(common.TaskTypeActivityScore, &TaskData{
|
||||||
SnId: p.SnId,
|
SnId: p.SnId,
|
||||||
Num: v.ItemNum,
|
Num: v.ItemNum,
|
||||||
|
|
@ -337,11 +335,9 @@ func (this *BagMgr) AddItemsOffline(platform string, snid int32, addItems []*Ite
|
||||||
if itemData == nil {
|
if itemData == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
num := v.ItemNum
|
|
||||||
logType := ItemObtain
|
logType := ItemObtain
|
||||||
if v.ItemNum < 0 {
|
if v.ItemNum < 0 {
|
||||||
logType = ItemConsume
|
logType = ItemConsume
|
||||||
num = -v.ItemNum
|
|
||||||
}
|
}
|
||||||
log := model.NewItemLogEx(model.ItemParam{
|
log := model.NewItemLogEx(model.ItemParam{
|
||||||
Platform: findPlayer.Platform,
|
Platform: findPlayer.Platform,
|
||||||
|
|
@ -349,7 +345,7 @@ func (this *BagMgr) AddItemsOffline(platform string, snid int32, addItems []*Ite
|
||||||
LogType: int32(logType),
|
LogType: int32(logType),
|
||||||
ItemId: v.ItemId,
|
ItemId: v.ItemId,
|
||||||
ItemName: itemData.Name,
|
ItemName: itemData.Name,
|
||||||
Count: num,
|
Count: v.ItemNum,
|
||||||
Remark: remark,
|
Remark: remark,
|
||||||
TypeId: gainWay,
|
TypeId: gainWay,
|
||||||
GameId: gameId,
|
GameId: gameId,
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,34 @@ const (
|
||||||
BlackState_Max
|
BlackState_Max
|
||||||
)
|
)
|
||||||
|
|
||||||
var BlackListMgrSington = NewBlackListMgr()
|
var BlackListMgrSington = &BlackListMgr{
|
||||||
|
BlackList: make(map[int32]*BlackInfo),
|
||||||
|
}
|
||||||
|
|
||||||
|
type BlackListMgr struct {
|
||||||
|
BlackList map[int32]*BlackInfo
|
||||||
|
BlackListByPlatform [BlackState_Max]map[string]map[int32]*BlackInfo
|
||||||
|
AlipayAccByPlatform [BlackState_Max]map[string]map[string]*BlackInfo
|
||||||
|
AlipayNameByPlatform [BlackState_Max]map[string]map[string]*BlackInfo
|
||||||
|
BankcardByPlatform [BlackState_Max]map[string]map[string]*BlackInfo
|
||||||
|
IpByPlatform [BlackState_Max]map[string]map[string]*BlackInfo
|
||||||
|
IpNetByPlatform [BlackState_Max]map[string][]*BlackInfo
|
||||||
|
PackageTagByPlatform [BlackState_Max]map[string]*BlackInfo
|
||||||
|
DeviceByPlatform [BlackState_Max]map[string]map[string]*BlackInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
type BlackInfo struct {
|
||||||
|
Id int32
|
||||||
|
BlackType int //1.游戏2.兑换3.充值4.比赛
|
||||||
|
Alipay_account string
|
||||||
|
Alipay_name string
|
||||||
|
Bankcard string
|
||||||
|
Ip string //support like "192.0.2.0/24" or "2001:db8::/32", as defined in RFC 4632 and RFC 4291.
|
||||||
|
Platform string
|
||||||
|
PackageTag string
|
||||||
|
DeviceId string //设备ID
|
||||||
|
ipNet *net.IPNet
|
||||||
|
}
|
||||||
|
|
||||||
type BlackInfoApi struct {
|
type BlackInfoApi struct {
|
||||||
Id int32
|
Id int32
|
||||||
|
|
@ -35,46 +62,26 @@ type BlackInfoApi struct {
|
||||||
DeviceId string //设备ID
|
DeviceId string //设备ID
|
||||||
}
|
}
|
||||||
|
|
||||||
type BlackInfo struct {
|
func (this *BlackListMgr) Init() {
|
||||||
Id int32
|
if this.BlackList == nil {
|
||||||
BlackType int //1.游戏2.兑换3.充值4.比赛
|
this.BlackList = make(map[int32]*BlackInfo)
|
||||||
Alipay_account string
|
|
||||||
Alipay_name string
|
|
||||||
Bankcard string
|
|
||||||
Ip string //support like "192.0.2.0/24" or "2001:db8::/32", as defined in RFC 4632 and RFC 4291.
|
|
||||||
Platform string
|
|
||||||
PackageTag string
|
|
||||||
DeviceId string //设备ID
|
|
||||||
ipNet *net.IPNet
|
|
||||||
}
|
|
||||||
|
|
||||||
type BlackListMgr struct {
|
|
||||||
BlackList map[int32]*BlackInfo
|
|
||||||
BlackListByPlatform [BlackState_Max]map[string]map[int32]*BlackInfo
|
|
||||||
AlipayAccByPlatform [BlackState_Max]map[string]map[string]*BlackInfo
|
|
||||||
AlipayNameByPlatform [BlackState_Max]map[string]map[string]*BlackInfo
|
|
||||||
BankcardByPlatform [BlackState_Max]map[string]map[string]*BlackInfo
|
|
||||||
IpByPlatform [BlackState_Max]map[string]map[string]*BlackInfo
|
|
||||||
IpNetByPlatform [BlackState_Max]map[string][]*BlackInfo
|
|
||||||
PackageTagByPlatform [BlackState_Max]map[string]*BlackInfo
|
|
||||||
DeviceByPlatform [BlackState_Max]map[string]map[string]*BlackInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewBlackListMgr() *BlackListMgr {
|
|
||||||
ret := &BlackListMgr{
|
|
||||||
BlackList: make(map[int32]*BlackInfo),
|
|
||||||
}
|
}
|
||||||
for i := uint(0); i < BlackState_Max; i++ {
|
for i := uint(0); i < BlackState_Max; i++ {
|
||||||
ret.BlackListByPlatform[i] = make(map[string]map[int32]*BlackInfo)
|
this.BlackListByPlatform[i] = make(map[string]map[int32]*BlackInfo)
|
||||||
ret.AlipayAccByPlatform[i] = make(map[string]map[string]*BlackInfo)
|
this.AlipayAccByPlatform[i] = make(map[string]map[string]*BlackInfo)
|
||||||
ret.AlipayNameByPlatform[i] = make(map[string]map[string]*BlackInfo)
|
this.AlipayNameByPlatform[i] = make(map[string]map[string]*BlackInfo)
|
||||||
ret.BankcardByPlatform[i] = make(map[string]map[string]*BlackInfo)
|
this.BankcardByPlatform[i] = make(map[string]map[string]*BlackInfo)
|
||||||
ret.IpByPlatform[i] = make(map[string]map[string]*BlackInfo)
|
this.IpByPlatform[i] = make(map[string]map[string]*BlackInfo)
|
||||||
ret.IpNetByPlatform[i] = make(map[string][]*BlackInfo)
|
this.IpNetByPlatform[i] = make(map[string][]*BlackInfo)
|
||||||
ret.PackageTagByPlatform[i] = make(map[string]*BlackInfo)
|
this.PackageTagByPlatform[i] = make(map[string]*BlackInfo)
|
||||||
ret.DeviceByPlatform[i] = make(map[string]map[string]*BlackInfo)
|
this.DeviceByPlatform[i] = make(map[string]map[string]*BlackInfo)
|
||||||
}
|
}
|
||||||
return ret
|
if !model.GameParamData.UseEtcd {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
EtcdMgrSington.InitBlackList()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *BlackListMgr) DivBlackInfo(blackInfo *BlackInfo) {
|
func (this *BlackListMgr) DivBlackInfo(blackInfo *BlackInfo) {
|
||||||
|
|
@ -531,4 +538,8 @@ func (this *BlackListMgr) CheckDeviceInBlackByPlatfrom(deviceId string, blackTyp
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
mgo.SetStats(true)
|
mgo.SetStats(true)
|
||||||
|
RegisterParallelLoadFunc("平台黑名单", func() error {
|
||||||
|
BlackListMgrSington.Init()
|
||||||
|
return nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"mongo.games.com/game/model"
|
||||||
webapi_proto "mongo.games.com/game/protocol/webapi"
|
webapi_proto "mongo.games.com/game/protocol/webapi"
|
||||||
"mongo.games.com/goserver/core/module"
|
"mongo.games.com/goserver/core/module"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
@ -22,7 +23,11 @@ func (this *ChessRankMgr) ModuleName() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ChessRankMgr) Init() {
|
func (this *ChessRankMgr) Init() {
|
||||||
|
if !model.GameParamData.UseEtcd {
|
||||||
|
// 后台说现在没有不走ETCD情况~
|
||||||
|
} else {
|
||||||
|
EtcdMgrSington.InitUpdateChessRankcfg()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ChessRankMgr) UpdateChessRankConfig(cfg *webapi_proto.ChessRankcfgData) {
|
func (this *ChessRankMgr) UpdateChessRankConfig(cfg *webapi_proto.ChessRankcfgData) {
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@ var CoinSceneMgrSingleton = &CoinSceneMgr{
|
||||||
playerChanging: make(map[int32]int32),
|
playerChanging: make(map[int32]int32),
|
||||||
//按平台管理
|
//按平台管理
|
||||||
scenesOfPlatform: make(map[string]map[int32]*CoinScenePool),
|
scenesOfPlatform: make(map[string]map[int32]*CoinScenePool),
|
||||||
platformOfScene: make(map[int]string),
|
platformOfScene: make(map[int32]string),
|
||||||
//按组管理
|
//按组管理
|
||||||
scenesOfGroup: make(map[int32]map[int32]*CoinScenePool),
|
scenesOfGroup: make(map[int32]map[int32]*CoinScenePool),
|
||||||
groupOfScene: make(map[int]int32),
|
groupOfScene: make(map[int32]int32),
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateRoomCache struct {
|
type CreateRoomCache struct {
|
||||||
|
|
@ -39,14 +39,14 @@ type CoinSceneMgr struct {
|
||||||
|
|
||||||
//按平台管理
|
//按平台管理
|
||||||
scenesOfPlatform map[string]map[int32]*CoinScenePool // platform:gamefreeid
|
scenesOfPlatform map[string]map[int32]*CoinScenePool // platform:gamefreeid
|
||||||
platformOfScene map[int]string // sceneid:platform; 创建房间后记录房间所在平台
|
platformOfScene map[int32]string // sceneid:platform; 创建房间后记录房间所在平台
|
||||||
|
|
||||||
//按组管理
|
//按组管理
|
||||||
scenesOfGroup map[int32]map[int32]*CoinScenePool // groupid:gamefreeid
|
scenesOfGroup map[int32]map[int32]*CoinScenePool // groupid:gamefreeid
|
||||||
groupOfScene map[int]int32 // sceneid:groupid;
|
groupOfScene map[int32]int32 // sceneid:groupid;
|
||||||
|
|
||||||
//延迟创建房间列表
|
//延迟创建房间列表
|
||||||
delayCache []*CreateRoomCache // 待预创建房间
|
delayCache []CreateRoomCache // 待预创建房间
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCoinScenePool 获取一个场景池
|
// GetCoinScenePool 获取一个场景池
|
||||||
|
|
@ -72,33 +72,29 @@ func (csm *CoinSceneMgr) GetCoinScenePool(plt string, id int32) *CoinScenePool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if gf.GetDbGameFree() == nil {
|
var dbGameFree *server_proto.DB_GameFree
|
||||||
|
if groupId != 0 {
|
||||||
|
conf := PlatformGameGroupMgrSington.GetGameGroup(groupId)
|
||||||
|
if conf != nil {
|
||||||
|
dbGameFree = conf.GetDbGameFree()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if dbGameFree == nil {
|
||||||
|
dbGameFree = gf.GetDbGameFree()
|
||||||
|
}
|
||||||
|
if dbGameFree == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建了一个新的
|
// 创建了一个新的
|
||||||
// 应该是走不到这里,因为模块启动时所有场次都创建了房间池
|
// 应该是走不到这里,因为模块启动时所有场次都创建了房间池
|
||||||
pool := newCoinScenePool(plt, groupId, gf.GetDbGameFree())
|
return NewCoinScenePool(plt, groupId, dbGameFree)
|
||||||
if groupId != 0 {
|
|
||||||
v, ok := csm.scenesOfGroup[groupId]
|
|
||||||
if !ok || v == nil {
|
|
||||||
csm.scenesOfGroup[groupId] = make(map[int32]*CoinScenePool)
|
|
||||||
}
|
|
||||||
csm.scenesOfGroup[groupId][id] = pool
|
|
||||||
} else {
|
|
||||||
v, ok := csm.scenesOfPlatform[plt]
|
|
||||||
if !ok || v == nil {
|
|
||||||
csm.scenesOfPlatform[plt] = make(map[int32]*CoinScenePool)
|
|
||||||
}
|
|
||||||
csm.scenesOfPlatform[plt][id] = pool
|
|
||||||
}
|
|
||||||
return pool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (csm *CoinSceneMgr) findCoinScenePool(platform string, id int32) (pools map[int32]*CoinScenePool, groupID int32,
|
func (csm *CoinSceneMgr) findCoinScenePool(platform string, id int32) (pools map[int32]*CoinScenePool, groupID int32,
|
||||||
dbGameFree *server.DB_GameFree) {
|
dbGameFree *server.DB_GameFree) {
|
||||||
gf := PlatformMgrSingleton.GetGameFree(platform, id)
|
gf := PlatformMgrSingleton.GetGameFree(platform, id)
|
||||||
if gf == nil || gf.GetDbGameFree() == nil {
|
if gf == nil {
|
||||||
return nil, 0, nil
|
return nil, 0, nil
|
||||||
}
|
}
|
||||||
groupId := gf.GetGroupId()
|
groupId := gf.GetGroupId()
|
||||||
|
|
@ -106,24 +102,31 @@ func (csm *CoinSceneMgr) findCoinScenePool(platform string, id int32) (pools map
|
||||||
var ss map[int32]*CoinScenePool
|
var ss map[int32]*CoinScenePool
|
||||||
var ok bool
|
var ok bool
|
||||||
if groupId != 0 {
|
if groupId != 0 {
|
||||||
|
pgg := PlatformGameGroupMgrSington.GetGameGroup(groupId)
|
||||||
|
if pgg != nil {
|
||||||
ss, ok = csm.scenesOfGroup[groupId]
|
ss, ok = csm.scenesOfGroup[groupId]
|
||||||
if !ok {
|
if !ok {
|
||||||
ss = make(map[int32]*CoinScenePool)
|
ss = make(map[int32]*CoinScenePool)
|
||||||
csm.scenesOfGroup[groupId] = ss
|
csm.scenesOfGroup[groupId] = ss
|
||||||
}
|
}
|
||||||
return ss, groupId, gf.GetDbGameFree()
|
return ss, groupId, pgg.GetDbGameFree()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ss == nil {
|
||||||
ss, ok = csm.scenesOfPlatform[platform]
|
ss, ok = csm.scenesOfPlatform[platform]
|
||||||
if !ok {
|
if !ok {
|
||||||
ss = make(map[int32]*CoinScenePool)
|
ss = make(map[int32]*CoinScenePool)
|
||||||
csm.scenesOfPlatform[platform] = ss
|
csm.scenesOfPlatform[platform] = ss
|
||||||
}
|
}
|
||||||
return ss, 0, gf.GetDbGameFree()
|
return ss, 0, gf.GetDbGameFree()
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PlayerEnter 玩家进入房间池
|
// PlayerEnter 玩家进入房间池
|
||||||
func (csm *CoinSceneMgr) PlayerEnter(p *Player, id int32, roomId int32, exclude []int32, isChangeRoom bool) hall_proto.OpResultCode {
|
func (csm *CoinSceneMgr) PlayerEnter(p *Player, id int32, roomId int32, exclude []int32, ischangeroom bool) hall_proto.OpResultCode {
|
||||||
logger.Logger.Tracef("(csm *CoinSceneMgr) PlayerEnter snid:%v id:%v roomid:%v exclude:%v", p.SnId, id, roomId, exclude)
|
logger.Logger.Tracef("(csm *CoinSceneMgr) PlayerEnter snid:%v id:%v roomid:%v exclude:%v", p.SnId, id, roomId, exclude)
|
||||||
if p.isDelete { //删档用户不让进游戏
|
if p.isDelete { //删档用户不让进游戏
|
||||||
return hall_proto.OpResultCode_OPRC_RoomHadClosed
|
return hall_proto.OpResultCode_OPRC_RoomHadClosed
|
||||||
|
|
@ -141,9 +144,22 @@ func (csm *CoinSceneMgr) PlayerEnter(p *Player, id int32, roomId int32, exclude
|
||||||
return hall_proto.OpResultCode_OPRC_Error
|
return hall_proto.OpResultCode_OPRC_Error
|
||||||
}
|
}
|
||||||
|
|
||||||
csp := csm.GetCoinScenePool(platform.IdStr, id)
|
pools, groupID, free := csm.findCoinScenePool(platform.IdStr, id)
|
||||||
|
if pools == nil {
|
||||||
|
return hall_proto.OpResultCode_OPRC_RoomHadClosed
|
||||||
|
}
|
||||||
|
|
||||||
ret := csp.PlayerEnter(p, roomId, exclude, isChangeRoom)
|
csp, ok := pools[id]
|
||||||
|
if !ok || csp == nil {
|
||||||
|
csp = NewCoinScenePool(platform.IdStr, groupID, free)
|
||||||
|
if csp == nil {
|
||||||
|
logger.Logger.Warnf("(csm *CoinSceneMgr) PlayerEnter snid:%v find in id:%v exclude:%v NewCoinScenePool failed", p.SnId, id, exclude)
|
||||||
|
return hall_proto.OpResultCode_OPRC_Error
|
||||||
|
}
|
||||||
|
pools[id] = csp
|
||||||
|
}
|
||||||
|
|
||||||
|
ret := csp.PlayerEnter(p, roomId, exclude, ischangeroom)
|
||||||
|
|
||||||
logger.Logger.Warnf("(csm *CoinSceneMgr) PlayerEnter snid:%v find in id:%v exclude:%v return false", p.SnId, id, exclude)
|
logger.Logger.Warnf("(csm *CoinSceneMgr) PlayerEnter snid:%v find in id:%v exclude:%v return false", p.SnId, id, exclude)
|
||||||
return ret
|
return ret
|
||||||
|
|
@ -228,28 +244,28 @@ func (csm *CoinSceneMgr) PlayerLeave(p *Player, reason int) bool {
|
||||||
// OnDestroyScene 解散房间
|
// OnDestroyScene 解散房间
|
||||||
// sceneId 房间id
|
// sceneId 房间id
|
||||||
func (csm *CoinSceneMgr) OnDestroyScene(sceneId int) {
|
func (csm *CoinSceneMgr) OnDestroyScene(sceneId int) {
|
||||||
if platformName, ok := csm.platformOfScene[sceneId]; ok {
|
if platformName, ok := csm.platformOfScene[int32(sceneId)]; ok {
|
||||||
if ss, ok := csm.scenesOfPlatform[platformName]; ok {
|
if ss, ok := csm.scenesOfPlatform[platformName]; ok {
|
||||||
for _, csp := range ss {
|
for _, csp := range ss {
|
||||||
csp.OnDestroyScene(sceneId)
|
csp.OnDestroyScene(sceneId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete(csm.platformOfScene, sceneId)
|
delete(csm.platformOfScene, int32(sceneId))
|
||||||
}
|
}
|
||||||
|
|
||||||
if groupId, ok := csm.groupOfScene[sceneId]; ok {
|
if groupId, ok := csm.groupOfScene[int32(sceneId)]; ok {
|
||||||
if ss, ok := csm.scenesOfGroup[groupId]; ok {
|
if ss, ok := csm.scenesOfGroup[groupId]; ok {
|
||||||
for _, csp := range ss {
|
for _, csp := range ss {
|
||||||
csp.OnDestroyScene(sceneId)
|
csp.OnDestroyScene(sceneId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete(csm.groupOfScene, sceneId)
|
delete(csm.groupOfScene, int32(sceneId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPlatformBySceneId 获取房间所在平台
|
// GetPlatformBySceneId 获取房间所在平台
|
||||||
func (csm *CoinSceneMgr) GetPlatformBySceneId(sceneId int) string {
|
func (csm *CoinSceneMgr) GetPlatformBySceneId(sceneId int) string {
|
||||||
if platformName, ok := csm.platformOfScene[sceneId]; ok {
|
if platformName, ok := csm.platformOfScene[int32(sceneId)]; ok {
|
||||||
return platformName
|
return platformName
|
||||||
}
|
}
|
||||||
s := SceneMgrSingleton.GetScene(sceneId)
|
s := SceneMgrSingleton.GetScene(sceneId)
|
||||||
|
|
@ -401,19 +417,76 @@ func (csm *CoinSceneMgr) StartChangeCoinSceneTransact(p *Player, id int32, exclu
|
||||||
return hall_proto.OpResultCode_OPRC_Error
|
return hall_proto.OpResultCode_OPRC_Error
|
||||||
}
|
}
|
||||||
|
|
||||||
// TouchCreateRoom 触发预创建房间
|
// ListRooms 给客户端发送场次房间列表
|
||||||
// 1.模块启动后触发
|
// id 场次id
|
||||||
// 2.游戏服建立连接后触发
|
func (csm *CoinSceneMgr) ListRooms(p *Player, id int32) bool {
|
||||||
// 3.房间解散后触发
|
//多平台支持
|
||||||
// 4.场次配置更新后
|
platform := p.GetPlatform()
|
||||||
func (csm *CoinSceneMgr) TouchCreateRoom(platform string, gameFreeId int32) {
|
if platform == nil {
|
||||||
gf := PlatformMgrSingleton.GetGameFree(platform, gameFreeId)
|
return false
|
||||||
if gf.Status && gf.DbGameFree.GetCreateRoomNum() > 0 {
|
}
|
||||||
logger.Logger.Tracef("TouchCreateRoom platform:%v gameFreeId:%v", platform, gameFreeId)
|
|
||||||
csm.delayCache = append(csm.delayCache, &CreateRoomCache{
|
pools, groupID, free := csm.findCoinScenePool(platform.IdStr, id)
|
||||||
platformName: platform,
|
if pools == nil {
|
||||||
gameFreeId: gameFreeId,
|
return false
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if csp, ok := pools[id]; ok && csp != nil {
|
||||||
|
return csp.ListRoom(p)
|
||||||
|
}
|
||||||
|
csp := NewCoinScenePool(platform.IdStr, groupID, free)
|
||||||
|
if csp == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
pools[id] = csp
|
||||||
|
return csp.ListRoom(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateRoomByCache 创建预创建房间
|
||||||
|
// 每2秒创建一次
|
||||||
|
func (csm *CoinSceneMgr) CreateRoomByCache() {
|
||||||
|
cnt := len(csm.delayCache)
|
||||||
|
if cnt > 0 {
|
||||||
|
data := csm.delayCache[cnt-1]
|
||||||
|
csm.delayCache = csm.delayCache[:cnt-1]
|
||||||
|
pdd := PlatformMgrSingleton.GetGameFree(data.platformName, data.gameFreeId)
|
||||||
|
//对战场和捕鱼场 预创建
|
||||||
|
if pdd != nil && pdd.DbGameFree != nil {
|
||||||
|
var ss map[int32]*CoinScenePool
|
||||||
|
var ok bool
|
||||||
|
//分组模式
|
||||||
|
if pdd.GroupId != 0 {
|
||||||
|
pgg := PlatformGameGroupMgrSington.GetGameGroup(pdd.GroupId)
|
||||||
|
if pgg != nil {
|
||||||
|
ss, ok = csm.scenesOfGroup[pdd.GroupId]
|
||||||
|
if !ok {
|
||||||
|
ss = make(map[int32]*CoinScenePool)
|
||||||
|
csm.scenesOfGroup[pdd.GroupId] = ss
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//独立模式
|
||||||
|
if ss == nil {
|
||||||
|
ss, ok = csm.scenesOfPlatform[data.platformName]
|
||||||
|
if !ok {
|
||||||
|
ss = make(map[int32]*CoinScenePool)
|
||||||
|
csm.scenesOfPlatform[data.platformName] = ss
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ss == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if csp, ok := ss[pdd.DbGameFree.Id]; ok && csp != nil {
|
||||||
|
csp.PreCreateRoom()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
csp := NewCoinScenePool(data.platformName, 0, pdd.DbGameFree)
|
||||||
|
if csp != nil {
|
||||||
|
ss[pdd.DbGameFree.Id] = csp
|
||||||
|
csp.PreCreateRoom()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -422,14 +495,42 @@ func (csm *CoinSceneMgr) ModuleName() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (csm *CoinSceneMgr) Init() {
|
func (csm *CoinSceneMgr) Init() {
|
||||||
// 房间池初始化
|
// 场次池预创建
|
||||||
for _, platform := range PlatformMgrSingleton.GetPlatforms() {
|
for _, platform := range PlatformMgrSingleton.GetPlatforms() {
|
||||||
if platform.Isolated || platform.IdStr == "" {
|
if platform.Isolated || platform.IdStr == "" {
|
||||||
for _, v := range srvdata.PBDB_GameFreeMgr.Datas.GetArr() {
|
arr := srvdata.PBDB_GameFreeMgr.Datas.GetArr()
|
||||||
gps := PlatformMgrSingleton.GetGameFree(platform.IdStr, v.GetId())
|
for _, dbGame := range arr {
|
||||||
|
gps := PlatformMgrSingleton.GetGameFree(platform.IdStr, dbGame.GetId())
|
||||||
if gps != nil {
|
if gps != nil {
|
||||||
csm.GetCoinScenePool(platform.IdStr, v.GetId())
|
// dbGameFree
|
||||||
csm.TouchCreateRoom(platform.IdStr, v.GetId())
|
dbGameFree := gps.DbGameFree
|
||||||
|
if gps.GroupId != 0 {
|
||||||
|
pgg := PlatformGameGroupMgrSington.GetGameGroup(gps.GroupId)
|
||||||
|
if pgg != nil {
|
||||||
|
dbGameFree = pgg.DbGameFree
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// CoinScenePool
|
||||||
|
csp := NewCoinScenePool(platform.IdStr, gps.GroupId, dbGameFree)
|
||||||
|
if csp != nil {
|
||||||
|
if gps.GroupId != 0 {
|
||||||
|
if ss, exist := csm.scenesOfGroup[gps.GroupId]; exist {
|
||||||
|
ss[dbGame.GetId()] = csp
|
||||||
|
} else {
|
||||||
|
ss = make(map[int32]*CoinScenePool)
|
||||||
|
ss[dbGame.GetId()] = csp
|
||||||
|
csm.scenesOfGroup[gps.GroupId] = ss
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ss, exist := csm.scenesOfPlatform[platform.IdStr]; exist {
|
||||||
|
ss[dbGame.GetId()] = csp
|
||||||
|
} else {
|
||||||
|
ss = make(map[int32]*CoinScenePool)
|
||||||
|
ss[dbGame.GetId()] = csp
|
||||||
|
csm.scenesOfPlatform[platform.IdStr] = ss
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -437,18 +538,8 @@ func (csm *CoinSceneMgr) Init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (csm *CoinSceneMgr) Update() {
|
func (csm *CoinSceneMgr) Update() {
|
||||||
cnt := len(csm.delayCache)
|
// 预创建房间
|
||||||
if cnt > 0 {
|
csm.CreateRoomByCache()
|
||||||
data := csm.delayCache[cnt-1]
|
|
||||||
csm.delayCache = csm.delayCache[:cnt-1]
|
|
||||||
gf := PlatformMgrSingleton.GetGameFree(data.platformName, data.gameFreeId)
|
|
||||||
if gf != nil && gf.DbGameFree != nil {
|
|
||||||
csp := csm.GetCoinScenePool(data.platformName, data.gameFreeId)
|
|
||||||
if csp != nil {
|
|
||||||
csp.PreCreateRoom()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (csm *CoinSceneMgr) Shutdown() {
|
func (csm *CoinSceneMgr) Shutdown() {
|
||||||
|
|
@ -458,15 +549,24 @@ func (csm *CoinSceneMgr) Shutdown() {
|
||||||
//=====================PlatformObserver======================
|
//=====================PlatformObserver======================
|
||||||
|
|
||||||
func (this *CoinSceneMgr) OnPlatformCreate(p *Platform) {
|
func (this *CoinSceneMgr) OnPlatformCreate(p *Platform) {
|
||||||
|
if p.IdStr == DefaultPlatform {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//获取配置
|
||||||
|
gps := PlatformMgrSingleton.GetGameFrees(p.IdStr)
|
||||||
|
for _, v := range gps {
|
||||||
|
if v.Status && v.DbGameFree.GetCreateRoomNum() > 0 {
|
||||||
|
this.delayCache = append(this.delayCache, CreateRoomCache{gameFreeId: v.DbGameFree.Id, platformName: p.IdStr})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CoinSceneMgr) OnPlatformDestroy(p *Platform) {
|
func (this *CoinSceneMgr) OnPlatformDestroy(p *Platform) {
|
||||||
if p == nil {
|
if p == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if v, ok := this.scenesOfPlatform[p.IdStr]; ok {
|
if csps, ok := this.scenesOfPlatform[p.IdStr]; ok {
|
||||||
for _, csp := range v {
|
for _, csp := range csps {
|
||||||
pack := &server_proto.WGGraceDestroyScene{}
|
pack := &server_proto.WGGraceDestroyScene{}
|
||||||
for _, scene := range csp.scenes {
|
for _, scene := range csp.scenes {
|
||||||
pack.Ids = append(pack.Ids, int32(scene.sceneId))
|
pack.Ids = append(pack.Ids, int32(scene.sceneId))
|
||||||
|
|
@ -477,6 +577,12 @@ func (this *CoinSceneMgr) OnPlatformDestroy(p *Platform) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *CoinSceneMgr) OnPlatformChangeIsolated(p *Platform, isolated bool) {
|
||||||
|
if !isolated {
|
||||||
|
this.OnPlatformDestroy(p)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (this *CoinSceneMgr) OnPlatformChangeDisabled(p *Platform, disabled bool) {
|
func (this *CoinSceneMgr) OnPlatformChangeDisabled(p *Platform, disabled bool) {
|
||||||
if disabled {
|
if disabled {
|
||||||
this.OnPlatformDestroy(p)
|
this.OnPlatformDestroy(p)
|
||||||
|
|
@ -507,7 +613,13 @@ func (this *CoinSceneMgr) OnPlatformGameFreeUpdate(p *Platform, oldCfg, newCfg *
|
||||||
}
|
}
|
||||||
srvlib.ServerSessionMgrSington.Broadcast(int(server_proto.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE),
|
srvlib.ServerSessionMgrSington.Broadcast(int(server_proto.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE),
|
||||||
pack, common.GetSelfAreaId(), srvlib.GameServerType)
|
pack, common.GetSelfAreaId(), srvlib.GameServerType)
|
||||||
this.TouchCreateRoom(p.IdStr, newCfg.DbGameFree.Id)
|
|
||||||
|
//预创建房间配置更新
|
||||||
|
if newCfg.DbGameFree.GetCreateRoomNum() != 0 && p.IdStr != DefaultPlatform && newCfg.Status {
|
||||||
|
logger.Logger.Tracef(">>>预创建房间 platform:%v %v_%v gamefreeid:%v CreateRoomNum:%v", p.Name,
|
||||||
|
newCfg.DbGameFree.GetName(), newCfg.DbGameFree.GetTitle(), newCfg.DbGameFree.GetId(), newCfg.DbGameFree.GetCreateRoomNum())
|
||||||
|
this.delayCache = append(this.delayCache, CreateRoomCache{gameFreeId: newCfg.DbGameFree.GetId(), platformName: p.IdStr})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -571,8 +683,8 @@ func (csm *CoinSceneMgr) OnGameSessionRegiste(gs *GameSession) {
|
||||||
//获取配置
|
//获取配置
|
||||||
gps := PlatformMgrSingleton.GetGameFrees(platform.IdStr)
|
gps := PlatformMgrSingleton.GetGameFrees(platform.IdStr)
|
||||||
for _, v := range gps {
|
for _, v := range gps {
|
||||||
if v != nil && (wildGs || common.InSliceInt32(gs.gameIds, v.DbGameFree.GetGameId())) {
|
if v.Status && v.DbGameFree.GetCreateRoomNum() > 0 && (wildGs || common.InSliceInt32(gs.gameIds, v.DbGameFree.GetGameId())) {
|
||||||
csm.TouchCreateRoom(platform.IdStr, v.DbGameFree.Id)
|
csm.delayCache = append(csm.delayCache, CreateRoomCache{gameFreeId: v.DbGameFree.Id, platformName: platform.IdStr})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"mongo.games.com/game/common"
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
gamehallproto "mongo.games.com/game/protocol/gamehall"
|
"mongo.games.com/game/proto"
|
||||||
serverproto "mongo.games.com/game/protocol/server"
|
gamehall_proto "mongo.games.com/game/protocol/gamehall"
|
||||||
|
server_proto "mongo.games.com/game/protocol/server"
|
||||||
"mongo.games.com/game/srvdata"
|
"mongo.games.com/game/srvdata"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -15,24 +15,21 @@ type CoinScenePool struct {
|
||||||
platform string // 平台id
|
platform string // 平台id
|
||||||
groupId int32 // 组id
|
groupId int32 // 组id
|
||||||
id int32 // 场次id
|
id int32 // 场次id
|
||||||
dbGameFree *serverproto.DB_GameFree // 场次配置
|
dbGameFree *server_proto.DB_GameFree // 场次配置
|
||||||
dbGameRule *serverproto.DB_GameRule // 场次配置
|
dbGameRule *server_proto.DB_GameRule // 场次配置
|
||||||
scenes map[int]*Scene // 所有房间,房间id
|
scenes map[int]*Scene // 所有房间,房间id
|
||||||
players map[int32]struct{} // 玩家id
|
players map[int32]struct{} // 玩家id
|
||||||
|
|
||||||
// 扩展数据
|
// 扩展数据
|
||||||
extraData interface{}
|
extraData interface{}
|
||||||
// 房间池规则
|
// 匹配规则
|
||||||
policy ICoinScenePool
|
policy ICoinScenePool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCoinScenePool(platform string, groupId int32, dbGameFree *serverproto.DB_GameFree) *CoinScenePool {
|
func NewCoinScenePool(platform string, groupId int32, dbGameFree *server_proto.DB_GameFree) *CoinScenePool {
|
||||||
if dbGameFree == nil {
|
if dbGameFree == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if platform == "" {
|
|
||||||
platform = DefaultPlatform
|
|
||||||
}
|
|
||||||
|
|
||||||
dbGameRule := srvdata.PBDB_GameRuleMgr.GetData(dbGameFree.GetGameRule())
|
dbGameRule := srvdata.PBDB_GameRuleMgr.GetData(dbGameFree.GetGameRule())
|
||||||
if dbGameRule == nil {
|
if dbGameRule == nil {
|
||||||
|
|
@ -90,20 +87,20 @@ func (csp *CoinScenePool) CanInviteRob() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CanEnter 检查入场条件
|
// CanEnter 检查入场条件
|
||||||
func (csp *CoinScenePool) CanEnter(p *Player) gamehallproto.OpResultCode {
|
func (csp *CoinScenePool) CanEnter(p *Player) gamehall_proto.OpResultCode {
|
||||||
if csp.dbGameFree == nil || p == nil {
|
if csp.dbGameFree == nil || p == nil {
|
||||||
return gamehallproto.OpResultCode_OPRC_Error
|
return gamehall_proto.OpResultCode_OPRC_Error
|
||||||
}
|
}
|
||||||
|
|
||||||
//检测房间状态是否开启
|
//检测房间状态是否开启
|
||||||
gps := PlatformMgrSingleton.GetGameFree(p.Platform, csp.id)
|
gps := PlatformMgrSingleton.GetGameFree(p.Platform, csp.id)
|
||||||
if gps == nil || !gps.Status {
|
if gps == nil || !gps.Status {
|
||||||
return gamehallproto.OpResultCode_OPRC_RoomHadClosed
|
return gamehall_proto.OpResultCode_OPRC_RoomHadClosed
|
||||||
}
|
}
|
||||||
|
|
||||||
dbGameFree := csp.dbGameFree
|
dbGameFree := csp.dbGameFree
|
||||||
if dbGameFree == nil {
|
if dbGameFree == nil {
|
||||||
return gamehallproto.OpResultCode_OPRC_RoomHadClosed
|
return gamehall_proto.OpResultCode_OPRC_RoomHadClosed
|
||||||
}
|
}
|
||||||
|
|
||||||
//检查游戏次数限制
|
//检查游戏次数限制
|
||||||
|
|
@ -112,7 +109,7 @@ func (csp *CoinScenePool) CanEnter(p *Player) gamehallproto.OpResultCode {
|
||||||
if dbGameFree.GetPlayNumLimit() != 0 &&
|
if dbGameFree.GetPlayNumLimit() != 0 &&
|
||||||
todayData != nil &&
|
todayData != nil &&
|
||||||
todayData.GameTimes >= int64(dbGameFree.GetPlayNumLimit()) {
|
todayData.GameTimes >= int64(dbGameFree.GetPlayNumLimit()) {
|
||||||
return gamehallproto.OpResultCode_OPRC_RoomGameTimes
|
return gamehall_proto.OpResultCode_OPRC_RoomGameTimes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,44 +117,28 @@ func (csp *CoinScenePool) CanEnter(p *Player) gamehallproto.OpResultCode {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CanAudienceEnter 检查观众入场条件
|
// CanAudienceEnter 检查观众入场条件
|
||||||
func (csp *CoinScenePool) CanAudienceEnter(p *Player) gamehallproto.OpResultCode {
|
func (csp *CoinScenePool) CanAudienceEnter(p *Player) gamehall_proto.OpResultCode {
|
||||||
if csp.dbGameFree == nil || p == nil {
|
if csp.dbGameFree == nil || p == nil {
|
||||||
return gamehallproto.OpResultCode_OPRC_Error
|
return gamehall_proto.OpResultCode_OPRC_Error
|
||||||
}
|
}
|
||||||
|
|
||||||
//检测房间状态是否开启
|
//检测房间状态是否开启
|
||||||
gps := PlatformMgrSingleton.GetGameFree(p.Platform, csp.id)
|
gps := PlatformMgrSingleton.GetGameFree(p.Platform, csp.id)
|
||||||
if gps == nil {
|
if gps == nil {
|
||||||
return gamehallproto.OpResultCode_OPRC_RoomHadClosed
|
return gamehall_proto.OpResultCode_OPRC_RoomHadClosed
|
||||||
}
|
}
|
||||||
|
|
||||||
dbGameFree := csp.dbGameFree
|
dbGameFree := csp.dbGameFree
|
||||||
if dbGameFree == nil {
|
if dbGameFree == nil {
|
||||||
return gamehallproto.OpResultCode_OPRC_RoomHadClosed
|
return gamehall_proto.OpResultCode_OPRC_RoomHadClosed
|
||||||
}
|
}
|
||||||
|
|
||||||
return csp.policy.CanAudienceEnter(csp, p)
|
return csp.policy.CanAudienceEnter(csp, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddScene 添加房间
|
|
||||||
func (csp *CoinScenePool) AddScene(s *Scene) {
|
|
||||||
if s == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
csp.scenes[s.sceneId] = s
|
|
||||||
s.csp = csp
|
|
||||||
if csp.groupId != 0 {
|
|
||||||
CoinSceneMgrSingleton.groupOfScene[s.sceneId] = csp.groupId
|
|
||||||
} else {
|
|
||||||
CoinSceneMgrSingleton.platformOfScene[s.sceneId] = csp.platform
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PlayerEnter 玩家进入房间池
|
// PlayerEnter 玩家进入房间池
|
||||||
// exclude 排除的房间id
|
func (csp *CoinScenePool) PlayerEnter(p *Player, roomId int32, exclude []int32, ischangeroom bool) gamehall_proto.OpResultCode {
|
||||||
// isChangeRoom 是否换房
|
if ret := csp.CanEnter(p); ret != gamehall_proto.OpResultCode_OPRC_Sucess {
|
||||||
func (csp *CoinScenePool) PlayerEnter(p *Player, roomId int32, exclude []int32, isChangeRoom bool) gamehallproto.OpResultCode {
|
|
||||||
if ret := csp.CanEnter(p); ret != gamehallproto.OpResultCode_OPRC_Sucess {
|
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter find snid:%v csp.CanEnter coin:%v ret:%v id:%v", p.SnId,
|
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter find snid:%v csp.CanEnter coin:%v ret:%v id:%v", p.SnId,
|
||||||
p.Coin, ret, csp.dbGameFree.GetId())
|
p.Coin, ret, csp.dbGameFree.GetId())
|
||||||
return ret
|
return ret
|
||||||
|
|
@ -165,77 +146,76 @@ func (csp *CoinScenePool) PlayerEnter(p *Player, roomId int32, exclude []int32,
|
||||||
|
|
||||||
if p.scene != nil {
|
if p.scene != nil {
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter[p.scene != nil] find snid:%v in scene:%v gameId:%v", p.SnId, p.scene.sceneId, p.scene.gameId)
|
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter[p.scene != nil] find snid:%v in scene:%v gameId:%v", p.SnId, p.scene.sceneId, p.scene.gameId)
|
||||||
return gamehallproto.OpResultCode_OPRC_Error
|
return gamehall_proto.OpResultCode_OPRC_Error
|
||||||
}
|
}
|
||||||
|
|
||||||
var scene *Scene
|
var scene *Scene
|
||||||
// 进入房间
|
// 进入房间
|
||||||
// 指定房间id进入,忽略排除exclude,只有机器人和进入预创建房间才允许
|
if roomId != 0 && (p.IsRob || p.GMLevel > 0 || csp.dbGameFree.GetCreateRoomNum() != 0) {
|
||||||
if roomId != 0 && (p.IsRob || csp.dbGameFree.GetCreateRoomNum() != 0) {
|
|
||||||
if s, ok := csp.scenes[int(roomId)]; ok {
|
if s, ok := csp.scenes[int(roomId)]; ok {
|
||||||
if s != nil && !s.deleting { //指定房间id进入,那么忽略掉排除id
|
if s != nil && !s.deleting { //指定房间id进入,那么忽略掉排除id
|
||||||
if s.IsFull() {
|
if s.IsFull() {
|
||||||
return gamehallproto.OpResultCode_OPRC_RoomIsFull
|
return gamehall_proto.OpResultCode_OPRC_RoomIsFull
|
||||||
}
|
}
|
||||||
if sp, ok := s.sp.(*ScenePolicyData); ok {
|
if sp, ok := s.sp.(*ScenePolicyData); ok {
|
||||||
if !s.starting || sp.EnterAfterStart {
|
if !s.starting || sp.EnterAfterStart {
|
||||||
scene = s
|
scene = s
|
||||||
} else {
|
} else {
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter[!s.starting || sp.EnterAfterStart] snid:%v sceneid:%v starting:%v EnterAfterStart:%v", p.SnId, s.sceneId, s.starting, sp.EnterAfterStart)
|
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter[!s.starting || sp.EnterAfterStart] snid:%v sceneid:%v starting:%v EnterAfterStart:%v", p.SnId, s.sceneId, s.starting, sp.EnterAfterStart)
|
||||||
return gamehallproto.OpResultCode_OPRC_Error
|
return gamehall_proto.OpResultCode_OPRC_Error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter(robot:%v,roomid:%v, exclude:%v, isChangeRoom:%v) no found scene", p.SnId, roomId, exclude, isChangeRoom)
|
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter(robot:%v,roomid:%v, exclude:%v, ischangeroom:%v) no found scene", p.SnId, roomId, exclude, ischangeroom)
|
||||||
return gamehallproto.OpResultCode_OPRC_Error
|
return gamehall_proto.OpResultCode_OPRC_Error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if scene == nil {
|
if scene == nil {
|
||||||
var ret gamehallproto.OpResultCode
|
var ret gamehall_proto.OpResultCode
|
||||||
ret, scene = csp.policy.PlayerEnter(csp, p, exclude, isChangeRoom)
|
ret, scene = csp.policy.PlayerEnter(csp, p, exclude, ischangeroom)
|
||||||
if ret != gamehallproto.OpResultCode_OPRC_Sucess {
|
if ret != gamehall_proto.OpResultCode_OPRC_Sucess {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 没有找到房间,创建新房间
|
|
||||||
if scene == nil {
|
if scene == nil {
|
||||||
scene = csp.policy.NewScene(csp, p)
|
scene = csp.policy.NewScene(csp, p)
|
||||||
if scene != nil {
|
if scene != nil {
|
||||||
csp.AddScene(scene)
|
csp.scenes[scene.sceneId] = scene
|
||||||
|
scene.csp = csp
|
||||||
} else {
|
} else {
|
||||||
logger.Logger.Errorf("Create %v scene failed.", csp.id)
|
logger.Logger.Errorf("Create %v scene failed.", csp.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if scene != nil {
|
if scene != nil {
|
||||||
if scene.PlayerEnter(p, -1, isChangeRoom) {
|
if p.EnterScene(scene, ischangeroom, -1) {
|
||||||
csp.OnPlayerEnter(p, scene)
|
csp.OnPlayerEnter(p, scene)
|
||||||
return gamehallproto.OpResultCode_OPRC_Sucess
|
return gamehall_proto.OpResultCode_OPRC_Sucess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter snid:%v not found scene", p.SnId)
|
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter snid:%v not found scene", p.SnId)
|
||||||
return gamehallproto.OpResultCode_OPRC_SceneServerMaintain
|
return gamehall_proto.OpResultCode_OPRC_SceneServerMaintain
|
||||||
}
|
}
|
||||||
|
|
||||||
// AudienceEnter 观众入场
|
// AudienceEnter 观众入场
|
||||||
func (csp *CoinScenePool) AudienceEnter(p *Player, roomId int32, exclude []int32, isChangeRoom bool) gamehallproto.OpResultCode {
|
func (csp *CoinScenePool) AudienceEnter(p *Player, roomId int32, exclude []int32, ischangeroom bool) gamehall_proto.OpResultCode {
|
||||||
if ret := csp.CanAudienceEnter(p); ret != gamehallproto.OpResultCode_OPRC_Sucess {
|
if ret := csp.CanAudienceEnter(p); ret != gamehall_proto.OpResultCode_OPRC_Sucess {
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) AudienceEnter find snid:%v csp.CanEnter coin:%v ret:%v id:%v", p.SnId, p.Coin, ret, csp.dbGameFree.GetId())
|
logger.Logger.Warnf("(csp *CoinScenePool) AudienceEnter find snid:%v csp.CanEnter coin:%v ret:%v id:%v", p.SnId, p.Coin, ret, csp.dbGameFree.GetId())
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.scene != nil {
|
if p.scene != nil {
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) AudienceEnter[p.scene != nil] find snid:%v in scene:%v gameId:%v", p.SnId, p.scene.sceneId, p.scene.gameId)
|
logger.Logger.Warnf("(csp *CoinScenePool) AudienceEnter[p.scene != nil] find snid:%v in scene:%v gameId:%v", p.SnId, p.scene.sceneId, p.scene.gameId)
|
||||||
return gamehallproto.OpResultCode_OPRC_Error
|
return gamehall_proto.OpResultCode_OPRC_Error
|
||||||
}
|
}
|
||||||
|
|
||||||
var scene *Scene
|
var scene *Scene
|
||||||
if roomId != 0 {
|
if roomId != 0 {
|
||||||
if s, ok := csp.scenes[int(roomId)]; ok {
|
if s, ok := csp.scenes[int(roomId)]; ok {
|
||||||
if s != nil && !s.deleting {
|
if s != nil && !s.deleting /*&& s.sceneId != int(exclude)*/ {
|
||||||
scene = s
|
scene = s
|
||||||
} else {
|
} else {
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) AudienceEnter[!s.starting || sp.EnterAfterStart] snid:%v sceneid:%v starting:%v EnterAfterStart:%v", p.SnId, s.sceneId, s.starting)
|
logger.Logger.Warnf("(csp *CoinScenePool) AudienceEnter[!s.starting || sp.EnterAfterStart] snid:%v sceneid:%v starting:%v EnterAfterStart:%v", p.SnId, s.sceneId, s.starting)
|
||||||
|
|
@ -244,29 +224,29 @@ func (csp *CoinScenePool) AudienceEnter(p *Player, roomId int32, exclude []int32
|
||||||
}
|
}
|
||||||
|
|
||||||
if scene == nil {
|
if scene == nil {
|
||||||
var ret gamehallproto.OpResultCode
|
var ret gamehall_proto.OpResultCode
|
||||||
ret, scene = csp.policy.AudienceEnter(csp, p, exclude, isChangeRoom)
|
ret, scene = csp.policy.AudienceEnter(csp, p, exclude, ischangeroom)
|
||||||
if ret != gamehallproto.OpResultCode_OPRC_Sucess {
|
if ret != gamehall_proto.OpResultCode_OPRC_Sucess {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if scene == nil {
|
if scene == nil {
|
||||||
return gamehallproto.OpResultCode_OPRC_NoFindDownTiceRoom
|
return gamehall_proto.OpResultCode_OPRC_NoFindDownTiceRoom
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if scene != nil {
|
||||||
// 预创建房间检查观众数量
|
// 预创建房间检查观众数量
|
||||||
if scene.IsPreCreateScene() && scene.GetAudienceCnt() >= model.GameParamData.MaxAudienceNum {
|
if scene.IsPreCreateScene() && scene.GetAudienceCnt() >= model.GameParamData.MaxAudienceNum {
|
||||||
return gamehallproto.OpResultCode_OPRC_RoomIsFull
|
return gamehall_proto.OpResultCode_OPRC_RoomIsFull
|
||||||
}
|
}
|
||||||
|
if scene.AudienceEnter(p, ischangeroom) {
|
||||||
if scene.AudienceEnter(p, isChangeRoom) {
|
|
||||||
csp.OnPlayerEnter(p, scene)
|
csp.OnPlayerEnter(p, scene)
|
||||||
return gamehallproto.OpResultCode_OPRC_Sucess
|
return gamehall_proto.OpResultCode_OPRC_Sucess
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter snid:%v not found scene", p.SnId)
|
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter snid:%v not found scene", p.SnId)
|
||||||
return gamehallproto.OpResultCode_OPRC_NoFindDownTiceRoom
|
return gamehall_proto.OpResultCode_OPRC_NoFindDownTiceRoom
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnPlayerEnter 玩家进入房间完成
|
// OnPlayerEnter 玩家进入房间完成
|
||||||
|
|
@ -371,16 +351,13 @@ func (csp *CoinScenePool) OnPlayerLeave(s *Scene, p *Player) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnDestroyScene 解散房间
|
// OnDestroyScene 解散房间
|
||||||
// 房间解散一定是游戏服确认的,worldsrv收到游戏房间解散消息后解散房间
|
// todo 是否需要优化
|
||||||
func (csp *CoinScenePool) OnDestroyScene(sceneId int) {
|
func (csp *CoinScenePool) OnDestroyScene(sceneId int) {
|
||||||
scene, ok := csp.scenes[sceneId]
|
scene, ok := csp.scenes[sceneId]
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Logger.Tracef("(csp *CoinScenePool) OnDestroyScene scene:%v", sceneId)
|
|
||||||
|
|
||||||
// todo 是否需要优化
|
|
||||||
for id := range scene.players {
|
for id := range scene.players {
|
||||||
player := PlayerMgrSington.GetPlayerBySnId(id)
|
player := PlayerMgrSington.GetPlayerBySnId(id)
|
||||||
if player != nil {
|
if player != nil {
|
||||||
|
|
@ -409,7 +386,6 @@ func (csp *CoinScenePool) OnDestroyScene(sceneId int) {
|
||||||
csp.policy.OnDestroyScene(csp, sceneId)
|
csp.policy.OnDestroyScene(csp, sceneId)
|
||||||
scene.csp = nil // 解除关联
|
scene.csp = nil // 解除关联
|
||||||
delete(csp.scenes, sceneId)
|
delete(csp.scenes, sceneId)
|
||||||
CoinSceneMgrSingleton.TouchCreateRoom(csp.platform, csp.dbGameFree.Id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PreCreateRoom 预创建房间
|
// PreCreateRoom 预创建房间
|
||||||
|
|
@ -417,78 +393,67 @@ func (csp *CoinScenePool) PreCreateRoom() {
|
||||||
if csp.platform == DefaultPlatform {
|
if csp.platform == DefaultPlatform {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
preCreateNum := int(csp.dbGameFree.GetCreateRoomNum())
|
||||||
|
if preCreateNum == 0 || model.GameParamData.ClosePreCreateRoom {
|
||||||
|
return
|
||||||
|
}
|
||||||
if p := PlatformMgrSingleton.GetPlatform(csp.platform); p == nil || p.Disable {
|
if p := PlatformMgrSingleton.GetPlatform(csp.platform); p == nil || p.Disable {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
preCreateNum := int(csp.dbGameFree.GetCreateRoomNum())
|
|
||||||
if preCreateNum <= 0 || model.GameParamData.ClosePreCreateRoom {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
num := preCreateNum - csp.GetRoomNum(common.SceneMode_Public)
|
|
||||||
if num > 0 {
|
|
||||||
logger.Logger.Tracef("预创建房间 [inc:%v] platform:%v gameFreeId:%v", num, csp.platform, csp.dbGameFree.Id)
|
|
||||||
for i := 0; i < num; i++ {
|
|
||||||
scene := csp.policy.NewPreCreateScene(csp)
|
|
||||||
if scene != nil {
|
|
||||||
csp.AddScene(scene)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (csp *CoinScenePool) GetRoomNum(mode ...int) int {
|
|
||||||
tp := 0
|
|
||||||
if len(mode) > 0 {
|
|
||||||
tp = mode[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
var num int
|
var num int
|
||||||
for _, scene := range csp.scenes {
|
for _, scene := range csp.scenes {
|
||||||
if tp > 0 {
|
if scene.limitPlatform.IdStr == csp.platform {
|
||||||
if scene.IsSceneMode(tp) {
|
|
||||||
num++
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
num++
|
num++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return num
|
if num < preCreateNum {
|
||||||
|
inc := preCreateNum - num
|
||||||
|
for i := 0; i < inc; i++ {
|
||||||
|
scene := csp.policy.NewPreCreateScene(csp)
|
||||||
|
if scene != nil {
|
||||||
|
csp.scenes[scene.sceneId] = scene
|
||||||
|
scene.csp = csp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRoom 房间列表
|
// ListRoom 房间列表
|
||||||
//func (csp *CoinScenePool) ListRoom(p *Player) bool {
|
func (csp *CoinScenePool) ListRoom(p *Player) bool {
|
||||||
// if p.scene != nil {
|
if p.scene != nil {
|
||||||
// logger.Logger.Warnf("(csp *CoinScenePool) PlayerListRoom[p.scene != nil] find snid:%v in scene:%v gameId:%v", p.SnId, p.scene.sceneId, p.scene.gameId)
|
logger.Logger.Warnf("(csp *CoinScenePool) PlayerListRoom[p.scene != nil] find snid:%v in scene:%v gameId:%v", p.SnId, p.scene.sceneId, p.scene.gameId)
|
||||||
// return false
|
return false
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if len(csp.scenes) == 0 {
|
csp.PreCreateRoom()
|
||||||
// return false
|
|
||||||
// }
|
if len(csp.scenes) == 0 {
|
||||||
//
|
return false
|
||||||
// pack := &gamehallproto.SCCoinSceneListRoom{
|
}
|
||||||
// Id: csp.dbGameFree.Id,
|
|
||||||
// LimitCoin: csp.dbGameFree.LimitCoin,
|
pack := &gamehall_proto.SCCoinSceneListRoom{
|
||||||
// MaxCoinLimit: csp.dbGameFree.MaxCoinLimit,
|
Id: csp.dbGameFree.Id,
|
||||||
// BaseScore: csp.dbGameFree.BaseScore,
|
LimitCoin: csp.dbGameFree.LimitCoin,
|
||||||
// MaxScore: csp.dbGameFree.MaxChip,
|
MaxCoinLimit: csp.dbGameFree.MaxCoinLimit,
|
||||||
// OtherIntParams: csp.dbGameFree.OtherIntParams,
|
BaseScore: csp.dbGameFree.BaseScore,
|
||||||
// }
|
MaxScore: csp.dbGameFree.MaxChip,
|
||||||
//
|
OtherIntParams: csp.dbGameFree.OtherIntParams,
|
||||||
// maxPlayerNum := 0
|
}
|
||||||
// for sceneId, s := range csp.scenes {
|
|
||||||
// data := &gamehallproto.CoinSceneInfo{
|
maxPlayerNum := 0
|
||||||
// SceneId: proto.Int(sceneId),
|
for sceneId, s := range csp.scenes {
|
||||||
// PlayerNum: proto.Int(len(s.players)),
|
data := &gamehall_proto.CoinSceneInfo{
|
||||||
// }
|
SceneId: proto.Int(sceneId),
|
||||||
// pack.Datas = append(pack.Datas, data)
|
PlayerNum: proto.Int(len(s.players)),
|
||||||
// maxPlayerNum = s.playerNum
|
}
|
||||||
// }
|
pack.Datas = append(pack.Datas, data)
|
||||||
// pack.MaxPlayerNum = proto.Int(maxPlayerNum)
|
maxPlayerNum = s.playerNum
|
||||||
// proto.SetDefaults(pack)
|
}
|
||||||
// p.SendToClient(int(gamehallproto.CoinSceneGamePacketID_PACKET_SC_COINSCENE_LISTROOM), pack)
|
pack.MaxPlayerNum = proto.Int(maxPlayerNum)
|
||||||
// return true
|
proto.SetDefaults(pack)
|
||||||
//}
|
p.SendToClient(int(gamehall_proto.CoinSceneGamePacketID_PACKET_SC_COINSCENE_LISTROOM), pack)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// GetHasTruePlayerSceneCnt 有真人的房间数量
|
// GetHasTruePlayerSceneCnt 有真人的房间数量
|
||||||
func (csp *CoinScenePool) GetHasTruePlayerSceneCnt() int {
|
func (csp *CoinScenePool) GetHasTruePlayerSceneCnt() int {
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ func (this *BaseCoinScenePool) CanEnter(pool *CoinScenePool, p *Player) gamehall
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通用入场检测
|
// 通用入场检测
|
||||||
if pool.dbGameFree.GetLimitCoin() != 0 && pool.dbGameFree.GetLimitCoin() > p.Coin && !p.IsRob {
|
if pool.dbGameFree.GetLimitCoin() != 0 && int64(pool.dbGameFree.GetLimitCoin()) > p.Coin {
|
||||||
return gamehall.OpResultCode_OPRC_CoinNotEnough
|
return gamehall.OpResultCode_OPRC_CoinNotEnough
|
||||||
}
|
}
|
||||||
if pool.dbGameFree.GetMaxCoinLimit() != 0 && int64(pool.dbGameFree.GetMaxCoinLimit()) < p.Coin && !p.IsRob {
|
if pool.dbGameFree.GetMaxCoinLimit() != 0 && int64(pool.dbGameFree.GetMaxCoinLimit()) < p.Coin && !p.IsRob {
|
||||||
|
|
@ -67,10 +67,6 @@ func (this *BaseCoinScenePool) PlayerEnter(pool *CoinScenePool, p *Player, exclu
|
||||||
}
|
}
|
||||||
|
|
||||||
if !common.Config.IsDevMode {
|
if !common.Config.IsDevMode {
|
||||||
// 私人房
|
|
||||||
if s.IsPrivateScene() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// 禁止真人匹配
|
// 禁止真人匹配
|
||||||
if matchTrueManRule == MatchTrueManForbid && !p.IsRob && s.GetTruePlayerCnt() != 0 {
|
if matchTrueManRule == MatchTrueManForbid && !p.IsRob && s.GetTruePlayerCnt() != 0 {
|
||||||
continue
|
continue
|
||||||
|
|
@ -98,7 +94,7 @@ func (this *BaseCoinScenePool) PlayerEnter(pool *CoinScenePool, p *Player, exclu
|
||||||
}
|
}
|
||||||
|
|
||||||
//优先黑白名单
|
//优先黑白名单
|
||||||
if len(scenes) != 0 {
|
if scene == nil && len(scenes) != 0 {
|
||||||
gameId := pool.dbGameFree.GetGameId()
|
gameId := pool.dbGameFree.GetGameId()
|
||||||
if p.WBLevel < 0 { //黑名单玩家
|
if p.WBLevel < 0 { //黑名单玩家
|
||||||
var cntWhite int
|
var cntWhite int
|
||||||
|
|
@ -176,6 +172,7 @@ func (this *BaseCoinScenePool) PlayerEnter(pool *CoinScenePool, p *Player, exclu
|
||||||
|
|
||||||
if scene == nil && len(scenes) != 0 {
|
if scene == nil && len(scenes) != 0 {
|
||||||
//1.其次游戏的配桌规则
|
//1.其次游戏的配桌规则
|
||||||
|
if scene == nil {
|
||||||
matchFunc := GetCoinSceneMatchFunc(int(gameId))
|
matchFunc := GetCoinSceneMatchFunc(int(gameId))
|
||||||
if matchFunc != nil {
|
if matchFunc != nil {
|
||||||
scene = matchFunc(pool, p, scenes, sameIpLimit, exclude)
|
scene = matchFunc(pool, p, scenes, sameIpLimit, exclude)
|
||||||
|
|
@ -184,6 +181,14 @@ func (this *BaseCoinScenePool) PlayerEnter(pool *CoinScenePool, p *Player, exclu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 随机
|
||||||
|
if scene == nil {
|
||||||
|
for _, v := range scenes {
|
||||||
|
scene = v
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return gamehall.OpResultCode_OPRC_Sucess, scene
|
return gamehall.OpResultCode_OPRC_Sucess, scene
|
||||||
}
|
}
|
||||||
|
|
@ -214,22 +219,36 @@ func (this *BaseCoinScenePool) NewScene(pool *CoinScenePool, p *Player) *Scene {
|
||||||
gameId := int(pool.dbGameRule.GetGameId())
|
gameId := int(pool.dbGameRule.GetGameId())
|
||||||
gs := GameSessMgrSington.GetMinLoadSess(gameId)
|
gs := GameSessMgrSington.GetMinLoadSess(gameId)
|
||||||
if gs == nil {
|
if gs == nil {
|
||||||
logger.Logger.Warnf("Get %v game min session failed.", gameId)
|
logger.Logger.Errorf("Get %v game min session failed.", gameId)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
gameMode := pool.dbGameRule.GetGameMode()
|
gameMode := pool.dbGameRule.GetGameMode()
|
||||||
params := common.CopySliceInt32ToInt64(pool.dbGameRule.GetParams())
|
params := common.CopySliceInt32ToInt64(pool.dbGameRule.GetParams())
|
||||||
|
var platformName string
|
||||||
limitPlatform := PlatformMgrSingleton.GetPlatform(pool.platform)
|
limitPlatform := PlatformMgrSingleton.GetPlatform(pool.platform)
|
||||||
if limitPlatform == nil || !limitPlatform.Isolated {
|
if limitPlatform == nil || !limitPlatform.Isolated {
|
||||||
limitPlatform = PlatformMgrSingleton.GetPlatform(DefaultPlatform)
|
limitPlatform = PlatformMgrSingleton.GetPlatform(DefaultPlatform)
|
||||||
|
platformName = DefaultPlatform
|
||||||
|
} else {
|
||||||
|
platformName = limitPlatform.IdStr
|
||||||
}
|
}
|
||||||
|
|
||||||
sceneId := SceneMgrSingleton.GenOneCoinSceneId()
|
sceneId := SceneMgrSingleton.GenOneCoinSceneId()
|
||||||
|
|
||||||
scene := SceneMgrSingleton.CreateScene(0, 0, sceneId, gameId, int(gameMode), common.SceneMode_Public,
|
scene := SceneMgrSingleton.CreateScene(0, 0, sceneId, gameId, int(gameMode), int(common.SceneMode_Public),
|
||||||
1, -1, params, gs, limitPlatform, pool.groupId, pool.dbGameFree, pool.id)
|
1, -1, params, gs, limitPlatform, pool.groupId, pool.dbGameFree, int32(pool.id))
|
||||||
|
if scene != nil {
|
||||||
|
scene.hallId = pool.id
|
||||||
|
scene.csp = pool
|
||||||
|
if pool.groupId != 0 {
|
||||||
|
CoinSceneMgrSingleton.groupOfScene[int32(sceneId)] = pool.groupId
|
||||||
|
} else {
|
||||||
|
CoinSceneMgrSingleton.platformOfScene[int32(sceneId)] = platformName
|
||||||
|
}
|
||||||
return scene
|
return scene
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *BaseCoinScenePool) NewPreCreateScene(pool *CoinScenePool) *Scene {
|
func (this *BaseCoinScenePool) NewPreCreateScene(pool *CoinScenePool) *Scene {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import (
|
||||||
|
|
||||||
var coinScenePools = map[int32]ICoinScenePool{}
|
var coinScenePools = map[int32]ICoinScenePool{}
|
||||||
|
|
||||||
// RegisterCoinScenePool 注册房间池规则
|
// RegisterCoinScenePool 注册游戏匹配规则
|
||||||
func RegisterCoinScenePool(gameId int32, policy ICoinScenePool) {
|
func RegisterCoinScenePool(gameId int32, policy ICoinScenePool) {
|
||||||
coinScenePools[gameId] = policy
|
coinScenePools[gameId] = policy
|
||||||
}
|
}
|
||||||
|
|
@ -15,36 +15,21 @@ func GetCoinScenePool(gameId int32) ICoinScenePool {
|
||||||
return coinScenePools[gameId]
|
return coinScenePools[gameId]
|
||||||
}
|
}
|
||||||
|
|
||||||
// ICoinScenePool 定义房间池规则的接口
|
|
||||||
// 公共处理逻辑可以写在 CoinScenePool,不能满足需求时再实现 ICoinScenePool
|
|
||||||
type ICoinScenePool interface {
|
type ICoinScenePool interface {
|
||||||
// New 创建房间池
|
|
||||||
New() interface{}
|
New() interface{}
|
||||||
// CanEnter 玩家是否可以进入
|
|
||||||
CanEnter(pool *CoinScenePool, p *Player) gamehall.OpResultCode
|
CanEnter(pool *CoinScenePool, p *Player) gamehall.OpResultCode
|
||||||
// CanAudienceEnter 观众是否可以进入
|
|
||||||
CanAudienceEnter(pool *CoinScenePool, p *Player) gamehall.OpResultCode
|
CanAudienceEnter(pool *CoinScenePool, p *Player) gamehall.OpResultCode
|
||||||
|
|
||||||
// PlayerEnter 玩家进入(匹配房间)
|
PlayerEnter(pool *CoinScenePool, p *Player, exclude []int32, ischangeroom bool) (ret gamehall.OpResultCode, scene *Scene)
|
||||||
// exclude 排除的房间列表
|
AudienceEnter(pool *CoinScenePool, p *Player, exclude []int32, ischangeroom bool) (ret gamehall.OpResultCode, scene *Scene)
|
||||||
// isChangeRoom 是否是换房间
|
|
||||||
PlayerEnter(pool *CoinScenePool, p *Player, exclude []int32, isChangeRoom bool) (ret gamehall.OpResultCode, scene *Scene)
|
|
||||||
// AudienceEnter 观众进入(匹配房间)
|
|
||||||
AudienceEnter(pool *CoinScenePool, p *Player, exclude []int32, isChangeRoom bool) (ret gamehall.OpResultCode, scene *Scene)
|
|
||||||
// OnPlayerEnter 玩家进入房间之后
|
|
||||||
OnPlayerEnter(pool *CoinScenePool, p *Player, scene *Scene)
|
OnPlayerEnter(pool *CoinScenePool, p *Player, scene *Scene)
|
||||||
|
|
||||||
// PlayerLeave 玩家离开
|
|
||||||
PlayerLeave(pool *CoinScenePool, p *Player, reason int) bool
|
PlayerLeave(pool *CoinScenePool, p *Player, reason int) bool
|
||||||
// AudienceLeave 观众离开
|
|
||||||
AudienceLeave(pool *CoinScenePool, p *Player, reason int) bool
|
AudienceLeave(pool *CoinScenePool, p *Player, reason int) bool
|
||||||
// OnPlayerLeave 玩家离开房间之后
|
|
||||||
OnPlayerLeave(pool *CoinScenePool, s *Scene, p *Player)
|
OnPlayerLeave(pool *CoinScenePool, s *Scene, p *Player)
|
||||||
|
|
||||||
// NewScene 创建房间
|
|
||||||
NewScene(pool *CoinScenePool, p *Player) *Scene
|
NewScene(pool *CoinScenePool, p *Player) *Scene
|
||||||
// NewPreCreateScene 创建预创建房间
|
|
||||||
NewPreCreateScene(pool *CoinScenePool) *Scene
|
NewPreCreateScene(pool *CoinScenePool) *Scene
|
||||||
// OnDestroyScene 房间解散之后
|
|
||||||
OnDestroyScene(pool *CoinScenePool, sceneId int)
|
OnDestroyScene(pool *CoinScenePool, sceneId int)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/protocol/gamehall"
|
"mongo.games.com/game/protocol/gamehall"
|
||||||
serverproto "mongo.games.com/game/protocol/server"
|
server_proto "mongo.games.com/game/protocol/server"
|
||||||
"mongo.games.com/game/srvdata"
|
"mongo.games.com/game/srvdata"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ type CoinScenePoolLocal struct {
|
||||||
BaseCoinScenePool
|
BaseCoinScenePool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *CoinScenePoolLocal) PlayerEnter(pool *CoinScenePool, p *Player, exclude []int32, isChangeRoom bool) (ret gamehall.OpResultCode, scene *Scene) {
|
func (this *CoinScenePoolLocal) PlayerEnter(pool *CoinScenePool, p *Player, exclude []int32, ischangeroom bool) (ret gamehall.OpResultCode, scene *Scene) {
|
||||||
// 配房规则
|
// 配房规则
|
||||||
// 如果全局为限制则看具体的游戏是否限制,如果全局为不限制则不考虑具体的游戏。
|
// 如果全局为限制则看具体的游戏是否限制,如果全局为不限制则不考虑具体的游戏。
|
||||||
sameIpLimit := !model.GameParamData.SameIpNoLimit
|
sameIpLimit := !model.GameParamData.SameIpNoLimit
|
||||||
|
|
@ -42,12 +42,12 @@ func (l *CoinScenePoolLocal) PlayerEnter(pool *CoinScenePool, p *Player, exclude
|
||||||
matchTrueManRule := pool.dbGameFree.GetMatchTrueMan()
|
matchTrueManRule := pool.dbGameFree.GetMatchTrueMan()
|
||||||
|
|
||||||
//根据携带金额取进房间底注 DB_Createroom
|
//根据携带金额取进房间底注 DB_Createroom
|
||||||
var dbCreateRoom *serverproto.DB_Createroom
|
var dbCreateRoom *server_proto.DB_Createroom
|
||||||
gameId := pool.dbGameFree.GetGameId()
|
gameId := pool.dbGameFree.GetGameId()
|
||||||
dbCreateRoom = srvdata.CreateRoomMgrSington.GetDataByGameIdWithTakeCoin(gameId, p.Coin)
|
dbCreateRoom = srvdata.CreateRoomMgrSington.GetDataByGameIdWithTakeCoin(gameId, p.Coin)
|
||||||
if dbCreateRoom == nil {
|
if dbCreateRoom == nil {
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter(robot:%v, exclude:%v, isChangeRoom:%v) no found scene from DB_Createroom",
|
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter(robot:%v, exclude:%v, ischangeroom:%v) no found scene from DB_Createroom",
|
||||||
p.SnId, exclude, isChangeRoom)
|
p.SnId, exclude, ischangeroom)
|
||||||
return gamehall.OpResultCode_OPRC_Error, nil
|
return gamehall.OpResultCode_OPRC_Error, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,10 +58,6 @@ func (l *CoinScenePoolLocal) PlayerEnter(pool *CoinScenePool, p *Player, exclude
|
||||||
}
|
}
|
||||||
|
|
||||||
if !common.Config.IsDevMode {
|
if !common.Config.IsDevMode {
|
||||||
// 私人房
|
|
||||||
if s.IsPrivateScene() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// 禁止真人匹配
|
// 禁止真人匹配
|
||||||
if matchTrueManRule == MatchTrueManForbid && !p.IsRob && s.GetTruePlayerCnt() != 0 {
|
if matchTrueManRule == MatchTrueManForbid && !p.IsRob && s.GetTruePlayerCnt() != 0 {
|
||||||
continue
|
continue
|
||||||
|
|
@ -85,7 +81,7 @@ func (l *CoinScenePoolLocal) PlayerEnter(pool *CoinScenePool, p *Player, exclude
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//根据携带金额取可进房间
|
//根据携带金额取可进房间
|
||||||
if len(dbCreateRoom.GetBetRange()) != 0 {
|
if dbCreateRoom != nil && len(dbCreateRoom.GetBetRange()) != 0 {
|
||||||
betRange := dbCreateRoom.GetBetRange()
|
betRange := dbCreateRoom.GetBetRange()
|
||||||
if common.InSliceInt32(betRange, s.BaseScore) {
|
if common.InSliceInt32(betRange, s.BaseScore) {
|
||||||
scenes[sceneId] = s
|
scenes[sceneId] = s
|
||||||
|
|
@ -96,7 +92,7 @@ func (l *CoinScenePoolLocal) PlayerEnter(pool *CoinScenePool, p *Player, exclude
|
||||||
}
|
}
|
||||||
|
|
||||||
//优先黑白名单
|
//优先黑白名单
|
||||||
if len(scenes) != 0 {
|
if scene == nil && len(scenes) != 0 {
|
||||||
gameId := pool.dbGameFree.GetGameId()
|
gameId := pool.dbGameFree.GetGameId()
|
||||||
if p.WBLevel < 0 { //黑名单玩家
|
if p.WBLevel < 0 { //黑名单玩家
|
||||||
var cntWhite int
|
var cntWhite int
|
||||||
|
|
@ -155,7 +151,7 @@ func (l *CoinScenePoolLocal) PlayerEnter(pool *CoinScenePool, p *Player, exclude
|
||||||
}
|
}
|
||||||
} else { //按类型匹配
|
} else { //按类型匹配
|
||||||
//优先真人
|
//优先真人
|
||||||
if len(scenes) != 0 && matchTrueManRule == MatchTrueManPriority {
|
if scene == nil && len(scenes) != 0 && matchTrueManRule == MatchTrueManPriority {
|
||||||
var selScene []*Scene
|
var selScene []*Scene
|
||||||
for _, value := range scenes {
|
for _, value := range scenes {
|
||||||
if value != nil {
|
if value != nil {
|
||||||
|
|
@ -174,6 +170,7 @@ func (l *CoinScenePoolLocal) PlayerEnter(pool *CoinScenePool, p *Player, exclude
|
||||||
|
|
||||||
if scene == nil && len(scenes) != 0 {
|
if scene == nil && len(scenes) != 0 {
|
||||||
//1.其次游戏的配桌规则
|
//1.其次游戏的配桌规则
|
||||||
|
if scene == nil {
|
||||||
matchFunc := GetCoinSceneMatchFunc(int(gameId))
|
matchFunc := GetCoinSceneMatchFunc(int(gameId))
|
||||||
if matchFunc != nil {
|
if matchFunc != nil {
|
||||||
scene = matchFunc(pool, p, scenes, sameIpLimit, exclude)
|
scene = matchFunc(pool, p, scenes, sameIpLimit, exclude)
|
||||||
|
|
@ -181,11 +178,12 @@ func (l *CoinScenePoolLocal) PlayerEnter(pool *CoinScenePool, p *Player, exclude
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return gamehall.OpResultCode_OPRC_Sucess, scene
|
return gamehall.OpResultCode_OPRC_Sucess, scene
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *CoinScenePoolLocal) NewScene(pool *CoinScenePool, p *Player) *Scene {
|
func (this *CoinScenePoolLocal) NewScene(pool *CoinScenePool, p *Player) *Scene {
|
||||||
gameId := int(pool.dbGameFree.GetGameId())
|
gameId := int(pool.dbGameFree.GetGameId())
|
||||||
gs := GameSessMgrSington.GetMinLoadSess(gameId)
|
gs := GameSessMgrSington.GetMinLoadSess(gameId)
|
||||||
if gs == nil {
|
if gs == nil {
|
||||||
|
|
@ -196,16 +194,20 @@ func (l *CoinScenePoolLocal) NewScene(pool *CoinScenePool, p *Player) *Scene {
|
||||||
sceneId := SceneMgrSingleton.GenOneCoinSceneId()
|
sceneId := SceneMgrSingleton.GenOneCoinSceneId()
|
||||||
|
|
||||||
params := pool.dbGameRule.GetParams()
|
params := pool.dbGameRule.GetParams()
|
||||||
|
var platformName string
|
||||||
limitPlatform := PlatformMgrSingleton.GetPlatform(pool.platform)
|
limitPlatform := PlatformMgrSingleton.GetPlatform(pool.platform)
|
||||||
if limitPlatform == nil || !limitPlatform.Isolated {
|
if limitPlatform == nil || !limitPlatform.Isolated {
|
||||||
limitPlatform = PlatformMgrSingleton.GetPlatform(DefaultPlatform)
|
limitPlatform = PlatformMgrSingleton.GetPlatform(DefaultPlatform)
|
||||||
|
platformName = DefaultPlatform
|
||||||
|
} else {
|
||||||
|
platformName = limitPlatform.IdStr
|
||||||
}
|
}
|
||||||
|
|
||||||
//根据携带金额取可创房间 DB_Createroom
|
//根据携带金额取可创房间 DB_Createroom
|
||||||
baseScore := int32(0)
|
baseScore := int32(0)
|
||||||
gameSite := 0
|
gameSite := 0
|
||||||
playerTakeCoin := p.Coin
|
playerTakeCoin := p.Coin
|
||||||
var dbCreateRoom *serverproto.DB_Createroom
|
var dbCreateRoom *server_proto.DB_Createroom
|
||||||
arrs := srvdata.PBDB_CreateroomMgr.Datas.Arr
|
arrs := srvdata.PBDB_CreateroomMgr.Datas.Arr
|
||||||
for i := len(arrs) - 1; i >= 0; i-- {
|
for i := len(arrs) - 1; i >= 0; i-- {
|
||||||
if arrs[i].GetGameId() == int32(gameId) {
|
if arrs[i].GetGameId() == int32(gameId) {
|
||||||
|
|
@ -234,23 +236,33 @@ func (l *CoinScenePoolLocal) NewScene(pool *CoinScenePool, p *Player) *Scene {
|
||||||
|
|
||||||
scene := SceneMgrSingleton.CreateLocalGameScene(p.SnId, sceneId, gameId, gameSite, common.SceneMode_Public, 1, common.CopySliceInt32ToInt64(params),
|
scene := SceneMgrSingleton.CreateLocalGameScene(p.SnId, sceneId, gameId, gameSite, common.SceneMode_Public, 1, common.CopySliceInt32ToInt64(params),
|
||||||
gs, limitPlatform, 0, pool.dbGameFree, baseScore, pool.groupId, pool.id)
|
gs, limitPlatform, 0, pool.dbGameFree, baseScore, pool.groupId, pool.id)
|
||||||
|
if scene != nil {
|
||||||
|
scene.hallId = pool.id
|
||||||
|
scene.groupId = pool.groupId
|
||||||
|
CoinSceneMgrSingleton.platformOfScene[int32(sceneId)] = platformName
|
||||||
return scene
|
return scene
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *CoinScenePoolLocal) NewPreCreateScene(pool *CoinScenePool) *Scene {
|
func (this *CoinScenePoolLocal) NewPreCreateScene(pool *CoinScenePool) *Scene {
|
||||||
gameId := int(pool.dbGameRule.GetGameId())
|
gameId := int(pool.dbGameRule.GetGameId())
|
||||||
gs := GameSessMgrSington.GetMinLoadSess(gameId)
|
gs := GameSessMgrSington.GetMinLoadSess(gameId)
|
||||||
if gs == nil {
|
if gs == nil {
|
||||||
logger.Logger.Warnf("Get %v game min session failed.", gameId)
|
logger.Logger.Errorf("Get %v game min session failed.", gameId)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
sceneId := SceneMgrSingleton.GenOneCoinSceneId()
|
sceneId := SceneMgrSingleton.GenOneCoinSceneId()
|
||||||
|
|
||||||
params := pool.dbGameRule.GetParams()
|
params := pool.dbGameRule.GetParams()
|
||||||
|
var platformName string
|
||||||
limitPlatform := PlatformMgrSingleton.GetPlatform(pool.platform)
|
limitPlatform := PlatformMgrSingleton.GetPlatform(pool.platform)
|
||||||
if limitPlatform == nil || !limitPlatform.Isolated {
|
if limitPlatform == nil || !limitPlatform.Isolated {
|
||||||
limitPlatform = PlatformMgrSingleton.GetPlatform(DefaultPlatform)
|
limitPlatform = PlatformMgrSingleton.GetPlatform(DefaultPlatform)
|
||||||
|
platformName = DefaultPlatform
|
||||||
|
} else {
|
||||||
|
platformName = limitPlatform.IdStr
|
||||||
}
|
}
|
||||||
|
|
||||||
var scene *Scene
|
var scene *Scene
|
||||||
|
|
@ -262,7 +274,7 @@ func (l *CoinScenePoolLocal) NewPreCreateScene(pool *CoinScenePool) *Scene {
|
||||||
//根据SceneType随机可创房间 DB_Createroom
|
//根据SceneType随机可创房间 DB_Createroom
|
||||||
baseScore := int32(0)
|
baseScore := int32(0)
|
||||||
gameSite := 0
|
gameSite := 0
|
||||||
var dbCreateRooms []*serverproto.DB_Createroom
|
var dbCreateRooms []*server_proto.DB_Createroom
|
||||||
arrs := srvdata.PBDB_CreateroomMgr.Datas.Arr
|
arrs := srvdata.PBDB_CreateroomMgr.Datas.Arr
|
||||||
for i := len(arrs) - 1; i >= 0; i-- {
|
for i := len(arrs) - 1; i >= 0; i-- {
|
||||||
if arrs[i].GetGameId() == int32(gameId) && arrs[i].GetGameSite() == pool.dbGameFree.GetSceneType() {
|
if arrs[i].GetGameId() == int32(gameId) && arrs[i].GetGameSite() == pool.dbGameFree.GetSceneType() {
|
||||||
|
|
@ -291,5 +303,16 @@ func (l *CoinScenePoolLocal) NewPreCreateScene(pool *CoinScenePool) *Scene {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if scene != nil {
|
||||||
|
scene.hallId = pool.id
|
||||||
|
scene.csp = pool
|
||||||
|
if pool.groupId != 0 {
|
||||||
|
CoinSceneMgrSingleton.groupOfScene[int32(sceneId)] = pool.groupId
|
||||||
|
} else {
|
||||||
|
CoinSceneMgrSingleton.platformOfScene[int32(sceneId)] = platformName
|
||||||
|
}
|
||||||
return scene
|
return scene
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,13 +112,12 @@
|
||||||
"AppId": "5c56d1644966f078bfb90c71",
|
"AppId": "5c56d1644966f078bfb90c71",
|
||||||
"IsDevMode": true
|
"IsDevMode": true
|
||||||
},
|
},
|
||||||
"etcd": {
|
|
||||||
"Url": ["127.0.0.1:2379"],
|
|
||||||
"UserName": "",
|
|
||||||
"Password": "",
|
|
||||||
"DialTimeout": 60
|
|
||||||
},
|
|
||||||
"costum": {
|
"costum": {
|
||||||
|
"etcdurl": [
|
||||||
|
"127.0.0.1:2379"
|
||||||
|
],
|
||||||
|
"etcduser": "root",
|
||||||
|
"etcdpwd": "win88",
|
||||||
"MgoRpcCliNet": "tcp",
|
"MgoRpcCliNet": "tcp",
|
||||||
"MgoRpcCliAddr": "127.0.0.1:8999",
|
"MgoRpcCliAddr": "127.0.0.1:8999",
|
||||||
"MgoRpcCliReconnInterV": 3,
|
"MgoRpcCliReconnInterV": 3,
|
||||||
|
|
|
||||||
121
worldsrv/etcd.go
121
worldsrv/etcd.go
|
|
@ -2,15 +2,14 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"go.etcd.io/etcd/client/v3"
|
"go.etcd.io/etcd/client/v3"
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
|
||||||
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/etcd"
|
"mongo.games.com/game/etcd"
|
||||||
hallproto "mongo.games.com/game/protocol/gamehall"
|
hallproto "mongo.games.com/game/protocol/gamehall"
|
||||||
loginproto "mongo.games.com/game/protocol/login"
|
|
||||||
playerproto "mongo.games.com/game/protocol/player"
|
playerproto "mongo.games.com/game/protocol/player"
|
||||||
"mongo.games.com/game/protocol/webapi"
|
"mongo.games.com/game/protocol/webapi"
|
||||||
)
|
)
|
||||||
|
|
@ -18,10 +17,10 @@ import (
|
||||||
func init() {
|
func init() {
|
||||||
// 平台配置
|
// 平台配置
|
||||||
etcd.Register(etcd.ETCDKEY_PLATFORM_PREFIX, webapi.Platform{}, platformConfigEvent)
|
etcd.Register(etcd.ETCDKEY_PLATFORM_PREFIX, webapi.Platform{}, platformConfigEvent)
|
||||||
// 超管平台游戏开关
|
|
||||||
etcd.Register(etcd.ETCDKEY_GAME_CONFIG_GLOBAL, webapi.GameConfigGlobal{}, platformConfigEvent)
|
|
||||||
// 游戏场次配置
|
// 游戏场次配置
|
||||||
etcd.Register(etcd.ETCDKEY_GAMECONFIG_PREFIX, webapi.GameFree{}, platformConfigEvent)
|
etcd.Register(etcd.ETCDKEY_GAMECONFIG_PREFIX, webapi.GameFree{}, platformConfigEvent)
|
||||||
|
// 超管平台游戏开关
|
||||||
|
etcd.Register(etcd.ETCDKEY_GAME_CONFIG_GLOBAL, webapi.GameConfigGlobal{}, platformConfigEvent)
|
||||||
// 平台包数据
|
// 平台包数据
|
||||||
etcd.Register(etcd.ETCDKEY_PACKAGE_PREFIX, webapi.AppInfo{}, platformConfigEvent)
|
etcd.Register(etcd.ETCDKEY_PACKAGE_PREFIX, webapi.AppInfo{}, platformConfigEvent)
|
||||||
// 客户端游戏入口开关
|
// 客户端游戏入口开关
|
||||||
|
|
@ -40,30 +39,6 @@ func init() {
|
||||||
etcd.Register(etcd.ETCDKEY_ACT_Collect, webapi.WelfareCollectConfig{}, platformConfigEvent)
|
etcd.Register(etcd.ETCDKEY_ACT_Collect, webapi.WelfareCollectConfig{}, platformConfigEvent)
|
||||||
// 渠道开关
|
// 渠道开关
|
||||||
etcd.Register(etcd.ETCDKEY_ChannelSwitch, webapi.ChannelSwitchConfig{}, platformConfigEvent)
|
etcd.Register(etcd.ETCDKEY_ChannelSwitch, webapi.ChannelSwitchConfig{}, platformConfigEvent)
|
||||||
// 组配置
|
|
||||||
etcd.Register(etcd.ETCDKEY_GROUPCONFIG_PREFIX, webapi.GameConfigGroup{}, platformConfigEvent)
|
|
||||||
// 黑名单配置
|
|
||||||
etcd.Register(etcd.ETCDKEY_BLACKLIST_PREFIX, BlackInfoApi{}, handlerEvent)
|
|
||||||
// 代理
|
|
||||||
etcd.Register(etcd.ETCDKEY_PROMOTER_PREFIX, PromoterConfig{}, handlerEvent)
|
|
||||||
// 赠送
|
|
||||||
etcd.Register(etcd.ETCDKEY_ACT_GIVE_PREFIX, PromoterConfig{}, handlerEvent)
|
|
||||||
// 7日签到
|
|
||||||
etcd.Register(etcd.ETCDKEY_ACT_7SIGN, webapi.Welfare7SignDateList{}, platformConfigEvent)
|
|
||||||
// 转盘
|
|
||||||
etcd.Register(etcd.ETCDKEY_ACT_TURNPLATE, webapi.WelfareTurnplateDateList{}, platformConfigEvent)
|
|
||||||
// 盲盒
|
|
||||||
etcd.Register(etcd.ETCDKEY_ACT_BLINDBOX, webapi.WelfareBlindBoxDataList{}, platformConfigEvent)
|
|
||||||
// 首充
|
|
||||||
etcd.Register(etcd.ETCDKEY_ACT_FIRSTPAY, webapi.WelfareFirstPayDataList{}, platformConfigEvent)
|
|
||||||
// 连充
|
|
||||||
etcd.Register(etcd.ETCDKEY_ACT_CONTINUOUSPAY, webapi.WelfareContinuousPayDataList{}, platformConfigEvent)
|
|
||||||
// VIP
|
|
||||||
etcd.Register(etcd.ETCDKEY_VIP_CFG, webapi.VIPcfgDataList{}, platformConfigEvent)
|
|
||||||
// 象棋段位
|
|
||||||
etcd.Register(etcd.ETCDKEY_CHESSRANK_CFG, webapi.ChessRankcfgData{}, platformConfigEvent)
|
|
||||||
// 手机积分
|
|
||||||
etcd.Register(etcd.ETCDKEY_ACT_PHONELOTTERY, webapi.WelfarePhoneLotteryStatus{}, platformConfigEvent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
||||||
|
|
@ -157,103 +132,17 @@ func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, e
|
||||||
case *webapi.ChannelSwitchConfig:
|
case *webapi.ChannelSwitchConfig:
|
||||||
PlatformMgrSingleton.GetConfig(config.Platform).ChannelSwitch[config.GetTp()] = config
|
PlatformMgrSingleton.GetConfig(config.Platform).ChannelSwitch[config.GetTp()] = config
|
||||||
if !isInit {
|
if !isInit {
|
||||||
|
switch config.GetTp() {
|
||||||
|
case common.ChannelSwitchExchange:
|
||||||
// 通知变更
|
// 通知变更
|
||||||
for _, v := range PlayerMgrSington.playerOfPlatform[config.Platform] {
|
for _, v := range PlayerMgrSington.playerOfPlatform[config.Platform] {
|
||||||
if v != nil && v.IsOnLine() {
|
if v != nil && v.IsOnLine() {
|
||||||
v.SendToClient(int(playerproto.PlayerPacketID_PACKET_SCExchangeChannel), &playerproto.SCExchangeChannel{
|
v.SendToClient(int(playerproto.PlayerPacketID_PACKET_SCExchangeChannel), &playerproto.SCExchangeChannel{
|
||||||
Datas: []*playerproto.ChannelSwitch{{
|
|
||||||
Tp: config.Tp,
|
|
||||||
OnChannelName: config.OnChannelName,
|
OnChannelName: config.OnChannelName,
|
||||||
}},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case *webapi.GameConfigGroup:
|
|
||||||
PlatformGameGroupMgrSington.UpsertGameGroup(config)
|
|
||||||
case *webapi.Welfare7SignDateList:
|
|
||||||
WelfareMgrSington.UpdateSign7(config)
|
|
||||||
case *webapi.WelfareTurnplateDateList:
|
|
||||||
WelfareMgrSington.UpdateTurnplate(config)
|
|
||||||
case *webapi.WelfareBlindBoxDataList:
|
|
||||||
WelfareMgrSington.UpdateBlindBox(config)
|
|
||||||
case *webapi.WelfareFirstPayDataList:
|
|
||||||
WelfareMgrSington.UpdateFirstPay(config)
|
|
||||||
case *webapi.WelfareContinuousPayDataList:
|
|
||||||
WelfareMgrSington.UpdateContinuousPay(config)
|
|
||||||
case *webapi.VIPcfgDataList:
|
|
||||||
VipMgrSington.UpdateVIPcfg(config)
|
|
||||||
case *webapi.ChessRankcfgData:
|
|
||||||
ChessRankMgrSington.UpdateChessRankConfig(config)
|
|
||||||
case *webapi.WelfarePhoneLotteryStatus:
|
|
||||||
WelfareMgrSington.UpdatePhoneLotteryStatus(config)
|
|
||||||
|
|
||||||
default:
|
|
||||||
logger.Logger.Errorf("etcd completeKey:%s, Not processed", completeKey)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func handlerEvent(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
|
||||||
if data == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch config := data.(type) {
|
|
||||||
case *BlackInfoApi:
|
|
||||||
if isInit {
|
|
||||||
BlackListMgrSington.InitBlackInfo(config)
|
|
||||||
} else {
|
|
||||||
switch event.Type {
|
|
||||||
case clientv3.EventTypeDelete:
|
|
||||||
dirs := strings.Split(string(event.Kv.Key), "/")
|
|
||||||
n := len(dirs)
|
|
||||||
if n > 0 {
|
|
||||||
last := dirs[n-1]
|
|
||||||
id, err := strconv.Atoi(last)
|
|
||||||
if err == nil {
|
|
||||||
if value, exist := BlackListMgrSington.BlackList[int32(id)]; exist {
|
|
||||||
BlackListMgrSington.RemoveBlackInfo(value.Id, value.Platform)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case clientv3.EventTypePut:
|
|
||||||
BlackListMgrSington.UpsertBlackInfo(config)
|
|
||||||
if (config.Space & int32(BlackState_Login)) != 0 {
|
|
||||||
var targetPlayer []*Player //确定用户是否在线
|
|
||||||
for _, value := range PlayerMgrSington.players {
|
|
||||||
_, ok := BlackListMgrSington.CheckPlayerInBlack(value.PlayerData, BlackState_Login)
|
|
||||||
if ok {
|
|
||||||
targetPlayer = append(targetPlayer, value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, p := range targetPlayer {
|
|
||||||
if p.sid != 0 {
|
|
||||||
p.Kickout(int32(loginproto.SSDisconnectTypeCode_SSDTC_BlackList))
|
|
||||||
} else {
|
|
||||||
LoginStateMgrSington.LogoutByAccount(p.AccountId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case *PromoterConfig:
|
|
||||||
if isInit {
|
|
||||||
PromoterMgrSington.AddConfig(config)
|
|
||||||
} else {
|
|
||||||
switch event.Type {
|
|
||||||
case clientv3.EventTypeDelete:
|
|
||||||
dirs := strings.Split(string(event.Kv.Key), "/")
|
|
||||||
n := len(dirs)
|
|
||||||
if n > 0 {
|
|
||||||
promoterConfig := dirs[n-1]
|
|
||||||
PromoterMgrSington.RemoveConfigByKey(promoterConfig)
|
|
||||||
}
|
|
||||||
case clientv3.EventTypePut:
|
|
||||||
PromoterMgrSington.AddConfig(config)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case *ActGivePlateformConfig:
|
|
||||||
if isInit || event.Type == clientv3.EventTypePut {
|
|
||||||
ActMgrSington.AddGiveConfig(config, config.Platform)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,768 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"go.etcd.io/etcd/client/v3"
|
||||||
|
"mongo.games.com/game/common"
|
||||||
|
"mongo.games.com/game/etcd"
|
||||||
|
"mongo.games.com/game/model"
|
||||||
|
"mongo.games.com/game/proto"
|
||||||
|
loginproto "mongo.games.com/game/protocol/login"
|
||||||
|
webapiproto "mongo.games.com/game/protocol/webapi"
|
||||||
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
)
|
||||||
|
|
||||||
|
// EtcdMgrSington etcd数据读取
|
||||||
|
// Deprecated: use [etcd] instead
|
||||||
|
// 使用 etcd.Register 代替
|
||||||
|
// todo EtcdMgrSington 用新方法替换
|
||||||
|
var EtcdMgrSington = &EtcdMgr{
|
||||||
|
Client: &etcd.Client{},
|
||||||
|
}
|
||||||
|
|
||||||
|
type EtcdMgr struct {
|
||||||
|
*etcd.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载组配置
|
||||||
|
func (this *EtcdMgr) InitGameGroup() {
|
||||||
|
initFunc := func() int64 {
|
||||||
|
if model.GameParamData.UseEtcd {
|
||||||
|
logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_GROUPCONFIG_PREFIX)
|
||||||
|
res, err := this.GetValueWithPrefix(etcd.ETCDKEY_GROUPCONFIG_PREFIX)
|
||||||
|
if err == nil {
|
||||||
|
for i := int64(0); i < res.Count; i++ {
|
||||||
|
var value webapiproto.GameConfigGroup
|
||||||
|
err = proto.Unmarshal(res.Kvs[i].Value, &value)
|
||||||
|
if err == nil {
|
||||||
|
PlatformGameGroupMgrSington.UpsertGameGroup(&value)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_GROUPCONFIG_PREFIX, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if res.Header != nil {
|
||||||
|
return res.Header.Revision
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_GROUPCONFIG_PREFIX, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监控数据变动
|
||||||
|
watchFunc := func(ctx context.Context, revision int64) {
|
||||||
|
this.GoWatch(ctx, revision, etcd.ETCDKEY_GROUPCONFIG_PREFIX, func(res clientv3.WatchResponse) error {
|
||||||
|
for _, ev := range res.Events {
|
||||||
|
switch ev.Type {
|
||||||
|
case clientv3.EventTypeDelete:
|
||||||
|
case clientv3.EventTypePut:
|
||||||
|
var value webapiproto.GameConfigGroup
|
||||||
|
err := proto.Unmarshal(ev.Kv.Value, &value)
|
||||||
|
if err == nil {
|
||||||
|
PlatformGameGroupMgrSington.UpsertGameGroup(&value)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_GROUPCONFIG_PREFIX, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.InitAndWatch(initFunc, watchFunc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载黑名单配置
|
||||||
|
func (this *EtcdMgr) InitBlackList() {
|
||||||
|
initFunc := func() int64 {
|
||||||
|
if model.GameParamData.UseEtcd {
|
||||||
|
logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_BLACKLIST_PREFIX)
|
||||||
|
res, err := this.GetValueWithPrefix(etcd.ETCDKEY_BLACKLIST_PREFIX)
|
||||||
|
if err == nil {
|
||||||
|
for i := int64(0); i < res.Count; i++ {
|
||||||
|
var value BlackInfoApi
|
||||||
|
err = json.Unmarshal(res.Kvs[i].Value, &value)
|
||||||
|
if err == nil {
|
||||||
|
BlackListMgrSington.InitBlackInfo(&value)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_BLACKLIST_PREFIX, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if res.Header != nil {
|
||||||
|
return res.Header.Revision
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_BLACKLIST_PREFIX, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
//@test code
|
||||||
|
//go func() {
|
||||||
|
// for {
|
||||||
|
// i := int32(1)
|
||||||
|
// data := BlackInfoApi{
|
||||||
|
// Id: i,
|
||||||
|
// Snid: i,
|
||||||
|
// Creator: rand.Int31(),
|
||||||
|
// }
|
||||||
|
// buf, err := json.Marshal(data)
|
||||||
|
// if err == nil {
|
||||||
|
// key := fmt.Sprintf("%s%d", etcd.ETCDKEY_BLACKLIST_PREFIX, i)
|
||||||
|
// putResp, err := this.PutValue(key, string(buf))
|
||||||
|
// if err == nil {
|
||||||
|
// if putResp.PrevKv != nil {
|
||||||
|
// logger.Logger.Trace("@etcdtest put", string(putResp.PrevKv.Key), string(putResp.PrevKv.Value))
|
||||||
|
// }
|
||||||
|
// //delResp, err := this.DelValue(key)
|
||||||
|
// //if err == nil {
|
||||||
|
// // logger.Logger.Trace("@etcdtest del", delResp.Deleted)
|
||||||
|
// //}
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}()
|
||||||
|
//@test code
|
||||||
|
|
||||||
|
//ETCD中现在只有公共黑名单信息
|
||||||
|
//如果删除公共黑名单信息使用ETCD删除
|
||||||
|
//如果删除个人玩家身上的黑名单信息使用API删除
|
||||||
|
// 监控数据变动
|
||||||
|
watchFunc := func(ctx context.Context, revision int64) {
|
||||||
|
this.GoWatch(ctx, revision, etcd.ETCDKEY_BLACKLIST_PREFIX, func(res clientv3.WatchResponse) error {
|
||||||
|
for _, ev := range res.Events {
|
||||||
|
switch ev.Type {
|
||||||
|
case clientv3.EventTypeDelete:
|
||||||
|
dirs := strings.Split(string(ev.Kv.Key), "/")
|
||||||
|
n := len(dirs)
|
||||||
|
if n > 0 {
|
||||||
|
last := dirs[n-1]
|
||||||
|
id, err := strconv.Atoi(last)
|
||||||
|
if err == nil {
|
||||||
|
if value, exist := BlackListMgrSington.BlackList[int32(id)]; exist {
|
||||||
|
BlackListMgrSington.RemoveBlackInfo(value.Id, value.Platform)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case clientv3.EventTypePut:
|
||||||
|
var value BlackInfoApi
|
||||||
|
err := json.Unmarshal(ev.Kv.Value, &value)
|
||||||
|
if err == nil {
|
||||||
|
BlackListMgrSington.UpsertBlackInfo(&value)
|
||||||
|
if (value.Space & int32(BlackState_Login)) != 0 {
|
||||||
|
var targetPlayer []*Player //确定用户是否在线
|
||||||
|
for _, value := range PlayerMgrSington.players {
|
||||||
|
_, ok := BlackListMgrSington.CheckPlayerInBlack(value.PlayerData, BlackState_Login)
|
||||||
|
if ok {
|
||||||
|
targetPlayer = append(targetPlayer, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, p := range targetPlayer {
|
||||||
|
if p.sid != 0 {
|
||||||
|
p.Kickout(int32(loginproto.SSDisconnectTypeCode_SSDTC_BlackList))
|
||||||
|
} else {
|
||||||
|
LoginStateMgrSington.LogoutByAccount(p.AccountId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_BLACKLIST_PREFIX, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.InitAndWatch(initFunc, watchFunc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化代理数据
|
||||||
|
func (this *EtcdMgr) InitPromoterConfig() {
|
||||||
|
initFunc := func() int64 {
|
||||||
|
if model.GameParamData.UseEtcd {
|
||||||
|
logger.Logger.Info("ETCD 初始化代理数据 拉取数据:", etcd.ETCDKEY_PROMOTER_PREFIX)
|
||||||
|
res, err := this.GetValueWithPrefix(etcd.ETCDKEY_PROMOTER_PREFIX)
|
||||||
|
if err == nil {
|
||||||
|
for i := int64(0); i < res.Count; i++ {
|
||||||
|
var promoterConfig *PromoterConfig
|
||||||
|
err = json.Unmarshal(res.Kvs[i].Value, &promoterConfig)
|
||||||
|
if err == nil {
|
||||||
|
PromoterMgrSington.AddConfig(promoterConfig)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_PROMOTER_PREFIX, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if res.Header != nil {
|
||||||
|
return res.Header.Revision
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_PROMOTER_PREFIX, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监控数据变动
|
||||||
|
watchFunc := func(ctx context.Context, revision int64) {
|
||||||
|
this.GoWatch(ctx, revision, etcd.ETCDKEY_PROMOTER_PREFIX, func(res clientv3.WatchResponse) error {
|
||||||
|
for _, ev := range res.Events {
|
||||||
|
switch ev.Type {
|
||||||
|
case clientv3.EventTypeDelete:
|
||||||
|
dirs := strings.Split(string(ev.Kv.Key), "/")
|
||||||
|
n := len(dirs)
|
||||||
|
if n > 0 {
|
||||||
|
promoterConfig := dirs[n-1]
|
||||||
|
PromoterMgrSington.RemoveConfigByKey(promoterConfig)
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
var promoterConfig *PromoterConfig
|
||||||
|
err := json.Unmarshal(ev.Kv.Value, &promoterConfig)
|
||||||
|
if err == nil {
|
||||||
|
PromoterMgrSington.RemoveConfigByKey(promoterConfig)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_PROMOTER_PREFIX, err)
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
case clientv3.EventTypePut:
|
||||||
|
var promoterConfig *PromoterConfig
|
||||||
|
err := json.Unmarshal(ev.Kv.Value, &promoterConfig)
|
||||||
|
if err == nil {
|
||||||
|
PromoterMgrSington.AddConfig(promoterConfig)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_PROMOTER_PREFIX, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.InitAndWatch(initFunc, watchFunc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载活动give配置
|
||||||
|
func (this *EtcdMgr) InitPlatformAct() {
|
||||||
|
initFunc := func() int64 {
|
||||||
|
if model.GameParamData.UseEtcd {
|
||||||
|
logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_GIVE_PREFIX)
|
||||||
|
res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_GIVE_PREFIX)
|
||||||
|
if err == nil {
|
||||||
|
for i := int64(0); i < res.Count; i++ {
|
||||||
|
var vipConfig ActGivePlateformConfig
|
||||||
|
err = json.Unmarshal(res.Kvs[i].Value, &vipConfig)
|
||||||
|
if err == nil {
|
||||||
|
ActMgrSington.AddGiveConfig(&vipConfig, vipConfig.Platform)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_GIVE_PREFIX, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if res.Header != nil {
|
||||||
|
return res.Header.Revision
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_GIVE_PREFIX, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监控数据变动
|
||||||
|
watchFunc := func(ctx context.Context, revision int64) {
|
||||||
|
this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_GIVE_PREFIX, func(res clientv3.WatchResponse) error {
|
||||||
|
for _, ev := range res.Events {
|
||||||
|
switch ev.Type {
|
||||||
|
case clientv3.EventTypeDelete:
|
||||||
|
case clientv3.EventTypePut:
|
||||||
|
var vipConfig ActGivePlateformConfig
|
||||||
|
err := json.Unmarshal(ev.Kv.Value, &vipConfig)
|
||||||
|
if err == nil {
|
||||||
|
ActMgrSington.AddGiveConfig(&vipConfig, vipConfig.Platform)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_GOLDCOME_PREFIX, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.InitAndWatch(initFunc, watchFunc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载七日签到
|
||||||
|
func (this *EtcdMgr) InitSign7() {
|
||||||
|
initFunc := func() int64 {
|
||||||
|
if model.GameParamData.UseEtcd {
|
||||||
|
logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_7SIGN)
|
||||||
|
res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_7SIGN)
|
||||||
|
if err == nil {
|
||||||
|
for i := int64(0); i < res.Count; i++ {
|
||||||
|
cfg := &webapiproto.Welfare7SignDateList{}
|
||||||
|
//msg := &webapi.ASSrvCtrlClose{}
|
||||||
|
err = proto.Unmarshal(res.Kvs[i].Value, cfg)
|
||||||
|
if err == nil && cfg.Platform != "" {
|
||||||
|
WelfareMgrSington.UpdateSign7(cfg)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_ACT_7SIGN, cfg.Platform, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if res.Header != nil {
|
||||||
|
return res.Header.Revision
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_7SIGN, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监控数据变动
|
||||||
|
watchFunc := func(ctx context.Context, revision int64) {
|
||||||
|
this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_7SIGN, func(res clientv3.WatchResponse) error {
|
||||||
|
for _, ev := range res.Events {
|
||||||
|
switch ev.Type {
|
||||||
|
case clientv3.EventTypeDelete:
|
||||||
|
case clientv3.EventTypePut:
|
||||||
|
cfg := &webapiproto.Welfare7SignDateList{}
|
||||||
|
err := proto.Unmarshal(ev.Kv.Value, cfg)
|
||||||
|
if err == nil && cfg.Platform != "" {
|
||||||
|
WelfareMgrSington.UpdateSign7(cfg)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_ACT_7SIGN, cfg.Platform, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.InitAndWatch(initFunc, watchFunc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载轮盘
|
||||||
|
func (this *EtcdMgr) InitTurnplate() {
|
||||||
|
initFunc := func() int64 {
|
||||||
|
if model.GameParamData.UseEtcd {
|
||||||
|
logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_TURNPLATE)
|
||||||
|
res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_TURNPLATE)
|
||||||
|
if err == nil {
|
||||||
|
for i := int64(0); i < res.Count; i++ {
|
||||||
|
cfg := &webapiproto.WelfareTurnplateDateList{}
|
||||||
|
//msg := &webapi.ASSrvCtrlClose{}
|
||||||
|
err = proto.Unmarshal(res.Kvs[i].Value, cfg)
|
||||||
|
if err == nil && cfg.Platform != "" {
|
||||||
|
WelfareMgrSington.UpdateTurnplate(cfg)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_ACT_TURNPLATE, cfg.Platform, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if res.Header != nil {
|
||||||
|
return res.Header.Revision
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_TURNPLATE, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监控数据变动
|
||||||
|
watchFunc := func(ctx context.Context, revision int64) {
|
||||||
|
this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_TURNPLATE, func(res clientv3.WatchResponse) error {
|
||||||
|
for _, ev := range res.Events {
|
||||||
|
switch ev.Type {
|
||||||
|
case clientv3.EventTypeDelete:
|
||||||
|
case clientv3.EventTypePut:
|
||||||
|
cfg := &webapiproto.WelfareTurnplateDateList{}
|
||||||
|
err := proto.Unmarshal(ev.Kv.Value, cfg)
|
||||||
|
if err == nil && cfg.Platform != "" {
|
||||||
|
WelfareMgrSington.UpdateTurnplate(cfg)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_ACT_TURNPLATE, cfg.Platform, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.InitAndWatch(initFunc, watchFunc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载盲盒
|
||||||
|
func (this *EtcdMgr) InitBlindBox() {
|
||||||
|
initFunc := func() int64 {
|
||||||
|
if model.GameParamData.UseEtcd {
|
||||||
|
logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_BLINDBOX)
|
||||||
|
res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_BLINDBOX)
|
||||||
|
if err == nil {
|
||||||
|
for i := int64(0); i < res.Count; i++ {
|
||||||
|
cfg := &webapiproto.WelfareBlindBoxDataList{}
|
||||||
|
//msg := &webapi.ASSrvCtrlClose{}
|
||||||
|
err = proto.Unmarshal(res.Kvs[i].Value, cfg)
|
||||||
|
if err == nil && cfg.Platform != "" {
|
||||||
|
WelfareMgrSington.UpdateBlindBox(cfg)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_ACT_BLINDBOX, cfg.Platform, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if res.Header != nil {
|
||||||
|
return res.Header.Revision
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_BLINDBOX, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监控数据变动
|
||||||
|
watchFunc := func(ctx context.Context, revision int64) {
|
||||||
|
this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_BLINDBOX, func(res clientv3.WatchResponse) error {
|
||||||
|
for _, ev := range res.Events {
|
||||||
|
switch ev.Type {
|
||||||
|
case clientv3.EventTypeDelete:
|
||||||
|
case clientv3.EventTypePut:
|
||||||
|
cfg := &webapiproto.WelfareBlindBoxDataList{}
|
||||||
|
err := proto.Unmarshal(ev.Kv.Value, cfg)
|
||||||
|
if err == nil && cfg.Platform != "" {
|
||||||
|
WelfareMgrSington.UpdateBlindBox(cfg)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_ACT_BLINDBOX, cfg.Platform, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.InitAndWatch(initFunc, watchFunc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载首充
|
||||||
|
func (this *EtcdMgr) InitFirstPay() {
|
||||||
|
initFunc := func() int64 {
|
||||||
|
if model.GameParamData.UseEtcd {
|
||||||
|
logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_FIRSTPAY)
|
||||||
|
res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_FIRSTPAY)
|
||||||
|
if err == nil {
|
||||||
|
for i := int64(0); i < res.Count; i++ {
|
||||||
|
cfg := &webapiproto.WelfareFirstPayDataList{}
|
||||||
|
//msg := &webapi.ASSrvCtrlClose{}
|
||||||
|
err = proto.Unmarshal(res.Kvs[i].Value, cfg)
|
||||||
|
if err == nil && cfg.Platform != "" {
|
||||||
|
WelfareMgrSington.UpdateFirstPay(cfg)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_ACT_FIRSTPAY, cfg.Platform, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if res.Header != nil {
|
||||||
|
return res.Header.Revision
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_FIRSTPAY, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监控数据变动
|
||||||
|
watchFunc := func(ctx context.Context, revision int64) {
|
||||||
|
this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_FIRSTPAY, func(res clientv3.WatchResponse) error {
|
||||||
|
for _, ev := range res.Events {
|
||||||
|
switch ev.Type {
|
||||||
|
case clientv3.EventTypeDelete:
|
||||||
|
case clientv3.EventTypePut:
|
||||||
|
cfg := &webapiproto.WelfareFirstPayDataList{}
|
||||||
|
err := proto.Unmarshal(ev.Kv.Value, cfg)
|
||||||
|
if err == nil && cfg.Platform != "" {
|
||||||
|
WelfareMgrSington.UpdateFirstPay(cfg)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_ACT_FIRSTPAY, cfg.Platform, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.InitAndWatch(initFunc, watchFunc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载连续充值
|
||||||
|
func (this *EtcdMgr) InitContinuousPay() {
|
||||||
|
initFunc := func() int64 {
|
||||||
|
if model.GameParamData.UseEtcd {
|
||||||
|
logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_CONTINUOUSPAY)
|
||||||
|
res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_CONTINUOUSPAY)
|
||||||
|
if err == nil {
|
||||||
|
for i := int64(0); i < res.Count; i++ {
|
||||||
|
cfg := &webapiproto.WelfareContinuousPayDataList{}
|
||||||
|
//msg := &webapi.ASSrvCtrlClose{}
|
||||||
|
err = proto.Unmarshal(res.Kvs[i].Value, cfg)
|
||||||
|
if err == nil && cfg.Platform != "" {
|
||||||
|
WelfareMgrSington.UpdateContinuousPay(cfg)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_ACT_CONTINUOUSPAY, cfg.Platform, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if res.Header != nil {
|
||||||
|
return res.Header.Revision
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_CONTINUOUSPAY, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监控数据变动
|
||||||
|
watchFunc := func(ctx context.Context, revision int64) {
|
||||||
|
this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_CONTINUOUSPAY, func(res clientv3.WatchResponse) error {
|
||||||
|
for _, ev := range res.Events {
|
||||||
|
switch ev.Type {
|
||||||
|
case clientv3.EventTypeDelete:
|
||||||
|
case clientv3.EventTypePut:
|
||||||
|
cfg := &webapiproto.WelfareContinuousPayDataList{}
|
||||||
|
err := proto.Unmarshal(ev.Kv.Value, cfg)
|
||||||
|
if err == nil && cfg.Platform != "" {
|
||||||
|
WelfareMgrSington.UpdateContinuousPay(cfg)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_ACT_CONTINUOUSPAY, cfg.Platform, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.InitAndWatch(initFunc, watchFunc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载VIP
|
||||||
|
func (this *EtcdMgr) InitUpdateVIPcfg() {
|
||||||
|
initFunc := func() int64 {
|
||||||
|
if model.GameParamData.UseEtcd {
|
||||||
|
logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_VIP_CFG)
|
||||||
|
res, err := this.GetValueWithPrefix(etcd.ETCDKEY_VIP_CFG)
|
||||||
|
if err == nil {
|
||||||
|
for i := int64(0); i < res.Count; i++ {
|
||||||
|
cfg := &webapiproto.VIPcfgDataList{}
|
||||||
|
//msg := &webapi.ASSrvCtrlClose{}
|
||||||
|
err = proto.Unmarshal(res.Kvs[i].Value, cfg)
|
||||||
|
if err == nil && cfg.Platform != "" {
|
||||||
|
VipMgrSington.UpdateVIPcfg(cfg)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_VIP_CFG, cfg.Platform, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if res.Header != nil {
|
||||||
|
return res.Header.Revision
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_VIP_CFG, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监控数据变动
|
||||||
|
watchFunc := func(ctx context.Context, revision int64) {
|
||||||
|
this.GoWatch(ctx, revision, etcd.ETCDKEY_VIP_CFG, func(res clientv3.WatchResponse) error {
|
||||||
|
for _, ev := range res.Events {
|
||||||
|
switch ev.Type {
|
||||||
|
case clientv3.EventTypeDelete:
|
||||||
|
case clientv3.EventTypePut:
|
||||||
|
cfg := &webapiproto.VIPcfgDataList{}
|
||||||
|
err := proto.Unmarshal(ev.Kv.Value, cfg)
|
||||||
|
if err == nil && cfg.Platform != "" {
|
||||||
|
VipMgrSington.UpdateVIPcfg(cfg)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_VIP_CFG, cfg.Platform, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.InitAndWatch(initFunc, watchFunc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载段位配置
|
||||||
|
func (this *EtcdMgr) InitUpdateChessRankcfg() {
|
||||||
|
initFunc := func() int64 {
|
||||||
|
if model.GameParamData.UseEtcd {
|
||||||
|
logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_CHESSRANK_CFG)
|
||||||
|
res, err := this.GetValueWithPrefix(etcd.ETCDKEY_CHESSRANK_CFG)
|
||||||
|
if err == nil {
|
||||||
|
for i := int64(0); i < res.Count; i++ {
|
||||||
|
cfg := &webapiproto.ChessRankcfgData{}
|
||||||
|
err = proto.Unmarshal(res.Kvs[i].Value, cfg)
|
||||||
|
if err == nil && cfg.Platform != "" {
|
||||||
|
ChessRankMgrSington.UpdateChessRankConfig(cfg)
|
||||||
|
logger.Logger.Tracef("ChessRankConfig %v", cfg)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_CHESSRANK_CFG, cfg.Platform, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if res.Header != nil {
|
||||||
|
return res.Header.Revision
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_CHESSRANK_CFG, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监控数据变动
|
||||||
|
watchFunc := func(ctx context.Context, revision int64) {
|
||||||
|
this.GoWatch(ctx, revision, etcd.ETCDKEY_CHESSRANK_CFG, func(res clientv3.WatchResponse) error {
|
||||||
|
for _, ev := range res.Events {
|
||||||
|
switch ev.Type {
|
||||||
|
case clientv3.EventTypeDelete:
|
||||||
|
case clientv3.EventTypePut:
|
||||||
|
cfg := &webapiproto.ChessRankcfgData{}
|
||||||
|
err := proto.Unmarshal(ev.Kv.Value, cfg)
|
||||||
|
if err == nil && cfg.Platform != "" {
|
||||||
|
ChessRankMgrSington.UpdateChessRankConfig(cfg)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_CHESSRANK_CFG, cfg.Platform, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.InitAndWatch(initFunc, watchFunc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载抽手机活动
|
||||||
|
func (this *EtcdMgr) InitPhoneLottery() {
|
||||||
|
initFunc := func() int64 {
|
||||||
|
if model.GameParamData.UseEtcd {
|
||||||
|
logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_PHONELOTTERY)
|
||||||
|
res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_PHONELOTTERY)
|
||||||
|
if err == nil {
|
||||||
|
for i := int64(0); i < res.Count; i++ {
|
||||||
|
cfg := &webapiproto.WelfarePhoneLotteryStatus{}
|
||||||
|
//msg := &webapi.ASSrvCtrlClose{}
|
||||||
|
err = proto.Unmarshal(res.Kvs[i].Value, cfg)
|
||||||
|
if err == nil && cfg.Platform != "" {
|
||||||
|
WelfareMgrSington.UpdatePhoneLotteryStatus(cfg)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_ACT_PHONELOTTERY, cfg.Platform, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if res.Header != nil {
|
||||||
|
return res.Header.Revision
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_PHONELOTTERY, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监控数据变动
|
||||||
|
watchFunc := func(ctx context.Context, revision int64) {
|
||||||
|
this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_PHONELOTTERY, func(res clientv3.WatchResponse) error {
|
||||||
|
for _, ev := range res.Events {
|
||||||
|
switch ev.Type {
|
||||||
|
case clientv3.EventTypeDelete:
|
||||||
|
case clientv3.EventTypePut:
|
||||||
|
cfg := &webapiproto.WelfarePhoneLotteryStatus{}
|
||||||
|
err := proto.Unmarshal(ev.Kv.Value, cfg)
|
||||||
|
if err == nil && cfg.Platform != "" {
|
||||||
|
WelfareMgrSington.UpdatePhoneLotteryStatus(cfg)
|
||||||
|
} else {
|
||||||
|
logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_ACT_PHONELOTTERY, cfg.Platform, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.InitAndWatch(initFunc, watchFunc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载 调控黑白名单
|
||||||
|
//func (this *EtcdMgr) InitWBCtrlCFG() {
|
||||||
|
// initFunc := func() int64 {
|
||||||
|
// if model.GameParamData.UseEtcd {
|
||||||
|
// logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_WBCtrl_CFG)
|
||||||
|
// res, err := this.GetValueWithPrefix(etcd.ETCDKEY_WBCtrl_CFG)
|
||||||
|
// if err == nil {
|
||||||
|
// for i := int64(0); i < res.Count; i++ {
|
||||||
|
// cfg := &webapi_proto.WbCtrlCfg{}
|
||||||
|
// err = proto.Unmarshal(res.Kvs[i].Value, cfg)
|
||||||
|
// if err == nil && cfg.Platform != "" {
|
||||||
|
// WBCtrlCfgMgr.UpdateConfig(cfg)
|
||||||
|
// } else {
|
||||||
|
// logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_WBCtrl_CFG, cfg.Platform, err)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if res.Header != nil {
|
||||||
|
// return res.Header.Revision
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_WBCtrl_CFG, err)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return -1
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 监控数据变动
|
||||||
|
// watchFunc := func(ctx context.Context, revision int64) {
|
||||||
|
// this.GoWatch(ctx, revision, etcd.ETCDKEY_WBCtrl_CFG, func(res clientv3.WatchResponse) error {
|
||||||
|
// for _, ev := range res.Events {
|
||||||
|
// switch ev.Type {
|
||||||
|
// case clientv3.EventTypeDelete:
|
||||||
|
// case clientv3.EventTypePut:
|
||||||
|
// cfg := &webapi_proto.WbCtrlCfg{}
|
||||||
|
// err := proto.Unmarshal(ev.Kv.Value, cfg)
|
||||||
|
// if err == nil && cfg.Platform != "" {
|
||||||
|
// WBCtrlCfgMgr.UpdateConfig(cfg)
|
||||||
|
// } else {
|
||||||
|
// logger.Logger.Errorf("etcd desc WithPrefix(%v) Platform %v panic:%v", etcd.ETCDKEY_WBCtrl_CFG, cfg.Platform, err)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return nil
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// this.InitAndWatch(initFunc, watchFunc)
|
||||||
|
//}
|
||||||
|
|
||||||
|
func (this *EtcdMgr) Init() {
|
||||||
|
if model.GameParamData.UseEtcd {
|
||||||
|
logger.Logger.Infof("EtcdClient开始连接url:%v;etcduser:%v;etcdpwd:%v", common.CustomConfig.GetStrings("etcdurl"), common.CustomConfig.GetString("etcduser"), common.CustomConfig.GetString("etcdpwd"))
|
||||||
|
err := this.Open(common.CustomConfig.GetStrings("etcdurl"), common.CustomConfig.GetString("etcduser"), common.CustomConfig.GetString("etcdpwd"), time.Minute)
|
||||||
|
if err != nil {
|
||||||
|
logger.Logger.Tracef("EtcdMgr.Open err:%v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *EtcdMgr) Shutdown() {
|
||||||
|
this.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *EtcdMgr) Reset() {
|
||||||
|
this.Close()
|
||||||
|
this.Init()
|
||||||
|
this.ReInitAndWatchAll()
|
||||||
|
}
|
||||||
|
|
@ -222,6 +222,7 @@ func (this *GameSession) AddScene(s *Scene) {
|
||||||
|
|
||||||
func (this *GameSession) DelScene(s *Scene) {
|
func (this *GameSession) DelScene(s *Scene) {
|
||||||
delete(this.scenes, s.sceneId)
|
delete(this.scenes, s.sceneId)
|
||||||
|
//from gameserver, so don't need send msg
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GameSession) AddPlayer(p *Player) {
|
func (this *GameSession) AddPlayer(p *Player) {
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue