Compare commits
No commits in common. "ac0daa39a4cb13d66979bf62a47c55b5a7616c3e" and "d494205ede8f164fa5a12bdcba873a7e31c6b23c" have entirely different histories.
ac0daa39a4
...
d494205ede
|
@ -99,7 +99,6 @@ const (
|
||||||
GameId_AngerUncle = 606 // 愤怒大叔
|
GameId_AngerUncle = 606 // 愤怒大叔
|
||||||
GameId_SmallRoket = 607 // 小火箭
|
GameId_SmallRoket = 607 // 小火箭
|
||||||
GameId_Clawdoll = 608 // 娃娃机
|
GameId_Clawdoll = 608 // 娃娃机
|
||||||
GameId_PushCoin = 609 // 推币机
|
|
||||||
__GameId_ThrGame_Min__ = 700 //################三方类################
|
__GameId_ThrGame_Min__ = 700 //################三方类################
|
||||||
GameId_Thr_Dg = 701 //DG Game
|
GameId_Thr_Dg = 701 //DG Game
|
||||||
GameId_Thr_XHJ = 901 ///DG Game
|
GameId_Thr_XHJ = 901 ///DG Game
|
||||||
|
|
Binary file not shown.
|
@ -4520,7 +4520,7 @@
|
||||||
{
|
{
|
||||||
"Id": 2110001,
|
"Id": 2110001,
|
||||||
"Name": "十三张四人",
|
"Name": "十三张四人",
|
||||||
"Title": "新手场",
|
"Title": "1",
|
||||||
"GameId": 211,
|
"GameId": 211,
|
||||||
"GameRule": 21100,
|
"GameRule": 21100,
|
||||||
"GameType": 2,
|
"GameType": 2,
|
||||||
|
@ -4574,7 +4574,7 @@
|
||||||
{
|
{
|
||||||
"Id": 2110002,
|
"Id": 2110002,
|
||||||
"Name": "十三张四人",
|
"Name": "十三张四人",
|
||||||
"Title": "小康场",
|
"Title": "2",
|
||||||
"GameId": 211,
|
"GameId": 211,
|
||||||
"GameRule": 21100,
|
"GameRule": 21100,
|
||||||
"GameType": 2,
|
"GameType": 2,
|
||||||
|
@ -4628,7 +4628,7 @@
|
||||||
{
|
{
|
||||||
"Id": 2110003,
|
"Id": 2110003,
|
||||||
"Name": "十三张四人",
|
"Name": "十三张四人",
|
||||||
"Title": "土豪场",
|
"Title": "3",
|
||||||
"GameId": 211,
|
"GameId": 211,
|
||||||
"GameRule": 21100,
|
"GameRule": 21100,
|
||||||
"GameType": 2,
|
"GameType": 2,
|
||||||
|
@ -4682,7 +4682,7 @@
|
||||||
{
|
{
|
||||||
"Id": 2110004,
|
"Id": 2110004,
|
||||||
"Name": "十三张四人",
|
"Name": "十三张四人",
|
||||||
"Title": "新手场",
|
"Title": "4",
|
||||||
"GameId": 211,
|
"GameId": 211,
|
||||||
"GameRule": 21100,
|
"GameRule": 21100,
|
||||||
"GameType": 2,
|
"GameType": 2,
|
||||||
|
@ -4736,7 +4736,7 @@
|
||||||
{
|
{
|
||||||
"Id": 2110005,
|
"Id": 2110005,
|
||||||
"Name": "十三张四人",
|
"Name": "十三张四人",
|
||||||
"Title": "小康场",
|
"Title": "5",
|
||||||
"GameId": 211,
|
"GameId": 211,
|
||||||
"GameRule": 21100,
|
"GameRule": 21100,
|
||||||
"GameType": 2,
|
"GameType": 2,
|
||||||
|
@ -4790,7 +4790,7 @@
|
||||||
{
|
{
|
||||||
"Id": 2110006,
|
"Id": 2110006,
|
||||||
"Name": "十三张四人",
|
"Name": "十三张四人",
|
||||||
"Title": "土豪场",
|
"Title": "6",
|
||||||
"GameId": 211,
|
"GameId": 211,
|
||||||
"GameRule": 21100,
|
"GameRule": 21100,
|
||||||
"GameType": 2,
|
"GameType": 2,
|
||||||
|
@ -4843,7 +4843,7 @@
|
||||||
{
|
{
|
||||||
"Id": 2120001,
|
"Id": 2120001,
|
||||||
"Name": "十三张八人",
|
"Name": "十三张八人",
|
||||||
"Title": "新手场",
|
"Title": "1",
|
||||||
"GameId": 212,
|
"GameId": 212,
|
||||||
"GameRule": 21200,
|
"GameRule": 21200,
|
||||||
"GameType": 2,
|
"GameType": 2,
|
||||||
|
@ -4897,7 +4897,7 @@
|
||||||
{
|
{
|
||||||
"Id": 2120002,
|
"Id": 2120002,
|
||||||
"Name": "十三张八人",
|
"Name": "十三张八人",
|
||||||
"Title": "小康场",
|
"Title": "2",
|
||||||
"GameId": 212,
|
"GameId": 212,
|
||||||
"GameRule": 21200,
|
"GameRule": 21200,
|
||||||
"GameType": 2,
|
"GameType": 2,
|
||||||
|
@ -4951,7 +4951,7 @@
|
||||||
{
|
{
|
||||||
"Id": 2120003,
|
"Id": 2120003,
|
||||||
"Name": "十三张八人",
|
"Name": "十三张八人",
|
||||||
"Title": "土豪场",
|
"Title": "3",
|
||||||
"GameId": 212,
|
"GameId": 212,
|
||||||
"GameRule": 21200,
|
"GameRule": 21200,
|
||||||
"GameType": 2,
|
"GameType": 2,
|
||||||
|
@ -5005,7 +5005,7 @@
|
||||||
{
|
{
|
||||||
"Id": 2120004,
|
"Id": 2120004,
|
||||||
"Name": "十三张八人",
|
"Name": "十三张八人",
|
||||||
"Title": "新手场",
|
"Title": "4",
|
||||||
"GameId": 212,
|
"GameId": 212,
|
||||||
"GameRule": 21200,
|
"GameRule": 21200,
|
||||||
"GameType": 2,
|
"GameType": 2,
|
||||||
|
@ -5059,7 +5059,7 @@
|
||||||
{
|
{
|
||||||
"Id": 2120005,
|
"Id": 2120005,
|
||||||
"Name": "十三张八人",
|
"Name": "十三张八人",
|
||||||
"Title": "小康场",
|
"Title": "5",
|
||||||
"GameId": 212,
|
"GameId": 212,
|
||||||
"GameRule": 21200,
|
"GameRule": 21200,
|
||||||
"GameType": 2,
|
"GameType": 2,
|
||||||
|
@ -5113,7 +5113,7 @@
|
||||||
{
|
{
|
||||||
"Id": 2120006,
|
"Id": 2120006,
|
||||||
"Name": "十三张八人",
|
"Name": "十三张八人",
|
||||||
"Title": "土豪场",
|
"Title": "6",
|
||||||
"GameId": 212,
|
"GameId": 212,
|
||||||
"GameRule": 21200,
|
"GameRule": 21200,
|
||||||
"GameType": 2,
|
"GameType": 2,
|
||||||
|
@ -7019,27 +7019,6 @@
|
||||||
"PlayerWaterRate": 100,
|
"PlayerWaterRate": 100,
|
||||||
"BetWaterRate": 100,
|
"BetWaterRate": 100,
|
||||||
"GameName": "娃娃机"
|
"GameName": "娃娃机"
|
||||||
},
|
|
||||||
{
|
|
||||||
"Id": 6090001,
|
|
||||||
"Name": "推币机",
|
|
||||||
"GameId": 609,
|
|
||||||
"GameRule": 60900,
|
|
||||||
"GameType": 5,
|
|
||||||
"SceneType": 1,
|
|
||||||
"ShowType": 3,
|
|
||||||
"ShowId": 60900,
|
|
||||||
"Turn": 60900,
|
|
||||||
"OtherIntParams": [
|
|
||||||
5000,
|
|
||||||
10000,
|
|
||||||
15000
|
|
||||||
],
|
|
||||||
"SameIpLimit": 1,
|
|
||||||
"GameDif": "609",
|
|
||||||
"GameClass": 2,
|
|
||||||
"PlatformName": "越南棋牌",
|
|
||||||
"GameName": "推币机"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
Binary file not shown.
|
@ -267,12 +267,6 @@
|
||||||
"Name": "娃娃机",
|
"Name": "娃娃机",
|
||||||
"GameId": 608,
|
"GameId": 608,
|
||||||
"GameDif": "608"
|
"GameDif": "608"
|
||||||
},
|
|
||||||
{
|
|
||||||
"Id": 60900,
|
|
||||||
"Name": "推币机",
|
|
||||||
"GameId": 609,
|
|
||||||
"GameDif": "609"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -1,84 +0,0 @@
|
||||||
|
|
||||||
"¡<>"¢<>d"¹ê
|
|
||||||
"¡<>"¢<>d"¸ê
|
|
||||||
"¡<>"¢<>d"¸ê
|
|
||||||
"¡<>"¢<>d
|
|
||||||
"¡<>"¢<>c
|
|
||||||
"¡<>"¢<>b
|
|
||||||
"¡<>"¢<>a
|
|
||||||
"¡<>"¢<>`
|
|
||||||
"¡<>"¢<>_
|
|
||||||
|
|
||||||
|
|
||||||
"¡<>"¢<>^
|
|
||||||
"¡<>"¢<>]
|
|
||||||
"¢<>\"¡<>
|
|
||||||
"¡<>"¢<>[
|
|
||||||
"¡<>"¢<>Z
|
|
||||||
"¡<>"¢<>Y
|
|
||||||
"¡<>"¢<>X
|
|
||||||
"¡<>"¢<>W
|
|
||||||
"¡<>"¢<>V
|
|
||||||
"¡<>"¢<>U
|
|
||||||
"¡<>"¢<>T
|
|
||||||
"¡<>"¢<>S
|
|
||||||
"¡<>"¢<>R
|
|
||||||
"¡<>"¢<>Q
|
|
||||||
"¡<>"¢<>P
|
|
||||||
"¡<>"¢<>O
|
|
||||||
"¡<>"¢<>N
|
|
||||||
"¡<>"¢<>M
|
|
||||||
"¡<>"¢<>L
|
|
||||||
"¡<>"¢<>K
|
|
||||||
"¡<>"¢<>J
|
|
||||||
"¡<>"¢<>I
|
|
||||||
"¡<>"¢<>H
|
|
||||||
!!"¡<>"¢<>G
|
|
||||||
"""¡<>"¢<>F
|
|
||||||
##"¡<>"¢<>E
|
|
||||||
$$"¡<>"¢<>D
|
|
||||||
%%"¡<>"¢<>C
|
|
||||||
&&"¢<>B"¡<>
|
|
||||||
''"¡<>"¢<>A
|
|
||||||
(("¢<>@"¡<>
|
|
||||||
)"¡<>"¢<>d"¹ê
|
|
||||||
*"¡<>"¢<>d"¸ê
|
|
||||||
+"¢<>d"¸ê"¡<>
|
|
||||||
,"¡<>"¢<>d
|
|
||||||
-"¡<>"¢<>c
|
|
||||||
."¡<>"¢<>b
|
|
||||||
/"¡<>"¢<>a
|
|
||||||
0"¡<>"¢<>`
|
|
||||||
1 "¡<>"¢<>_
|
|
||||||
2
|
|
||||||
"¡<>"¢<>^
|
|
||||||
3"¡<>"¢<>]
|
|
||||||
4"¡<>"¢<>\
|
|
||||||
5
"¡<>"¢<>[
|
|
||||||
6"¡<>"¢<>Z
|
|
||||||
7"¡<>"¢<>Y
|
|
||||||
8"¢<>X"¡<>
|
|
||||||
9"¢<>W"¡<>
|
|
||||||
:"¡<>"¢<>V
|
|
||||||
;"¡<>"¢<>U
|
|
||||||
<"¡<>"¢<>T
|
|
||||||
="¡<>"¢<>S
|
|
||||||
>"¢<>R"¡<>
|
|
||||||
?"¡<>"¢<>Q
|
|
||||||
@"¡<>"¢<>P
|
|
||||||
A"¡<>"¢<>O
|
|
||||||
B"¡<>"¢<>N
|
|
||||||
C"¡<>"¢<>M
|
|
||||||
D"¡<>"¢<>L
|
|
||||||
E"¡<>"¢<>K
|
|
||||||
F"¢<>J"¡<>
|
|
||||||
G"¡<>"¢<>I
|
|
||||||
H "¡<>"¢<>H
|
|
||||||
I!"¡<>"¢<>G
|
|
||||||
J""¡<>"¢<>F
|
|
||||||
K#"¡<>"¢<>E
|
|
||||||
L$"¡<>"¢<>D
|
|
||||||
M%"¡<>"¢<>C
|
|
||||||
N&"¡<>"¢<>B
|
|
||||||
O'"¡<>"¢<>A
|
|
||||||
P("¡<>"¢<>@
|
|
Binary file not shown.
BIN
data/DB_Task.dat
BIN
data/DB_Task.dat
Binary file not shown.
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"GameName":"推币机",
|
|
||||||
"GameId":609,
|
|
||||||
"GameMode":[0],
|
|
||||||
"SceneType":[1],
|
|
||||||
"CanForceStart":true,
|
|
||||||
"MinPlayerCnt":1,
|
|
||||||
"DefaultPlayerCnt":1
|
|
||||||
}
|
|
|
@ -193,9 +193,5 @@
|
||||||
|
|
||||||
- 5660~5669
|
- 5660~5669
|
||||||
|
|
||||||
### pushcoin.proto
|
|
||||||
|
|
||||||
- 5670~5679
|
|
||||||
|
|
||||||
### game.proto(玩家离开)
|
### game.proto(玩家离开)
|
||||||
- 8000~8099
|
- 8000~8099
|
File diff suppressed because it is too large
Load Diff
|
@ -1,103 +0,0 @@
|
||||||
syntax = "proto3";
|
|
||||||
package pushcoin;
|
|
||||||
option go_package = "mongo.games.com/game/protocol/pushcoin";
|
|
||||||
|
|
||||||
// 5670~5679
|
|
||||||
enum PushCoinPacketID {
|
|
||||||
PACKET_PushCoin_ZERO = 0;// 弃用消息号
|
|
||||||
PACKET_SCPushCoinRoomInfo = 5670; // 房间信息
|
|
||||||
PACKET_SCPushCoinRoomState = 5671; // 房间状态
|
|
||||||
PACKET_CSPushCoinPlayerOp = 5672; // 玩家操作
|
|
||||||
PACKET_SCPushCoinPlayerOp = 5673; // 玩家操作返回
|
|
||||||
}
|
|
||||||
|
|
||||||
//房间信息
|
|
||||||
//PACKET_SCPushCoinRoomInfo
|
|
||||||
message SCPushCoinRoomInfo {
|
|
||||||
int32 RoomId = 1; //房间id
|
|
||||||
int32 GameId = 2; //游戏id
|
|
||||||
int32 RoomMode = 3; //游戏模式
|
|
||||||
repeated int32 Params = 4; //规则参数
|
|
||||||
int32 State = 5; //房间当前状态
|
|
||||||
int32 TimeOut = 6; //等待剩余时间 单位:秒
|
|
||||||
repeated PushCoinPlayerData Players = 7; //房间内的玩家信息
|
|
||||||
repeated ExchangeInfo ExchangeList = 8; //兑换信息
|
|
||||||
repeated DrawInfo DrawList = 9; //抽奖信息
|
|
||||||
}
|
|
||||||
|
|
||||||
message ItemInfo{
|
|
||||||
int32 ItemId = 1; //道具id
|
|
||||||
int32 ItemNum = 2; //道具数量
|
|
||||||
}
|
|
||||||
|
|
||||||
message ExchangeInfo{
|
|
||||||
int32 Id = 1; //兑换id
|
|
||||||
repeated ItemInfo Cost = 2; //消耗道具
|
|
||||||
repeated ItemInfo Gain = 3; //获得道具
|
|
||||||
int32 ShakeTimes = 4; //获得震动次数
|
|
||||||
}
|
|
||||||
|
|
||||||
message DrawInfo{
|
|
||||||
int32 Id = 1; //抽奖id
|
|
||||||
int32 ItemId = 2; //道具id
|
|
||||||
int32 ItemNum = 3; //道具数量
|
|
||||||
int64 Coin = 4; //价值
|
|
||||||
}
|
|
||||||
|
|
||||||
message PushCoinPlayerData {
|
|
||||||
string Name = 1; //名字
|
|
||||||
int32 SnId = 2; //账号
|
|
||||||
int32 Head = 3; //头像
|
|
||||||
int32 Sex = 4; //性别
|
|
||||||
int64 Coin = 5; //金币
|
|
||||||
int32 Flag = 6; //二进制标记 第一位:是否掉线(0:在线 1:掉线) 第二位:是否准备(0:未准备 1:已准备)
|
|
||||||
repeated string Params = 7; //其他数据 如:ip 等
|
|
||||||
int32 VIP = 8;
|
|
||||||
int32 RoleId = 9; //使用中的角色id
|
|
||||||
int64 Level = 10; //玩家等级
|
|
||||||
int64 Exp = 11; //玩家经验
|
|
||||||
int32 SkinId = 12; //皮肤id
|
|
||||||
int32 ShakeTimes = 13; //可震动次数
|
|
||||||
int64 BaseCoin = 14; //当前底分(单次投币金额)
|
|
||||||
int64 PowerLine = 15; // 当前能量值
|
|
||||||
int64 PowerLineMax = 16; // 能量值上限
|
|
||||||
int64 RefreshTimes = 17; // 刷新次数
|
|
||||||
}
|
|
||||||
|
|
||||||
//房间状态
|
|
||||||
//PACKET_SCPushCoinRoomState
|
|
||||||
message SCPushCoinRoomState {
|
|
||||||
int32 State = 1; //房间当前状态
|
|
||||||
int32 SubState = 2; //房间当前子状态
|
|
||||||
repeated int32 Params = 3; //状态参数
|
|
||||||
}
|
|
||||||
|
|
||||||
//玩家操作
|
|
||||||
//PACKET_CSPushCoinPlayerOp
|
|
||||||
message CSPushCoinPlayerOp {
|
|
||||||
OpCodes OpCode = 1;
|
|
||||||
repeated int64 OpParam = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum OpCodes {
|
|
||||||
OP_Zero = 0;
|
|
||||||
OP_Bet = 1; // 下注 [下注金额]
|
|
||||||
OP_Gain = 2; // 得分 [得分金额]
|
|
||||||
OP_Shake = 3; // 震动 [消耗次数]
|
|
||||||
OP_Refresh = 4; // 刷新 [桌面金额]
|
|
||||||
OP_Exchange = 5; // 兑换 [兑换id]
|
|
||||||
OP_Draw = 6; // 抽奖 [抽奖id]
|
|
||||||
}
|
|
||||||
|
|
||||||
enum OpResultCode {
|
|
||||||
OPRC_Success = 0; //成功
|
|
||||||
OPRC_Error = 1; //失败
|
|
||||||
}
|
|
||||||
|
|
||||||
//PACKET_SCPushCoinPlayerOp
|
|
||||||
message SCPushCoinPlayerOp {
|
|
||||||
OpResultCode OpRetCode = 1;
|
|
||||||
OpCodes OpCode = 2;
|
|
||||||
ExchangeInfo Exchange = 3; // 兑换信息,加到背包
|
|
||||||
DrawInfo Draw = 4; // 抽奖信息,掉落到桌面
|
|
||||||
}
|
|
|
@ -1,95 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"math/rand"
|
|
||||||
"mongo.games.com/goserver/core/timer"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
|
||||||
"mongo.games.com/goserver/core/netlib"
|
|
||||||
|
|
||||||
"mongo.games.com/game/model"
|
|
||||||
"mongo.games.com/game/proto"
|
|
||||||
loginproto "mongo.games.com/game/protocol/login"
|
|
||||||
playerproto "mongo.games.com/game/protocol/player"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
// 心跳
|
|
||||||
netlib.Register(int(loginproto.GatePacketID_PACKET_SC_PONG), loginproto.SCPong{}, SCPong)
|
|
||||||
// 登录
|
|
||||||
netlib.Register(int(loginproto.LoginPacketID_PACKET_SC_LOGIN), loginproto.SCLogin{}, SCLogin)
|
|
||||||
// 玩家信息
|
|
||||||
netlib.Register(int(playerproto.PlayerPacketID_PACKET_SC_PLAYERDATA), playerproto.SCPlayerData{}, SCPlayerData)
|
|
||||||
}
|
|
||||||
|
|
||||||
func SCPong(s *netlib.Session, packetid int, data interface{}) error {
|
|
||||||
accountID := s.GetAttribute(SessionAttributeClientAccountId)
|
|
||||||
logger.Logger.Tracef("SCPong username:%v %v", accountID, data)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func SCLogin(s *netlib.Session, packetid int, data interface{}) error {
|
|
||||||
logger.Logger.Trace("SCLogin ", data)
|
|
||||||
|
|
||||||
msg, ok := data.(*loginproto.SCLogin)
|
|
||||||
if !ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if msg.GetOpRetCode() != loginproto.OpResultCode_OPRC_Sucess {
|
|
||||||
accountID := s.GetAttribute(SessionAttributeClientAccountId)
|
|
||||||
logger.Logger.Error("登录失败 ", accountID)
|
|
||||||
s.Close()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
csPlayerData := &playerproto.CSPlayerData{
|
|
||||||
AccId: msg.GetAccId(),
|
|
||||||
}
|
|
||||||
pp := &model.PlayerParams{
|
|
||||||
Platform: 1,
|
|
||||||
Ip: fmt.Sprintf("%v.%v.%v.%v", 1+rand.Int31n(255), 1+rand.Int31n(255), 1+rand.Int31n(255), 1+rand.Int31n(255)),
|
|
||||||
City: "北京",
|
|
||||||
Logininmodel: "app",
|
|
||||||
}
|
|
||||||
d, err := json.Marshal(pp)
|
|
||||||
if err == nil {
|
|
||||||
csPlayerData.Params = proto.String(string(d))
|
|
||||||
}
|
|
||||||
|
|
||||||
s.Send(int(playerproto.PlayerPacketID_PACKET_CS_PLAYERDATA), csPlayerData)
|
|
||||||
logger.Logger.Info("登录成功 ", msg.GetAccId())
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func SCPlayerData(s *netlib.Session, packetid int, data interface{}) error {
|
|
||||||
logger.Logger.Trace("SCPlayerData ", data)
|
|
||||||
msg, ok := data.(*playerproto.SCPlayerData)
|
|
||||||
if !ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if msg.GetOpRetCode() != playerproto.OpResultCode_OPRC_Sucess {
|
|
||||||
accountID := s.GetAttribute(SessionAttributeClientAccountId)
|
|
||||||
logger.Logger.Errorf("获取玩家信息失败 %v", accountID)
|
|
||||||
s.Close()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
s.SetAttribute(SessionAttributeUser, msg)
|
|
||||||
|
|
||||||
StartSessionPingTimer(s, timer.TimerActionWrapper(func(h timer.TimerHandle, ud interface{}) bool {
|
|
||||||
if !s.IsConned() {
|
|
||||||
StopSessionPingTimer(s)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
pack := &loginproto.CSPing{}
|
|
||||||
s.Send(int(loginproto.GatePacketID_PACKET_CS_PING), pack)
|
|
||||||
return true
|
|
||||||
}), nil, time.Second*time.Duration(60+rand.Int31n(100)), -1)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"mongo.games.com/goserver/core"
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
|
||||||
"mongo.games.com/goserver/core/netlib"
|
|
||||||
)
|
|
||||||
|
|
||||||
var Config = &Configuration{}
|
|
||||||
|
|
||||||
type Configuration struct {
|
|
||||||
Count int // 机器人总数
|
|
||||||
AppId string // appID
|
|
||||||
Connects netlib.SessionConfig // 网络连接配置
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *Configuration) Name() string {
|
|
||||||
return "benchmark"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *Configuration) Init() error {
|
|
||||||
logger.Logger.Tracef("%+v", *this)
|
|
||||||
if this.Count == 0 {
|
|
||||||
this.Count = 20
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *Configuration) Close() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
core.RegistePackage(Config)
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
netlib:
|
|
||||||
SrvInfo:
|
|
||||||
Name: BenchmarkServer
|
|
||||||
Type: 9
|
|
||||||
Id: 902
|
|
||||||
AreaID: 1
|
|
||||||
Banner:
|
|
||||||
- =================
|
|
||||||
- benchmark server
|
|
||||||
- =================
|
|
||||||
IoServices: []
|
|
||||||
module:
|
|
||||||
Options:
|
|
||||||
QueueBacklog: 1024
|
|
||||||
MaxDone: 1024
|
|
||||||
Interval: 100
|
|
||||||
executor:
|
|
||||||
Options:
|
|
||||||
QueueBacklog: 1024
|
|
||||||
MaxDone: 1024
|
|
||||||
Interval: 0
|
|
||||||
Worker:
|
|
||||||
WorkerCnt: 8
|
|
||||||
Options:
|
|
||||||
QueueBacklog: 1024
|
|
||||||
MaxDone: 1024
|
|
||||||
Interval: 0
|
|
||||||
timer:
|
|
||||||
Options:
|
|
||||||
QueueBacklog: 1024
|
|
||||||
MaxDone: 1024
|
|
||||||
Interval: 100
|
|
||||||
signal:
|
|
||||||
SupportSignal: true
|
|
||||||
benchmark:
|
|
||||||
Count: 100
|
|
||||||
AppId: 5c56d1644966f078bfb90c71
|
|
||||||
Connects:
|
|
||||||
Id: 402
|
|
||||||
Type: 4
|
|
||||||
AreaId: 1
|
|
||||||
Name: ClientService
|
|
||||||
Ip: 127.0.0.1
|
|
||||||
Port: 11001
|
|
||||||
Protocol: tcp
|
|
||||||
Path: /
|
|
||||||
MaxDone: 200
|
|
||||||
MaxPend: 200
|
|
||||||
MaxPacket: 65535
|
|
||||||
MaxConn: 2000
|
|
||||||
RcvBuff: 4096
|
|
||||||
SndBuff: 4096
|
|
||||||
WriteTimeout: 3600
|
|
||||||
ReadTimeout: 3600
|
|
||||||
SoLinger: 10
|
|
||||||
IsInnerLink: true
|
|
||||||
NoDelay: true
|
|
||||||
SupportFragment: true
|
|
||||||
AuthKey: www.jxjy.games.cn
|
|
||||||
IsClient: true
|
|
||||||
AllowMultiConn: true
|
|
||||||
FilterChain:
|
|
||||||
- session-filter-auth
|
|
||||||
HandlerChain:
|
|
||||||
- handler-gate-session
|
|
|
@ -1,69 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
|
||||||
"mongo.games.com/goserver/core/module"
|
|
||||||
"mongo.games.com/goserver/core/netlib"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// RobotSessionStartId 机器人session开始id
|
|
||||||
RobotSessionStartId = 100000000
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
BenchMarkModule = &BenchMark{}
|
|
||||||
WaitConnectSessions []*netlib.SessionConfig
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewSession 新建session
|
|
||||||
// id 连接id, 默认自动分配
|
|
||||||
func NewSession(id ...int) {
|
|
||||||
cfg := Config.Connects
|
|
||||||
if len(id) > 0 && id[0] > 0 {
|
|
||||||
cfg.Id = id[0]
|
|
||||||
} else {
|
|
||||||
BenchMarkModule.idx++
|
|
||||||
cfg.Id = BenchMarkModule.idx
|
|
||||||
}
|
|
||||||
cfg.Init()
|
|
||||||
logger.Logger.Info("waite connect session id=", cfg.Id)
|
|
||||||
WaitConnectSessions = append(WaitConnectSessions, &cfg)
|
|
||||||
}
|
|
||||||
|
|
||||||
type BenchMark struct {
|
|
||||||
idx int
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *BenchMark) ModuleName() string {
|
|
||||||
return "benchmark-module"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *BenchMark) Init() {
|
|
||||||
m.idx = RobotSessionStartId
|
|
||||||
for i := 0; i < Config.Count; i++ {
|
|
||||||
NewSession()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update 机器开始连接游戏服务器
|
|
||||||
func (m *BenchMark) Update() {
|
|
||||||
n := len(WaitConnectSessions)
|
|
||||||
if n > 0 {
|
|
||||||
config := WaitConnectSessions[n-1]
|
|
||||||
WaitConnectSessions = WaitConnectSessions[:n-1]
|
|
||||||
if err := netlib.Connect(config); err != nil {
|
|
||||||
logger.Logger.Error("netlib.Connect error", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *BenchMark) Shutdown() {
|
|
||||||
module.UnregisteModule(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
module.RegisteModule(BenchMarkModule, time.Millisecond, 1)
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"mongo.games.com/goserver/core/netlib"
|
|
||||||
"mongo.games.com/goserver/core/timer"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
SessionAttributeClientAccountId int = iota // 账号
|
|
||||||
SessionAttributeUser
|
|
||||||
SessionAttributePingTimer
|
|
||||||
)
|
|
||||||
|
|
||||||
func StartSessionPingTimer(s *netlib.Session, act timer.TimerAction, ud interface{}, interval time.Duration, times int) bool {
|
|
||||||
StopSessionPingTimer(s)
|
|
||||||
if hTimer, ok := timer.StartTimer(act, ud, interval, times); ok {
|
|
||||||
s.SetAttribute(SessionAttributePingTimer, hTimer)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func StopSessionPingTimer(s *netlib.Session) {
|
|
||||||
if h, ok := s.GetAttribute(SessionAttributePingTimer).(timer.TimerHandle); ok {
|
|
||||||
if h != timer.TimerHandle(0) {
|
|
||||||
timer.StopTimer(h)
|
|
||||||
s.RemoveAttribute(SessionAttributePingTimer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,97 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/md5"
|
|
||||||
"encoding/hex"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"math/rand"
|
|
||||||
"mongo.games.com/game/common"
|
|
||||||
"mongo.games.com/game/model"
|
|
||||||
loginproto "mongo.games.com/game/protocol/login"
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
|
||||||
"mongo.games.com/goserver/core/netlib"
|
|
||||||
"strconv"
|
|
||||||
"sync/atomic"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
/*
|
|
||||||
添加到客户端管理器,管理器负责登录
|
|
||||||
当连接断开时,从管理器中移除,判断是否需要重连
|
|
||||||
*/
|
|
||||||
|
|
||||||
const (
|
|
||||||
GateSessionHandlerName = "handler-gate-session"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GateSessionHandler struct {
|
|
||||||
netlib.BasicSessionHandler
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GateSessionHandler) GetName() string {
|
|
||||||
return GateSessionHandlerName
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GateSessionHandler) GetInterestOps() uint {
|
|
||||||
return 1<<netlib.InterestOps_Opened |
|
|
||||||
1<<netlib.InterestOps_Closed
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GateSessionHandler) OnSessionOpened(s *netlib.Session) {
|
|
||||||
// 登录账号
|
|
||||||
StartLogin(s)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GateSessionHandler) OnSessionClosed(s *netlib.Session) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
netlib.RegisteSessionHandlerCreator(GateSessionHandlerName, func() netlib.SessionHandler {
|
|
||||||
return &GateSessionHandler{}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var UserNameIndex int64
|
|
||||||
|
|
||||||
func StartLogin(s *netlib.Session) {
|
|
||||||
ts := time.Now().UnixNano()
|
|
||||||
username := fmt.Sprintf("benchmark-%v", atomic.AddInt64(&UserNameIndex, 1))
|
|
||||||
s.SetAttribute(SessionAttributeClientAccountId, username)
|
|
||||||
csLogin := &loginproto.CSLogin{
|
|
||||||
Username: username,
|
|
||||||
TimeStamp: ts,
|
|
||||||
Platform: "1",
|
|
||||||
Channel: "",
|
|
||||||
PlatformTag: "test.win88.yy_android",
|
|
||||||
}
|
|
||||||
|
|
||||||
params := &model.PlayerParams{
|
|
||||||
Ip: fmt.Sprintf("%v.%v.%v.%v", 1+rand.Int31n(255), 1+rand.Int31n(255), 1+rand.Int31n(255), 1+rand.Int31n(255)),
|
|
||||||
City: "北京",
|
|
||||||
Platform: 1,
|
|
||||||
Logininmodel: "app",
|
|
||||||
}
|
|
||||||
data, err := json.Marshal(params)
|
|
||||||
if err == nil {
|
|
||||||
csLogin.Params = string(data[:])
|
|
||||||
}
|
|
||||||
|
|
||||||
h := md5.New()
|
|
||||||
io.WriteString(h, fmt.Sprintf("%v%v", username, Config.AppId))
|
|
||||||
pwd := hex.EncodeToString(h.Sum(nil))
|
|
||||||
h.Reset()
|
|
||||||
io.WriteString(h, fmt.Sprintf("%v%v%v", pwd, Config.AppId, ts))
|
|
||||||
pwd = hex.EncodeToString(h.Sum(nil))
|
|
||||||
csLogin.Password = pwd
|
|
||||||
|
|
||||||
csLogin.LoginType = 0
|
|
||||||
csLogin.Sign = common.MakeMd5String(csLogin.GetUsername(), csLogin.GetPassword(),
|
|
||||||
strconv.Itoa(int(csLogin.GetTimeStamp())), csLogin.GetParams(), Config.AppId)
|
|
||||||
|
|
||||||
s.Send(int(loginproto.LoginPacketID_PACKET_CS_LOGIN), csLogin)
|
|
||||||
logger.Logger.Infof("账号 [%v] 开始登录", username)
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<seelog type="adaptive" mininterval="2000000" maxinterval="100000000" critmsgcount="500" minlevel="trace">
|
|
||||||
<exceptions>
|
|
||||||
<exception filepattern="test*" minlevel="error"/>
|
|
||||||
</exceptions>
|
|
||||||
<outputs formatid="all">
|
|
||||||
<rollingfile formatid="all" type="size" filename="./all.log" maxsize="50000000" maxrolls="5" />
|
|
||||||
<filter levels="info,trace,warn,error">
|
|
||||||
<console formatid="fmtinfo"/>
|
|
||||||
</filter>
|
|
||||||
<filter levels="error,critical" formatid="fmterror">
|
|
||||||
<console/>
|
|
||||||
<file path="errors.log"/>
|
|
||||||
</filter>
|
|
||||||
</outputs>
|
|
||||||
<formats>
|
|
||||||
<format id="fmtinfo" format="[%Date][%Time] [%Level] %Msg%n"/>
|
|
||||||
<format id="fmterror" format="[%Date][%Time] [%LEVEL] [%FuncShort @ %File.%Line] %Msg%n"/>
|
|
||||||
<format id="all" format="[%Date][%Time] [%Level] [@ %File.%Line] %Msg%n"/>
|
|
||||||
<format id="criticalemail" format="Critical error on our server!\n %Time %Date %RelFile %Func %Msg \nSent by Seelog"/>
|
|
||||||
</formats>
|
|
||||||
</seelog>
|
|
|
@ -1,25 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
_ "mongo.games.com/game"
|
|
||||||
|
|
||||||
"mongo.games.com/goserver/core"
|
|
||||||
"mongo.games.com/goserver/core/module"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
defer core.ClosePackages()
|
|
||||||
core.LoadPackages("config.yaml")
|
|
||||||
// core hook
|
|
||||||
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
|
||||||
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
|
|
||||||
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
// module模块
|
|
||||||
waiter := module.Start()
|
|
||||||
waiter.Wait("main()")
|
|
||||||
}
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"slices"
|
"slices"
|
||||||
"sort"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
@ -2314,10 +2313,6 @@ func (this *WelfareMgr) SendRedPacketInfo(p *Player) *welfare.SCRedPacketInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(pack.Info, func(i, j int) bool {
|
|
||||||
return pack.Info[i].StartTs < pack.Info[j].StartTs
|
|
||||||
})
|
|
||||||
|
|
||||||
p.SendToClient(int(welfare.SPacketID_PACKET_SCRedPacketInfo), pack)
|
p.SendToClient(int(welfare.SPacketID_PACKET_SCRedPacketInfo), pack)
|
||||||
return pack
|
return pack
|
||||||
}
|
}
|
||||||
|
@ -2406,7 +2401,7 @@ func (this *WelfareMgr) GetRedPacket(p *Player, id int64) *welfare.SCRedPacketDr
|
||||||
f := func() {
|
f := func() {
|
||||||
// 概率抽奖
|
// 概率抽奖
|
||||||
rate := 0
|
rate := 0
|
||||||
n := rand.Int63n(10000)
|
n := rand.Int63n(100)
|
||||||
for _, v := range cfg.GetRedList() {
|
for _, v := range cfg.GetRedList() {
|
||||||
rate += int(v.GetRate())
|
rate += int(v.GetRate())
|
||||||
if n < int64(rate) {
|
if n < int64(rate) {
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue