上传协议测试工具代码
This commit is contained in:
parent
4cd4b89be6
commit
0c3cf4b7a1
22
package-lock.json
generated
22
package-lock.json
generated
@ -11,6 +11,8 @@
|
|||||||
"@mdi/font": "5.9.55",
|
"@mdi/font": "5.9.55",
|
||||||
"core-js": "^3.8.3",
|
"core-js": "^3.8.3",
|
||||||
"google-protobuf": "^3.20.1",
|
"google-protobuf": "^3.20.1",
|
||||||
|
"js-base64": "^3.7.2",
|
||||||
|
"js-md5": "^0.7.3",
|
||||||
"protobufjs": "^6.11.3",
|
"protobufjs": "^6.11.3",
|
||||||
"roboto-fontface": "*",
|
"roboto-fontface": "*",
|
||||||
"vue": "^3.2.13",
|
"vue": "^3.2.13",
|
||||||
@ -7527,6 +7529,16 @@
|
|||||||
"@sideway/pinpoint": "^2.0.0"
|
"@sideway/pinpoint": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/js-base64": {
|
||||||
|
"version": "3.7.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.2.tgz",
|
||||||
|
"integrity": "sha512-NnRs6dsyqUXejqk/yv2aiXlAvOs56sLkX6nUdeaNezI5LFFLlsZjOThmwnrcwh5ZZRwZlCMnVAY3CvhIhoVEKQ=="
|
||||||
|
},
|
||||||
|
"node_modules/js-md5": {
|
||||||
|
"version": "0.7.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/js-md5/-/js-md5-0.7.3.tgz",
|
||||||
|
"integrity": "sha512-ZC41vPSTLKGwIRjqDh8DfXoCrdQIyBgspJVPXHBGu4nZlAEvG3nf+jO9avM9RmLiGakg7vz974ms99nEV0tmTQ=="
|
||||||
|
},
|
||||||
"node_modules/js-message": {
|
"node_modules/js-message": {
|
||||||
"version": "1.0.7",
|
"version": "1.0.7",
|
||||||
"resolved": "https://registry.npmmirror.com/js-message/-/js-message-1.0.7.tgz",
|
"resolved": "https://registry.npmmirror.com/js-message/-/js-message-1.0.7.tgz",
|
||||||
@ -17862,6 +17874,16 @@
|
|||||||
"@sideway/pinpoint": "^2.0.0"
|
"@sideway/pinpoint": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"js-base64": {
|
||||||
|
"version": "3.7.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.2.tgz",
|
||||||
|
"integrity": "sha512-NnRs6dsyqUXejqk/yv2aiXlAvOs56sLkX6nUdeaNezI5LFFLlsZjOThmwnrcwh5ZZRwZlCMnVAY3CvhIhoVEKQ=="
|
||||||
|
},
|
||||||
|
"js-md5": {
|
||||||
|
"version": "0.7.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/js-md5/-/js-md5-0.7.3.tgz",
|
||||||
|
"integrity": "sha512-ZC41vPSTLKGwIRjqDh8DfXoCrdQIyBgspJVPXHBGu4nZlAEvG3nf+jO9avM9RmLiGakg7vz974ms99nEV0tmTQ=="
|
||||||
|
},
|
||||||
"js-message": {
|
"js-message": {
|
||||||
"version": "1.0.7",
|
"version": "1.0.7",
|
||||||
"resolved": "https://registry.npmmirror.com/js-message/-/js-message-1.0.7.tgz",
|
"resolved": "https://registry.npmmirror.com/js-message/-/js-message-1.0.7.tgz",
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
"@mdi/font": "5.9.55",
|
"@mdi/font": "5.9.55",
|
||||||
"core-js": "^3.8.3",
|
"core-js": "^3.8.3",
|
||||||
"google-protobuf": "^3.20.1",
|
"google-protobuf": "^3.20.1",
|
||||||
|
"js-base64": "^3.7.2",
|
||||||
|
"js-md5": "^0.7.3",
|
||||||
"protobufjs": "^6.11.3",
|
"protobufjs": "^6.11.3",
|
||||||
"roboto-fontface": "*",
|
"roboto-fontface": "*",
|
||||||
"vue": "^3.2.13",
|
"vue": "^3.2.13",
|
||||||
|
822
src/pb/proto.js
822
src/pb/proto.js
File diff suppressed because it is too large
Load Diff
@ -18,15 +18,17 @@ message AgentMessage {
|
|||||||
string UserSessionId = 2;
|
string UserSessionId = 2;
|
||||||
string UserId = 3;
|
string UserId = 3;
|
||||||
string GatewayServiceId = 4;
|
string GatewayServiceId = 4;
|
||||||
string Method = 5;
|
string MainType = 5;
|
||||||
google.protobuf.Any Message = 6;
|
string SubType = 6;
|
||||||
|
google.protobuf.Any Message = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
// RPC 服务固定回复结构
|
// RPC 服务固定回复结构
|
||||||
message RPCMessageReply {
|
message RPCMessageReply {
|
||||||
ErrorCode Code = 1;
|
ErrorCode Code = 1;
|
||||||
string Message = 2;
|
string ErrorMessage = 2;
|
||||||
string Data = 3;
|
string ErrorData = 3;
|
||||||
|
repeated UserMessage Reply = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
//用户代理绑定Uid请求
|
//用户代理绑定Uid请求
|
||||||
@ -63,3 +65,15 @@ message BroadCastMessageReq {
|
|||||||
|
|
||||||
//关闭用户代理
|
//关闭用户代理
|
||||||
message AgentCloseeReq { string UserSessionId = 1; }
|
message AgentCloseeReq { string UserSessionId = 1; }
|
||||||
|
|
||||||
|
//通知用户离线
|
||||||
|
message NoticeUserCloseReq {string UserSessionId = 1; string UserId = 2; }
|
||||||
|
|
||||||
|
//英雄属性类型
|
||||||
|
enum HeroAttributesType{
|
||||||
|
Hp = 0; //血量
|
||||||
|
Atk = 1; //攻击
|
||||||
|
Def = 2; //防御
|
||||||
|
Speed = 3; //速度
|
||||||
|
Crit = 4; //暴击
|
||||||
|
}
|
25
src/pb/proto/equipment_db.proto
Normal file
25
src/pb/proto/equipment_db.proto
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
option go_package = ".;pb";
|
||||||
|
|
||||||
|
//装备属性词条
|
||||||
|
message EquipmentAttributeEntry {
|
||||||
|
int32 Id = 1; //属性词条主键id 唯一
|
||||||
|
int32 libraryid = 2; //属性词条id 非唯一
|
||||||
|
string AttrName = 3; //属性名
|
||||||
|
int32 Lv = 4; //属性等级
|
||||||
|
int32 Value = 5; //属性值
|
||||||
|
}
|
||||||
|
|
||||||
|
//武器数据
|
||||||
|
message DB_Equipment {
|
||||||
|
string Id = 1; //@go_tags(`bson:"_id"`) 装备id
|
||||||
|
sint32 cId = 2; //@go_tags(`bson:"cId"`) 配置Id
|
||||||
|
string uId = 3; //@go_tags(`bson:"uid"`) 所属玩家Id
|
||||||
|
string heroId = 5; //@go_tags(`bson:"heroId"`) 挂在的英雄卡片id 未装备 填 ''
|
||||||
|
sint32 lv = 6; //@go_tags(`bson:"lv"`) 装备强化等级
|
||||||
|
sint32 keepFailNum = 7; //@go_tags(`bson:"keepFailNum"`) 连续强化失败次数
|
||||||
|
EquipmentAttributeEntry mainEntry = 8; //@go_tags(`bson:"mainEntry"`) 装备主词条
|
||||||
|
repeated EquipmentAttributeEntry adverbEntry = 9; //@go_tags(`bson:"adverbEntry"`) 装备副词条
|
||||||
|
uint32 overlayNum = 10; //@go_tags(`bson:"overlayNum"`) 叠加数量
|
||||||
|
bool isInitialState = 11; //@go_tags(`bson:"isInitialState"`) 是否初始状态
|
||||||
|
}
|
33
src/pb/proto/equipment_msg.proto
Normal file
33
src/pb/proto/equipment_msg.proto
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
option go_package = ".;pb";
|
||||||
|
import "equipment_db.proto";
|
||||||
|
|
||||||
|
//获取装备列表请求
|
||||||
|
message EquipmentGetListReq {
|
||||||
|
|
||||||
|
}
|
||||||
|
//获取装备列表请求 回应
|
||||||
|
message EquipmentGetListResp {
|
||||||
|
repeated DB_Equipment Equipments = 1; //装备列表
|
||||||
|
}
|
||||||
|
|
||||||
|
//装备挂在到英雄上
|
||||||
|
message EquipmentEquipReq{
|
||||||
|
string HeroCardId = 1; //英雄卡Id
|
||||||
|
repeated string EquipmentId = 2; //装备Id 固定长度的数组 0-5 对应的装备栏
|
||||||
|
}
|
||||||
|
|
||||||
|
//装备挂在到英雄上 回应
|
||||||
|
message EquipmentEquipResp{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//装备升级
|
||||||
|
message EquipmentUpgradeReq{
|
||||||
|
string EquipmentId = 1; //装备Id
|
||||||
|
}
|
||||||
|
|
||||||
|
//装备升级 回应
|
||||||
|
message EquipmentUpgradeResp{
|
||||||
|
|
||||||
|
}
|
@ -17,11 +17,18 @@ enum ErrorCode {
|
|||||||
DBError = 21; //数据库操作失败
|
DBError = 21; //数据库操作失败
|
||||||
SystemError = 22; //通用错误
|
SystemError = 22; //通用错误
|
||||||
Exception = 100; //程序执行异常
|
Exception = 100; //程序执行异常
|
||||||
|
Unknown = 101; //未知错误
|
||||||
|
ResNoEnough = 102; //资源不足
|
||||||
|
ConfigurationException = 103; //配置异常
|
||||||
|
ConfigNoFound = 104; //配置未找到
|
||||||
|
|
||||||
// user
|
// user
|
||||||
SecKeyInvalid = 1000; //秘钥无效
|
SecKeyInvalid = 1000; //秘钥无效
|
||||||
SecKey = 1001; //秘钥格式错误
|
SecKey = 1001; //秘钥格式错误
|
||||||
BindUser = 1002; //用户绑定错误
|
BindUser = 1002; //用户绑定错误
|
||||||
|
GoldNoEnough = 1003; // 金币不足
|
||||||
|
DiamondNoEnough = 1004; // 钻石不足
|
||||||
|
RoleCreated = 1005; //已创角
|
||||||
|
|
||||||
// friend
|
// friend
|
||||||
FriendNotSelf = 1100; //不能是自己
|
FriendNotSelf = 1100; //不能是自己
|
||||||
@ -36,4 +43,28 @@ enum ErrorCode {
|
|||||||
FriendApplyError = 1109; //申请失败
|
FriendApplyError = 1109; //申请失败
|
||||||
FriendBlackMax = 1110; //黑名单最大数量
|
FriendBlackMax = 1110; //黑名单最大数量
|
||||||
FriendSearchNameEmpty = 1111; //查询昵称为空
|
FriendSearchNameEmpty = 1111; //查询昵称为空
|
||||||
|
|
||||||
|
// item
|
||||||
|
ItemsNoEnough = 1200; //背包物品不足
|
||||||
|
ItemsNoFoundGird = 1201; //背包未找到物品格子
|
||||||
|
ItemsGridNumUpper = 1202; //背包格子数量已达上限
|
||||||
|
ItemsGirdAmountUpper = 1203; //背包格子容量已达上限
|
||||||
|
|
||||||
|
// hero
|
||||||
|
HeroNoExist = 1300; //英雄不存在
|
||||||
|
HeroNoEnough = 1301; //英雄数量不足
|
||||||
|
HeroMaxLv = 1302; //英雄达到最大等级
|
||||||
|
HeroInitCreat = 1303; //初始化英雄
|
||||||
|
|
||||||
|
HeroColorErr = 1304; // 品质不匹配
|
||||||
|
HeroSkillUpErr = 1305;// 技能升级失败
|
||||||
|
HeroMaxResonate = 1306; // 达到最大共鸣次数
|
||||||
|
HeroNoResonate = 1307; // 没有共鸣
|
||||||
|
HeroNotNeedResonate = 1308; // 不需要重置共鸣
|
||||||
|
HeroNoEnergy = 1309; // 没有能量点数
|
||||||
|
HeroCreate = 1310; // 创建卡失败
|
||||||
|
|
||||||
|
// equipment
|
||||||
|
EquipmentOnFoundEquipment = 1400; // 未找到武器
|
||||||
|
EquipmentLvlimitReached = 1401; // 武器等级已达上限
|
||||||
}
|
}
|
3
src/pb/proto/forum_db.proto
Normal file
3
src/pb/proto/forum_db.proto
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
option go_package = ".;pb";
|
||||||
|
|
2
src/pb/proto/forum_msg.proto
Normal file
2
src/pb/proto/forum_msg.proto
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
option go_package = ".;pb";
|
@ -1,7 +1,7 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
option go_package = ".;pb";
|
option go_package = ".;pb";
|
||||||
|
|
||||||
message DB_FriendData {
|
message DBFriend {
|
||||||
string uId = 1; //@go_tags(`bson:"uId"`) 用户ID
|
string uId = 1; //@go_tags(`bson:"uId"`) 用户ID
|
||||||
repeated string friendIds = 2; //@go_tags(`bson:"friendIds"`) 好友ID
|
repeated string friendIds = 2; //@go_tags(`bson:"friendIds"`) 好友ID
|
||||||
repeated string applyIds = 3; //@go_tags(`bson:"applyIds"`) 申请用户ID
|
repeated string applyIds = 3; //@go_tags(`bson:"applyIds"`) 申请用户ID
|
||||||
|
@ -12,97 +12,97 @@ message FriendBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//好友列表
|
//好友列表
|
||||||
message Friend_List_Req {}
|
message FriendListReq {}
|
||||||
|
|
||||||
message Friend_List_Rsp { repeated FriendBase list = 1; }
|
message FriendListRsp { repeated FriendBase list = 1; }
|
||||||
|
|
||||||
//申请好友
|
//申请好友
|
||||||
message Friend_Apply_Req {
|
message FriendApplyReq {
|
||||||
string friendId = 1; //好友ID
|
string friendId = 1; //好友ID
|
||||||
}
|
}
|
||||||
message Friend_Apply_Rsp {
|
message FriendApplyRsp {
|
||||||
string userId = 1; //用户ID
|
string userId = 1; //用户ID
|
||||||
string friendId = 2; //好友ID
|
string friendId = 2; //好友ID
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除好友
|
//删除好友
|
||||||
message Friend_Del_Req {
|
message FriendDelReq {
|
||||||
string friendId = 1; //好友ID
|
string friendId = 1; //好友ID
|
||||||
}
|
}
|
||||||
|
|
||||||
message Friend_Del_Rsp {
|
message FriendDelRsp {
|
||||||
string friendId = 1; //好友ID
|
string friendId = 1; //好友ID
|
||||||
string userId = 2; //用户ID
|
string userId = 2; //用户ID
|
||||||
}
|
}
|
||||||
|
|
||||||
//同意
|
//同意
|
||||||
message Friend_Agree_Req {
|
message FriendAgreeReq {
|
||||||
repeated string friendIds = 1; //被同意的用户
|
repeated string friendIds = 1; //被同意的用户
|
||||||
}
|
}
|
||||||
message Friend_Agree_Rsp {
|
message FriendAgreeRsp {
|
||||||
int32 Num = 1; //操作的数量
|
int32 Num = 1; //操作的数量
|
||||||
}
|
}
|
||||||
|
|
||||||
//拒绝
|
//拒绝
|
||||||
message Friend_Refuse_Req {
|
message FriendRefuseReq {
|
||||||
repeated string friendIds = 1; //被拒绝的用户
|
repeated string friendIds = 1; //被拒绝的用户
|
||||||
}
|
}
|
||||||
message Friend_Refuse_Rsp {
|
message FriendRefuseRsp {
|
||||||
int32 Num = 1; //操作的数量
|
int32 Num = 1; //操作的数量
|
||||||
}
|
}
|
||||||
|
|
||||||
//好友申请列表
|
//好友申请列表
|
||||||
message Friend_ApplyList_Req {}
|
message FriendApplyListReq {}
|
||||||
message Friend_ApplyList_Rsp { repeated FriendBase list = 1; }
|
message FriendApplyListRsp { repeated FriendBase list = 1; }
|
||||||
|
|
||||||
//好友搜索
|
//好友搜索
|
||||||
message Friend_Search_Req {
|
message FriendSearchReq {
|
||||||
string nickName = 1; //好友昵称
|
string nickName = 1; //好友昵称
|
||||||
}
|
}
|
||||||
|
|
||||||
message Friend_Search_Rsp { FriendBase friend = 1; }
|
message FriendSearchRsp { FriendBase friend = 1; }
|
||||||
|
|
||||||
//黑名单
|
//黑名单
|
||||||
message Friend_BlackList_Req {}
|
message FriendBlackListReq {}
|
||||||
|
|
||||||
message Friend_BlackList_Rsp { repeated FriendBase friends = 1; }
|
message FriendBlackListRsp { repeated FriendBase friends = 1; }
|
||||||
|
|
||||||
//添加黑名单
|
//添加黑名单
|
||||||
message Friend_BlackAdd_Req { string friendId = 1; }
|
message FriendBlackAddReq { string friendId = 1; }
|
||||||
|
|
||||||
message Friend_BlackAdd_Rsp {
|
message FriendBlackAddRsp {
|
||||||
string friendId = 1;
|
string friendId = 1;
|
||||||
string userId = 2;
|
string userId = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除黑名单
|
//删除黑名单
|
||||||
message Friend_DelBlack_Req { string friendId = 1; }
|
message FriendDelBlackReq { string friendId = 1; }
|
||||||
|
|
||||||
message Friend_DelBlack_Rsp {
|
message FriendDelBlackRsp {
|
||||||
string friendId = 1;
|
string friendId = 1;
|
||||||
string userId = 2;
|
string userId = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//接收
|
//接收
|
||||||
message Friend_Receive_Req { string friendId = 1; }
|
message FriendReceiveReq { string friendId = 1; }
|
||||||
|
|
||||||
message Friend_Receive_Rsp {
|
message FriendReceiveRsp {
|
||||||
string friendId = 1;
|
string friendId = 1;
|
||||||
string userId = 2;
|
string userId = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//赠送
|
//赠送
|
||||||
message Friend_Give_Req { string friendId = 1; }
|
message FriendGiveReq { string friendId = 1; }
|
||||||
|
|
||||||
message Friend_Give_Rsp {
|
message FriendGiveRsp {
|
||||||
string friendId = 1;
|
string friendId = 1;
|
||||||
string userId = 2;
|
string userId = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//好友数量
|
//好友数量
|
||||||
message Friend_Total_Req { string friendId = 1; }
|
message FriendTotalReq { string friendId = 1; }
|
||||||
|
|
||||||
message Friend_Total_Rsp {
|
message FriendTotalRsp {
|
||||||
string friendId = 1;
|
string friendId = 1;
|
||||||
int32 total = 2; //好友数量
|
int32 total = 2; //好友数量
|
||||||
}
|
}
|
38
src/pb/proto/hero_db.proto
Normal file
38
src/pb/proto/hero_db.proto
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
option go_package = ".;pb";
|
||||||
|
package pb;
|
||||||
|
|
||||||
|
message SkillData {
|
||||||
|
int32 skillID = 1;
|
||||||
|
int32 skillLv = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DBHero {
|
||||||
|
string id = 1; //@go_tags(`bson:"_id"`) ID
|
||||||
|
string uid = 2;
|
||||||
|
int32 heroID = 3; //@go_tags(`bson:"heroID"`) 英雄的配置表ID
|
||||||
|
int32 star = 4; // 英雄星级
|
||||||
|
int32 lv = 5; // 英雄等级
|
||||||
|
int32 exp = 6; // 英雄经验
|
||||||
|
int32 juexingLv = 7; //@go_tags(`bson:"juexingLv"`) 觉醒等级
|
||||||
|
int32 captainSkill = 8; //@go_tags(`bson:"captainSkill"`) 队长技能
|
||||||
|
repeated SkillData normalSkill = 9; //@go_tags(`bson:"normalSkill"`) 普通技能
|
||||||
|
map<int32, int32> property = 10; // 属性相关
|
||||||
|
map<int32, int32> addProperty =
|
||||||
|
11; //@go_tags(`bson:"addProperty"`) 附加属性相关
|
||||||
|
int32 formation = 12; // 阵型类型
|
||||||
|
int32 cardType =
|
||||||
|
13; //@go_tags(`bson:"cardType"`) 卡片类型(升星卡、经验卡、技能升级卡)
|
||||||
|
int32 curSkin = 14; //@go_tags(`bson:"curSkin"`) 当前装备的皮肤ID
|
||||||
|
repeated int32 skins = 15; // 所有皮肤ID
|
||||||
|
bool block = 16; // 锁定
|
||||||
|
repeated string equipID = 17; //@go_tags(`bson:"equipID"`) 装备 objID
|
||||||
|
int32 resonateNum = 18; //@go_tags(`bson:"resonateNum"`) 共鸣次数
|
||||||
|
int32 distributionResonate =
|
||||||
|
19; //@go_tags(`bson:"distributionResonate"`) 分配的共鸣能量
|
||||||
|
map<int32, int32> energy = 20; // @go_tags(`bson:"energy"`)能量分配到哪里
|
||||||
|
int32 sameCount = 21; // @go_tags(`bson:"sameCount"`) 卡片叠加数量
|
||||||
|
int32 suiteId = 22; //@go_tags(`bson:"suiteId"`) 套装Id
|
||||||
|
int32 suiteExtId = 23; // go_tags(`bson:"suiteExtId"`) 扩展套装Id
|
||||||
|
bool isOverlying = 24; // go_tags(`bson:"isOverlying"`) 是否允许叠加 默认true
|
||||||
|
}
|
120
src/pb/proto/hero_msg.proto
Normal file
120
src/pb/proto/hero_msg.proto
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
option go_package = ".;pb";
|
||||||
|
package pb;
|
||||||
|
import "hero_db.proto";
|
||||||
|
|
||||||
|
//英雄基础信息
|
||||||
|
message HeroInfoReq {
|
||||||
|
string heroId = 1; //英雄唯一ID
|
||||||
|
}
|
||||||
|
message HeroInfoRsp { DBHero base = 1; }
|
||||||
|
|
||||||
|
//英雄列表
|
||||||
|
message HeroListReq {}
|
||||||
|
|
||||||
|
message HeroListRsp { repeated DBHero list = 1; }
|
||||||
|
|
||||||
|
/// 卡牌养成: 强化(卡牌升级、卡牌升星、技能升级)
|
||||||
|
/// 卡牌养成: 共鸣(共鸣消耗、材料返回、能量点使用)
|
||||||
|
/// 卡牌养成: 觉醒(英雄觉醒、材料消耗)
|
||||||
|
|
||||||
|
message ItemData {
|
||||||
|
int32 itemId = 2; //物品Id
|
||||||
|
int32 amount = 3; //数量
|
||||||
|
}
|
||||||
|
|
||||||
|
// 卡牌升级
|
||||||
|
message HeroStrengthenUplvReq {
|
||||||
|
string heroObjID = 1; // 英雄对象ID
|
||||||
|
string expCardID = 2; // 经验卡对象ID
|
||||||
|
int32 amount = 3; // 消耗经验卡数量}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 卡牌升级返回
|
||||||
|
message HeroStrengthenUplvResp {
|
||||||
|
DBHero hero = 1; // 英雄对象
|
||||||
|
}
|
||||||
|
|
||||||
|
message CostCardData {
|
||||||
|
string costCardObj = 1; // 对象ID
|
||||||
|
int32 amount = 2; // 数量
|
||||||
|
}
|
||||||
|
// 卡牌升星
|
||||||
|
message HeroStrengthenUpStarReq {
|
||||||
|
string heroObjID = 1; // 英雄对象ID
|
||||||
|
repeated CostCardData hero = 2; // 消耗卡牌对象ID
|
||||||
|
repeated CostCardData heroRace = 3; // 消耗种族卡牌对象ID
|
||||||
|
}
|
||||||
|
|
||||||
|
// 卡牌升星返回
|
||||||
|
message HeroStrengthenUpStarResp {
|
||||||
|
DBHero hero = 1; // 英雄对象
|
||||||
|
}
|
||||||
|
|
||||||
|
// 卡牌技能升级
|
||||||
|
message HeroStrengthenUpSkillReq {
|
||||||
|
string heroObjID = 1; // 英雄对象ID
|
||||||
|
string costCardObj = 2; // 消耗技能升级卡
|
||||||
|
}
|
||||||
|
|
||||||
|
// 卡牌技能升级返回
|
||||||
|
message HeroStrengthenUpSkillResp {
|
||||||
|
DBHero hero = 1; // 英雄对象
|
||||||
|
}
|
||||||
|
|
||||||
|
// 共鸣英雄
|
||||||
|
message HeroResonanceReq {
|
||||||
|
string heroObjID = 1; // 英雄对象ID
|
||||||
|
string costObjID = 2; // 消耗对象
|
||||||
|
int32 amount = 3;// 消耗的数量
|
||||||
|
}
|
||||||
|
|
||||||
|
message HeroResonanceResp {
|
||||||
|
DBHero hero = 1; // 英雄对象
|
||||||
|
int32 energy = 2; // 共鸣成功 获得的能量点数
|
||||||
|
DBHero upStarCard = 3; //共鸣成功 获得的升星卡
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置共鸣属性
|
||||||
|
message HeroResonanceResetReq {
|
||||||
|
string heroObjID = 1; // 英雄对象ID
|
||||||
|
}
|
||||||
|
|
||||||
|
message HeroResonanceResetResp {
|
||||||
|
DBHero hero = 1; // 英雄对象
|
||||||
|
int32 energy = 2; // 能量点数
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用能量点数
|
||||||
|
message HeroResonanceUseEnergyReq {
|
||||||
|
string heroObjID = 1; // 英雄对象ID
|
||||||
|
int32 useEnergy = 2; // 使用的能量点数
|
||||||
|
int32 useType = 3; // 使用的类型 (攻击、血量、防御)
|
||||||
|
}
|
||||||
|
|
||||||
|
message HeroResonanceUseEnergyResp {
|
||||||
|
DBHero hero = 1; // 英雄对象
|
||||||
|
}
|
||||||
|
|
||||||
|
// 觉醒
|
||||||
|
message HeroJuexingReq {
|
||||||
|
string heroObjID = 1; // 英雄对象ID
|
||||||
|
ItemData costItmes = 2; // 觉醒消耗待定
|
||||||
|
}
|
||||||
|
|
||||||
|
// 觉醒返回
|
||||||
|
message HeroJuexingResp {
|
||||||
|
DBHero hero = 1; // 英雄对象
|
||||||
|
}
|
||||||
|
|
||||||
|
//抽卡
|
||||||
|
message HeroChoukaReq {}
|
||||||
|
|
||||||
|
message HeroChoukaResp { repeated DBHero heroes = 1; }
|
||||||
|
|
||||||
|
//英雄属性推送
|
||||||
|
message HeroProperty {
|
||||||
|
string heroId = 1; //英雄唯一ID
|
||||||
|
map<int32, int32> property = 2; //基础属性
|
||||||
|
map<int32, int32> addProperty = 3; //附加属性
|
||||||
|
}
|
@ -1,37 +1,37 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
option go_package = ".;pb";
|
option go_package = ".;pb";
|
||||||
import "pack_db.proto";
|
import "items_db.proto";
|
||||||
|
|
||||||
//查询用户背包请求
|
//查询用户背包请求
|
||||||
message Pack_Getlist_Req {
|
message ItemsGetlistReq {
|
||||||
int32 IType = 1; //道具类型
|
int32 IType = 1; //道具类型
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询用户背包请求 回应
|
//查询用户背包请求 回应
|
||||||
message Pack_Getlist_Resp {
|
message ItemsGetlistResp {
|
||||||
repeated DB_UserItemData Grids = 1; //用户背包列表
|
repeated DB_UserItemData Grids = 1; //用户背包列表
|
||||||
}
|
}
|
||||||
|
|
||||||
//使用物品请求
|
//使用物品请求
|
||||||
message Pack_UseItem_Req {
|
message ItemsUseItemReq {
|
||||||
int32 GridId = 1; //格子Id
|
int32 GridId = 1; //格子Id
|
||||||
int32 ItemId = 2; //物品Id
|
int32 ItemId = 2; //物品Id
|
||||||
uint32 Amount = 3; //使用数量
|
uint32 Amount = 3; //使用数量
|
||||||
}
|
}
|
||||||
|
|
||||||
//使用物品请求 回应
|
//使用物品请求 回应
|
||||||
message Pack_UseItem_Resp {
|
message ItemsUseItemResp {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//出售道具请求sailitem
|
//出售道具请求sailitem
|
||||||
message Pack_SellItem_Req {
|
message ItemsSellItemReq {
|
||||||
int32 GridId = 1; //格子Id
|
int32 GridId = 1; //格子Id
|
||||||
int32 ItemId = 2; //物品Id
|
int32 ItemId = 2; //物品Id
|
||||||
uint32 Amount = 3; //使用数量
|
uint32 Amount = 3; //使用数量
|
||||||
}
|
}
|
||||||
|
|
||||||
//出售道具请求 回应
|
//出售道具请求 回应
|
||||||
message Pack_SellItem_Resp {
|
message ItemsSellItemResp {
|
||||||
|
|
||||||
}
|
}
|
@ -11,7 +11,7 @@ message MailAttachment { // 附件
|
|||||||
uint32 ItemCount = 2; // 数量
|
uint32 ItemCount = 2; // 数量
|
||||||
}
|
}
|
||||||
|
|
||||||
message DB_MailData {
|
message DBMailData {
|
||||||
string ObjId = 1; // @go_tags(`bson:"_id"`) ID
|
string ObjId = 1; // @go_tags(`bson:"_id"`) ID
|
||||||
string Uid = 2;
|
string Uid = 2;
|
||||||
string Title = 3; // 邮件标题
|
string Title = 3; // 邮件标题
|
||||||
|
@ -2,38 +2,38 @@ syntax = "proto3";
|
|||||||
option go_package = ".;pb";
|
option go_package = ".;pb";
|
||||||
import "mail_db.proto";
|
import "mail_db.proto";
|
||||||
|
|
||||||
message Mail_GetList_Req {
|
message MailGetListReq {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询邮件信息
|
// 查询邮件信息
|
||||||
message Mail_GetList_Resp {
|
message MailGetListResp {
|
||||||
repeated DB_MailData Mails = 1;
|
repeated DBMailData Mails = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查看邮件
|
// 查看邮件
|
||||||
message Mail_ReadMail_Req {
|
message MailReadMailReq {
|
||||||
string ObjID = 1;
|
string ObjID = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Mail_ReadMail_Resp {
|
message MailReadMailResp {
|
||||||
DB_MailData Mail = 1;
|
DBMailData Mail = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 领取附件
|
// 领取附件
|
||||||
message Mail_GetUserMailAttachment_Req {
|
message MailGetUserMailAttachmentReq {
|
||||||
string ObjID = 1;
|
string ObjID = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Mail_GetUserMailAttachment_Resp {
|
message MailGetUserMailAttachmentResp {
|
||||||
DB_MailData Mail = 1;
|
DBMailData Mail = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除某个邮件
|
// 删除某个邮件
|
||||||
message Mail_DelMail_Req {
|
message MailDelMailReq {
|
||||||
string ObjID = 1;
|
string ObjID = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Mail_DelMail_Resp {
|
message MailDelMailResp {
|
||||||
repeated DB_MailData Mail = 1;
|
repeated DBMailData Mail = 1;
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,10 @@ option go_package = ".;pb";
|
|||||||
import "errorcode.proto";
|
import "errorcode.proto";
|
||||||
|
|
||||||
//统一错误码返回
|
//统一错误码返回
|
||||||
message ErrorNotify {
|
message NotifyErrorNotifyPush {
|
||||||
string ReqMainType = 1; // 请求协议模块 模块名 例如:user 对应项目中 user的模块
|
string ReqMainType = 1; // 请求协议模块 模块名 例如:user 对应项目中 user的模块
|
||||||
string ReqSubType = 2; // 请求协议函数 例如:login 对应项目中 user的模块中 api_login 的处理函数
|
string ReqSubType = 2; // 请求协议函数 例如:login 对应项目中 user的模块中
|
||||||
|
// api_login 的处理函数
|
||||||
ErrorCode Code = 3; // 执行返回错误码 对应 errorcode.proto 枚举
|
ErrorCode Code = 3; // 执行返回错误码 对应 errorcode.proto 枚举
|
||||||
string Message = 4; // 错误消息
|
string Message = 4; // 错误消息
|
||||||
string Data = 6; // 错误数据
|
string Data = 6; // 错误数据
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
option go_package = ".;pb";
|
option go_package = ".;pb";
|
||||||
|
|
||||||
message Cache_UserData {
|
message CacheUser {
|
||||||
string uid = 1;
|
string uid = 1;
|
||||||
string SessionId = 2;
|
string SessionId = 2;
|
||||||
string GatewayServiceId = 3;
|
string GatewayServiceId = 3;
|
||||||
// DB_UserData UserData = 4; //@go_tags(`json:",inline"`)
|
// DB_UserData UserData = 4; //@go_tags(`json:",inline"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
message DB_UserData {
|
message DBUser {
|
||||||
string id = 1; //@go_tags(`bson:"_id"`) ID
|
string id = 1; //@go_tags(`bson:"_id"`) ID
|
||||||
string uid = 2; //@go_tags(`bson:"uid"`) 用户ID
|
string uid = 2; //@go_tags(`bson:"uid"`) 用户ID
|
||||||
string uuid = 3; //@go_tags(`bson:"uuid"`) 玩家唯一uuid
|
string uuid = 3; //@go_tags(`bson:"uuid"`) 玩家唯一uuid
|
||||||
@ -21,4 +21,6 @@ message DB_UserData {
|
|||||||
int64 logintime = 10; //@go_tags(`bson:"logintime"`) 最后一次登录时间
|
int64 logintime = 10; //@go_tags(`bson:"logintime"`) 最后一次登录时间
|
||||||
int32 friendPoint = 11; //@go_tags(`bson:"friendPoint"`) 友情点
|
int32 friendPoint = 11; //@go_tags(`bson:"friendPoint"`) 友情点
|
||||||
int32 avatar = 12; //@go_tags(`bson:"avatar"`) 头像
|
int32 avatar = 12; //@go_tags(`bson:"avatar"`) 头像
|
||||||
|
int32 gold = 13; //@go_tags(`bson:"gold"`) 金币
|
||||||
|
int32 exp = 14; //@go_tags(`bson:"exp"`) 经验
|
||||||
}
|
}
|
@ -9,7 +9,7 @@ message UserLoginReq {
|
|||||||
int32 sid = 2; //区服编号
|
int32 sid = 2; //区服编号
|
||||||
}
|
}
|
||||||
|
|
||||||
message UserLoginResp { DB_UserData data = 1; }
|
message UserLoginResp { DBUser data = 1; }
|
||||||
|
|
||||||
message UserRegisterReq {
|
message UserRegisterReq {
|
||||||
string account = 1;
|
string account = 1;
|
||||||
@ -21,7 +21,7 @@ message UserRegisterRsp {
|
|||||||
string account = 2;
|
string account = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message UserLoadRsp { Cache_UserData data = 1; }
|
message UserLoadRsp { CacheUser data = 1; }
|
||||||
|
|
||||||
//创角
|
//创角
|
||||||
message UserCreateReq {
|
message UserCreateReq {
|
||||||
|
@ -18,7 +18,7 @@ var socket = {
|
|||||||
hearbeat_interval: 5000,
|
hearbeat_interval: 5000,
|
||||||
|
|
||||||
// 是否自动重连
|
// 是否自动重连
|
||||||
is_reonnect: true,
|
is_reonnect: false,
|
||||||
// 重连次数
|
// 重连次数
|
||||||
reconnect_count: 3,
|
reconnect_count: 3,
|
||||||
// 已发起重连次数
|
// 已发起重连次数
|
||||||
@ -27,7 +27,10 @@ var socket = {
|
|||||||
reconnect_timer: null,
|
reconnect_timer: null,
|
||||||
// 重连频率
|
// 重连频率
|
||||||
reconnect_interval: 3000,
|
reconnect_interval: 3000,
|
||||||
|
// 消息监听
|
||||||
|
receivelisten: null,
|
||||||
|
// 关闭监听
|
||||||
|
closelisten: null,
|
||||||
/**
|
/**
|
||||||
* 初始化连接
|
* 初始化连接
|
||||||
*/
|
*/
|
||||||
@ -45,27 +48,10 @@ var socket = {
|
|||||||
* @param {*} callback 发送后的自定义回调函数
|
* @param {*} callback 发送后的自定义回调函数
|
||||||
*/
|
*/
|
||||||
send: (data, callback = null) => {
|
send: (data, callback = null) => {
|
||||||
// 开启状态直接发送
|
socket.websock.send(data)
|
||||||
if (socket.websock.readyState === socket.websock.OPEN) {
|
|
||||||
socket.websock.send(JSON.stringify(data))
|
|
||||||
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 正在开启状态,则等待1s后重新调用
|
|
||||||
} else if (socket.websock.readyState === socket.websock.CONNECTING) {
|
|
||||||
setTimeout(function () {
|
|
||||||
socket.send(data, callback)
|
|
||||||
}, 1000)
|
|
||||||
|
|
||||||
// 未开启,则等待1s后重新调用
|
|
||||||
} else {
|
|
||||||
socket.init()
|
|
||||||
setTimeout(function () {
|
|
||||||
socket.send(data, callback)
|
|
||||||
}, 1000)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -180,8 +166,12 @@ var socket = {
|
|||||||
}
|
}
|
||||||
socket.websock = new WebSocket(socket.ws_url)
|
socket.websock = new WebSocket(socket.ws_url)
|
||||||
socket.websock.onmessage = function (e) {
|
socket.websock.onmessage = function (e) {
|
||||||
|
if (socket.receivelisten != null) {
|
||||||
|
socket.receivelisten(e)
|
||||||
|
} else {
|
||||||
socket.receive(e)
|
socket.receive(e)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// 关闭连接
|
// 关闭连接
|
||||||
socket.websock.onclose = function (e) {
|
socket.websock.onclose = function (e) {
|
||||||
console.log('连接已断开')
|
console.log('连接已断开')
|
||||||
@ -202,6 +192,10 @@ var socket = {
|
|||||||
socket.reconnect_current++
|
socket.reconnect_current++
|
||||||
return socket.connect(resolve, reject)
|
return socket.connect(resolve, reject)
|
||||||
}, socket.reconnect_interval)
|
}, socket.reconnect_interval)
|
||||||
|
} else {
|
||||||
|
if (socket.closelisten != null)
|
||||||
|
socket.closelisten()
|
||||||
|
return reject("连接失败")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,9 +204,9 @@ var socket = {
|
|||||||
console.log('连接成功')
|
console.log('连接成功')
|
||||||
socket.reconnect_current = 0
|
socket.reconnect_current = 0
|
||||||
socket.socket_open = true
|
socket.socket_open = true
|
||||||
socket.is_reonnect = true
|
// socket.is_reonnect = true
|
||||||
// 开启心跳
|
// 开启心跳
|
||||||
socket.heartbeat()
|
// socket.heartbeat()
|
||||||
resolve(socket.websock)
|
resolve(socket.websock)
|
||||||
}
|
}
|
||||||
// 连接发生错误
|
// 连接发生错误
|
||||||
@ -221,7 +215,5 @@ var socket = {
|
|||||||
console.log('WebSocket连接发生错误')
|
console.log('WebSocket连接发生错误')
|
||||||
// reject("WebSocket连接发生错误")
|
// reject("WebSocket连接发生错误")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
}
|
}
|
@ -27,17 +27,105 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
<v-divider inset></v-divider>
|
<v-divider inset></v-divider>
|
||||||
<v-row class="mt-5">
|
<v-row class="mt-5">
|
||||||
<v-col cols="4">
|
<v-col cols="2">
|
||||||
<v-select :items="proto_models"
|
<v-select v-model="mainSelect"
|
||||||
label="选择测试模块"></v-select>
|
:items="proto_models"
|
||||||
|
item-title="mainType"
|
||||||
|
item-value="subs"
|
||||||
|
label="mainType"
|
||||||
|
:disabled="!isconnect"
|
||||||
|
@update:modelValue="mainSelectUpdate"
|
||||||
|
single-line
|
||||||
|
return-object></v-select>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="4">
|
<v-col cols="2">
|
||||||
<v-select :items="proto_models"
|
<v-select v-model="subSelect"
|
||||||
label="选择子协议"></v-select>
|
:items="mainSelect.subs"
|
||||||
|
item-title="subType"
|
||||||
|
item-value="reqproto"
|
||||||
|
label="subType"
|
||||||
|
:disabled="!isconnect || mainSelect.disabled"
|
||||||
|
@update:modelValue="subSelectUpdate"
|
||||||
|
single-line
|
||||||
|
return-object></v-select>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
<v-divider inset></v-divider>
|
||||||
|
<v-row v-if="reqproto.length > 0"
|
||||||
|
class="mt-5">
|
||||||
|
<v-col v-for="item in reqproto"
|
||||||
|
:key="item.FieldName"
|
||||||
|
cols="4">
|
||||||
|
<v-text-field color="tertiary"
|
||||||
|
v-model="item.FieldValue"
|
||||||
|
:label="item.FieldName"
|
||||||
|
:type="item.FieldType"
|
||||||
|
:hint="item.FieldType"
|
||||||
|
:disabled="!isconnect"
|
||||||
|
outlined
|
||||||
|
clearable></v-text-field>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
<v-row class="mt-5">
|
||||||
|
<v-col cols="3">
|
||||||
|
<v-btn flat
|
||||||
|
class="text-capitalize"
|
||||||
|
:disabled="subSelect == null"
|
||||||
|
@click="reqprotohandle"
|
||||||
|
color="secondary">
|
||||||
|
request
|
||||||
|
</v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
|
<v-card class="mt-12">
|
||||||
|
<v-card-title>
|
||||||
|
<v-row justify="space-between">
|
||||||
|
<v-col>输出</v-col>
|
||||||
|
<v-col cols="auto">
|
||||||
|
<v-btn flat
|
||||||
|
prepend-icon="mdi-broom"
|
||||||
|
@click="logs=[]"
|
||||||
|
color="secondary">
|
||||||
|
Clear
|
||||||
|
</v-btn>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-card-title>
|
||||||
|
<v-divider></v-divider>
|
||||||
|
<v-responsive class="overflow-y-auto"
|
||||||
|
height="500">
|
||||||
|
<v-lazy :options="{threshold: .5}"
|
||||||
|
min-height="200"
|
||||||
|
transition="fade-transition">
|
||||||
|
|
||||||
|
<v-list>
|
||||||
|
<v-list-item v-for="log in logs"
|
||||||
|
:key="log">
|
||||||
|
<v-alert :type="log.type"
|
||||||
|
variant="outlined"
|
||||||
|
:title="log.title">
|
||||||
|
<template v-if="log.data"
|
||||||
|
v-slot:append>
|
||||||
|
<v-list-item-avatar end>
|
||||||
|
<v-btn variant="text"
|
||||||
|
size="x-large"
|
||||||
|
@click="log.isshow = !log.isshow"
|
||||||
|
:icon="log.isshow ? 'mdi-chevron-left':'mdi-chevron-down'"></v-btn>
|
||||||
|
</v-list-item-avatar>
|
||||||
|
</template>
|
||||||
|
<div v-if="log.data"
|
||||||
|
v-show="log.isshow">
|
||||||
|
<v-divider></v-divider>
|
||||||
|
<pre>{{log.data}}</pre>
|
||||||
|
</div>
|
||||||
|
</v-alert>
|
||||||
|
</v-list-item>
|
||||||
|
</v-list>
|
||||||
|
</v-lazy>
|
||||||
|
</v-responsive>
|
||||||
|
</v-card>
|
||||||
<v-snackbar v-model="error">
|
<v-snackbar v-model="error">
|
||||||
{{ error_message }}
|
{{ error_message }}
|
||||||
<template v-slot:actions>
|
<template v-slot:actions>
|
||||||
@ -52,6 +140,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { Base64 } from 'js-base64'
|
||||||
|
import md5 from 'js-md5'
|
||||||
import { reactive } from 'vue'
|
import { reactive } from 'vue'
|
||||||
import proto from '@/pb/proto'
|
import proto from '@/pb/proto'
|
||||||
import { socket } from '@/utils/socket'
|
import { socket } from '@/utils/socket'
|
||||||
@ -67,24 +157,106 @@ export default defineComponent({
|
|||||||
connecting: false,
|
connecting: false,
|
||||||
error: false,
|
error: false,
|
||||||
error_message: '',
|
error_message: '',
|
||||||
protodata: {},
|
proto_models: null,
|
||||||
proto_models: [],
|
mainSelect: { protoName: '', mainType: 'User', subs: [] },
|
||||||
|
subSelect: null,
|
||||||
|
reqproto: [],
|
||||||
|
reqloading: false,
|
||||||
|
islogin: false,
|
||||||
|
account: '',
|
||||||
|
serverId: 0,
|
||||||
|
logs: [],
|
||||||
|
isshow: true,
|
||||||
|
showdata: { name: 'liwei1dao', aog: 123 },
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {},
|
||||||
setup() {
|
setup() {
|
||||||
const protodata = reactive([])
|
const proto_models = reactive([
|
||||||
const proto_models = reactive([])
|
{ mainType: 'notify', disabled: true, subs: [] },
|
||||||
|
{ mainType: 'user', subs: [] },
|
||||||
|
{ mainType: 'items', subs: [] },
|
||||||
|
{ mainType: 'mail', subs: [] },
|
||||||
|
{ mainType: 'friend', subs: [] },
|
||||||
|
{ mainType: 'equipment', subs: [] },
|
||||||
|
{ mainType: 'hero', subs: [] },
|
||||||
|
])
|
||||||
for (const v of Object.keys(proto)) {
|
for (const v of Object.keys(proto)) {
|
||||||
let arr = v.split('_')
|
for (const v1 of proto_models) {
|
||||||
if (arr.length == 3) {
|
let protoName = v.toLowerCase()
|
||||||
console.log(v)
|
// console.log('protoName', protoName)
|
||||||
var value = proto[v]
|
//找到模块的消息对象
|
||||||
protodata[arr[0]] = value
|
let index = protoName.indexOf(v1.mainType)
|
||||||
console.log(value)
|
if (index == 0) {
|
||||||
proto_models.push(arr[0])
|
let reqindex = protoName.indexOf('req')
|
||||||
|
let respindex = protoName.indexOf('resp')
|
||||||
|
let pushindex = protoName.indexOf('push')
|
||||||
|
if (reqindex != -1) {
|
||||||
|
let sub = protoName.substring(index + v1.mainType.length, reqindex)
|
||||||
|
let iskeep = false
|
||||||
|
for (const v2 of v1.subs) {
|
||||||
|
if (v2.subType == sub) {
|
||||||
|
v2.reqproto = proto[v]
|
||||||
|
iskeep = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { protodata, proto_models }
|
if (!iskeep) {
|
||||||
|
v1.subs.push({
|
||||||
|
reqName: v,
|
||||||
|
mainType: v1.mainType,
|
||||||
|
subType: sub,
|
||||||
|
reqproto: proto[v],
|
||||||
|
})
|
||||||
|
console.log(sub + 'Req')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (respindex != -1) {
|
||||||
|
let sub = protoName.substring(index + v1.mainType.length, respindex)
|
||||||
|
let iskeep = false
|
||||||
|
for (const v2 of v1.subs) {
|
||||||
|
if (v2.subType == sub) {
|
||||||
|
v2.respName = v
|
||||||
|
v2.respproto = proto[v]
|
||||||
|
iskeep = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!iskeep) {
|
||||||
|
v1.subs.push({
|
||||||
|
respName: v,
|
||||||
|
mainType: v1.mainType,
|
||||||
|
subType: sub,
|
||||||
|
respproto: proto[v],
|
||||||
|
})
|
||||||
|
console.log(sub + 'Resp')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pushindex != -1) {
|
||||||
|
let sub = protoName.substring(index + v1.mainType.length, pushindex)
|
||||||
|
let iskeep = false
|
||||||
|
for (const v2 of v1.subs) {
|
||||||
|
if (v2.subType == sub) {
|
||||||
|
v2.pushName = v
|
||||||
|
v2.pushproto = proto[v]
|
||||||
|
iskeep = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!iskeep) {
|
||||||
|
v1.subs.push({
|
||||||
|
pushName: v,
|
||||||
|
mainType: v1.mainType,
|
||||||
|
subType: sub,
|
||||||
|
pushproto: proto[v],
|
||||||
|
})
|
||||||
|
console.log(sub + 'Resp')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { proto_models }
|
||||||
},
|
},
|
||||||
onBeforeUnmount() {
|
onBeforeUnmount() {
|
||||||
// 关闭连接
|
// 关闭连接
|
||||||
@ -94,6 +266,8 @@ export default defineComponent({
|
|||||||
connect() {
|
connect() {
|
||||||
// 发起连接
|
// 发起连接
|
||||||
this.connecting = true
|
this.connecting = true
|
||||||
|
socket.receivelisten = this.receivelisten
|
||||||
|
|
||||||
socket
|
socket
|
||||||
.init(this.ws_url)
|
.init(this.ws_url)
|
||||||
.then((value) => {
|
.then((value) => {
|
||||||
@ -101,19 +275,180 @@ export default defineComponent({
|
|||||||
this.error_message = ''
|
this.error_message = ''
|
||||||
this.isconnect = true
|
this.isconnect = true
|
||||||
this.connecting = false
|
this.connecting = false
|
||||||
|
this.pushlog('success', `连接创建成功`)
|
||||||
|
socket.closelisten = this.closelisten
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.error = true
|
this.error = true
|
||||||
this.error_message = error
|
this.error_message = error
|
||||||
this.isconnect = false
|
this.isconnect = false
|
||||||
this.connecting = false
|
this.connecting = false
|
||||||
|
this.subSelect = null
|
||||||
|
this.reqproto = []
|
||||||
|
this.pushlog('error', `连接创建失败:${this.ws_url}`)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
disconnect() {
|
disconnect() {
|
||||||
socket.close()
|
socket.close()
|
||||||
this.isconnect = false
|
this.isconnect = false
|
||||||
|
this.subSelect = null
|
||||||
|
this.reqproto = []
|
||||||
|
},
|
||||||
|
mainSelectUpdate(v) {
|
||||||
|
console.log(v)
|
||||||
|
this.subSelect = null
|
||||||
|
this.reqproto = []
|
||||||
|
},
|
||||||
|
subSelectUpdate(v) {
|
||||||
|
console.log(v)
|
||||||
|
this.reqproto = []
|
||||||
|
let keys = Object.keys(this.subSelect.reqproto.fields)
|
||||||
|
for (const v of keys) {
|
||||||
|
let ftype = this.subSelect.reqproto.fields[v].type
|
||||||
|
let fvalue = null
|
||||||
|
switch (this.subSelect.reqproto.fields[v].type) {
|
||||||
|
case 'int32':
|
||||||
|
case 'int64':
|
||||||
|
case 'uint32':
|
||||||
|
case 'uint64':
|
||||||
|
case 'float32':
|
||||||
|
case 'float64':
|
||||||
|
ftype = 'number'
|
||||||
|
fvalue = 0
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
ftype = 'text'
|
||||||
|
fvalue = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
this.reqproto.push({
|
||||||
|
FieldName: v,
|
||||||
|
FieldType: ftype,
|
||||||
|
FieldValue: fvalue,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
console.log(this.reqproto)
|
||||||
|
},
|
||||||
|
closelisten() {
|
||||||
|
this.isconnect = false
|
||||||
|
this.subSelect = null
|
||||||
|
this.reqproto = []
|
||||||
|
console.log('closelisten!')
|
||||||
|
this.pushlog('error', `连接断开${this.ws_url}`)
|
||||||
|
},
|
||||||
|
//接收服务的消息
|
||||||
|
receivelisten(msg) {
|
||||||
|
// console.log('接收到消息', msg.data.arrayBuffer())
|
||||||
|
msg.data
|
||||||
|
.arrayBuffer()
|
||||||
|
.then((buf) => new Uint8Array(buf))
|
||||||
|
.then((bytes) => {
|
||||||
|
console.log('bytes', bytes)
|
||||||
|
let message = proto.lookup('UserMessage').decode(bytes)
|
||||||
|
console.log('接收到消息 message', message)
|
||||||
|
let mainType = message.MainType
|
||||||
|
let subType = message.SubType
|
||||||
|
let iskeep = false
|
||||||
|
for (const v of this.proto_models) {
|
||||||
|
if (v.mainType == mainType) {
|
||||||
|
for (const v1 of v.subs) {
|
||||||
|
if (subType == v1.subType) {
|
||||||
|
console.log('接收到消息 v1', v1)
|
||||||
|
//找到消息组
|
||||||
|
iskeep = true
|
||||||
|
let protoobj = null
|
||||||
|
let messageobj = null
|
||||||
|
if (v1.respName) {
|
||||||
|
console.log('接收到消息 respName', v1.respName)
|
||||||
|
protoobj = proto
|
||||||
|
.lookup(v1.respName)
|
||||||
|
.decode(message.data.value)
|
||||||
|
messageobj = proto.lookup(v1.respName).toObject(protoobj)
|
||||||
|
// console.log('接收回应到消息 protoobj', protoobj)
|
||||||
|
} else {
|
||||||
|
console.log('接收到消息 pushName', v1.pushName)
|
||||||
|
protoobj = proto
|
||||||
|
.lookup(v1.pushName)
|
||||||
|
.decode(message.data.value)
|
||||||
|
messageobj = proto.lookup(v1.pushName).toObject(protoobj)
|
||||||
|
}
|
||||||
|
this.pushlog(
|
||||||
|
'success',
|
||||||
|
`收到回应消息: ${mainType}-${subType}-resp`,
|
||||||
|
messageobj
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (iskeep) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!iskeep) {
|
||||||
|
this.pushlog(
|
||||||
|
'error',
|
||||||
|
`接收消息错误 ${mainType}-${subType}`,
|
||||||
|
'未找到指定消息对象'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.log('接收到消息异常', error)
|
||||||
|
this.pushlog('error', '接收消息异常', { msg: msg, e: e })
|
||||||
|
})
|
||||||
|
},
|
||||||
|
//请求消息
|
||||||
|
reqprotohandle() {
|
||||||
|
console.log('protoName:', this.subSelect.reqName)
|
||||||
|
let protoobj = proto.lookup(this.subSelect.reqName)
|
||||||
|
for (const v of this.reqproto) {
|
||||||
|
protoobj[v.FieldName] = v.FieldValue
|
||||||
|
}
|
||||||
|
let message = proto.lookup('UserMessage')
|
||||||
|
let any = proto.lookup('google.protobuf.Any')
|
||||||
|
message.MainType = this.subSelect.mainType
|
||||||
|
message.SubType = this.subSelect.subType
|
||||||
|
message.data = any.create({
|
||||||
|
type_url: `type.googleapis.com/${this.subSelect.reqName}`,
|
||||||
|
value: proto.lookup(this.subSelect.reqName).encode(protoobj).finish(), // Or as packed buffer
|
||||||
|
})
|
||||||
|
if (this.subSelect.reqName == 'UserLoginReq') {
|
||||||
|
//登录协议特殊处理
|
||||||
|
message.sec = this.buildsecStr(protoobj.account, protoobj.sid)
|
||||||
|
} else {
|
||||||
|
message.sec = this.buildsecStr()
|
||||||
|
}
|
||||||
|
console.log('message:', message)
|
||||||
|
let buffer = proto.lookup('UserMessage').encode(message).finish()
|
||||||
|
console.log('req buff:', buffer)
|
||||||
|
socket.send(buffer)
|
||||||
|
this.pushlog(
|
||||||
|
'success',
|
||||||
|
`发送请求消息: ${message.MainType}-${message.SubType}-req`,
|
||||||
|
proto.lookup(this.subSelect.reqName).toObject(protoobj)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
buildsecStr(_account, _serverId) {
|
||||||
|
_account = _account ? _account : this.account
|
||||||
|
_serverId = _serverId ? _serverId : this.serverId
|
||||||
|
let jsonStr = JSON.stringify({
|
||||||
|
account: _account,
|
||||||
|
serverId: _serverId,
|
||||||
|
timestamp: Date.parse(new Date()) / 1000,
|
||||||
|
})
|
||||||
|
let baseStr = Base64.encode(jsonStr)
|
||||||
|
let clientMd5key = md5(baseStr)
|
||||||
|
console.log('clientMd5key:', clientMd5key)
|
||||||
|
return `CE:${clientMd5key}${baseStr}`
|
||||||
|
},
|
||||||
|
pushlog(_type, _title, _data) {
|
||||||
|
this.logs.push({
|
||||||
|
type: _type,
|
||||||
|
title: _title,
|
||||||
|
data: _data,
|
||||||
|
isshow: false,
|
||||||
|
})
|
||||||
},
|
},
|
||||||
loginreq() {},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user