浏览代码

make it cross app

joe 4 年之前
父节点
当前提交
2fb8aee238
共有 7 个文件被更改,包括 110 次插入105 次删除
  1. 9 0
      confs.proto
  2. 4 4
      gossip.proto
  3. 40 55
      login.proto
  4. 28 18
      login_internal.proto
  5. 2 2
      outline.proto
  6. 5 5
      redis.proto
  7. 22 21
      tajmahal.proto

+ 9 - 0
confs.proto

@@ -39,6 +39,15 @@ message LoginConfConf {
     string password         = 2;
 }
 
+message AppConfConf {
+    string namespace    = 1;
+    uint64 id           = 2;
+    string addr         = 3;
+    string rpcAddr      = 5;
+    string externalAddr = 6;
+    int32 offline       = 7;
+}
+
 message AppConf {
     ConfConf zoo        = 1;
     string namespace    = 2;

+ 4 - 4
gossip.proto

@@ -16,18 +16,18 @@ message A_Heartbeat {
 
 // 掉线
 message Q_Offline {
-    uint64 guid     = 1;
+    uint64 userId     = 1;
 }
 
 message A_Offline {
-    uint64 guid     = 1;
+    uint64 userId     = 1;
 }
 
 // 断线重连
 message Q_Online {
-    uint64 guid     = 1;
+    uint64 userId     = 1;
 }
 
 message A_Online {
-    uint64 guid     = 1;
+    uint64 userId     = 1;
 }

+ 40 - 55
login.proto

@@ -11,83 +11,68 @@ enum RegType {
     REG_PHONE   = 1;
 }
 
-message L_Hash {
+// 请求图片验证码
+message ReqVerifyImg {
 
 }
 
-message M_Hash {
-    string hash = 1;
-    int64 ts    = 2;
+message RespVerifyImg {
+    string b64id    = 1;
+    string b64img   = 2;
 }
 
 // 请求验证码
 // 发送至邮箱(手机)
-message P_RequestVerifiCode {
-    string dest     = 1;
-    int64 ts        = 2;
-    string hash     = 3;
+message ReqVerifyCode {
+    string username     = 1;    // email/phone
+    string b64id        = 2;
+    string imgCode      = 3;
+}
+
+message RespVerifyCode {
+    int32 needVerify    = 1;
 }
 
 // 注册
-message L_Register {
-    int32 rt            = 1;            // 注册类型 optional 定义在 RegType,这里用整型表示
+message ReqRegister {
+    int32 regType       = 1;            // 注册类型 optional 定义在 RegType,这里用整型表示
     string username     = 2;            // 注册使用手机或邮箱
-    string verifiCode   = 3;            // 验证码
-    string password     = 4;
-    int64 ts            = 5;
-    string hash         = 6;
-    int32 platform      = 7;
-    int32 from          = 8;
+    string password     = 3;            // 验证码
+    string verifyCode   = 4;
+    int32 platform      = 7;            // 客户端平台
+    int32 pulish        = 8;            // 渠道
 }
 
-message M_Register {
-    int32 ec        = 1;
-    string username = 2;
-    uint64 guid     = 3;
+message RespRegister {
+    string username = 1;
+    uint64 userId   = 3;
     string token    = 4;
     string url      = 5;    // 注册成功不需要再次登录的情况,相当与登录成功的跳转
 }
 
-// 登录
-message L_Login {
-    int32  lt           = 1;    // 登录类型
-    string username     = 3;    // 这里是 email
-    string password     = 4;
-    int64 ts            = 5;
-    string hash         = 6;
-}
-
-message M_Login {
-    int32  ec       = 1;
-    uint64 guid     = 2;
-    string username = 3;
-    string token    = 5;
-    string url      = 6;
+// 注销
+message ReqDestroy {
+    uint64 userId       = 1;
+    string token        = 2;
+    string verifyCode   = 3;
 }
 
-// 手机通过验证码重置密码,暂不支持手机号注册
+message RespDestroy {
 
-/// 邮箱重置密码
-/// 邮箱重置密码后, 用户邮箱会收到一个 url,在该 url 页面重置密码,
-/// 再走登录流程
-message L_TryResetByEmail {
-    string email    = 1;
-    int64 ts        = 2;
-    string hash     = 5;
 }
 
-message M_TryResetByEmail {
-    int32 ec        = 1;
-    string email    = 3;
+// 登录
+message ReqLogin {
+    string username     = 1;    // email/phone
+    string password     = 4;
+    string b64id        = 5;
+    string imgCode      = 6;
+    string verifyCode   = 7;
 }
-// 这里隐含一个重置密码的 web 页面
 
-// 重置请求
-message L_ResetByEmail {
-    string email    = 1;
-    string password = 2;
+message RespLogin {
+    uint64 userId   = 1;
+    string username = 3;
+    string token    = 5;
+    string redirect = 6;
 }
-
-message M_ResetByEmail {
-    int32 ec        = 1;
-}

+ 28 - 18
login_internal.proto

@@ -3,6 +3,15 @@ package protos;
 
 option go_package = ".;protos";
 
+/// 命令
+
+enum LoginternalCmd {
+    bl_placeholder      = 0;
+    bl_heartbeat        = 1;
+    bl_login_verify     = 2;
+    bl_update_userinfo  = 3;
+}
+
 /// login 到 agent 通信协议
 
 message OfflineResult {
@@ -11,11 +20,14 @@ message OfflineResult {
 
 /// 逻辑服务器报告状态作为心跳
 message StatusParams {
-    int32 active    = 1;            // 链接数
-    int32 support   = 2;            // 最大支持连接数
-    int64 ts        = 4;            // 当前时间
+    uint64 id       = 1;
+    int64 ts        = 2;            // 当前时间
+    int32 active    = 3;            // 链接数
+    int32 support   = 4;            // 最大支持连接数
     string addr     = 5;            // 地址
     int32 priority  = 8;            // 进程优先级
+    int32 mem       = 9;            // memory load
+    int32 cpu       = 10;           // cpu load
 }
 
 message StatusResult {
@@ -25,35 +37,33 @@ message StatusResult {
 
 /// 用户更新密码后需要通知登录服务器
 /// 失败必须重试,如果重试失败需要记录日志手动修改
-message UpdatePasswordParams {
-    uint64 guid          = 1;
-    string username     = 2;
-    string password     = 3;
+message UpdateUserParams {
+    uint64 userId           = 1;
+    int64 ts                = 2;
+    map<string, string> fv  = 3;
 }
 
-message UpdatePasswordResult {
-    uint64 guid         = 1;
-    string username     = 2;
-    string password     = 3;
+message UpdateUserResult  {
+    uint64 userId           = 1;
+    map<string, string> fv  = 3;
 }
 
-
 /// 逻辑服务验证用户 token。
-/// 登录服务器的返回 guid, token 必须和请求一致,
+/// 登录服务器的返回 userId, token 必须和请求一致,
 /// 登录服务器可以续租, 但不可更新 token
 
 message VerifyParams {
-    uint64  guid    = 1;
+    uint64 userId   = 1;
     string username = 2;
     string token    = 3;
 }
 
 message VerifyResult {
-    uint64 guid     = 1;
+    uint64 userId   = 1;
     string token    = 4;
     string nickname = 5;
-    string password = 6;
+    string headerIcon = 6;
     string username = 8;
-    int32 from      = 10;   // 用户注册渠道 见 UserFrom
-    int32 platform  = 11;
+    int32 publish   = 10;   // 用户注册渠道 见 UserFrom
+    int32 platform  = 11;   // android/ios/web
 }

+ 2 - 2
outline.proto

@@ -7,14 +7,14 @@ option go_package = ".;protos";
 
 message Request{
 	int32 msgId 		= 1;
-	uint64 guid 		= 2;
+	uint64 userId 		= 2;
 	string msgName	= 3;
 	bytes  req      = 10;
 }
 
 message Response{
 	int32 msgId 		= 1;
-	uint64 guid 		= 2;
+	uint64 userId 		= 2;
 	string msgName	= 3;
 	int32  ec       = 4;
 	bytes  res      = 10;

+ 5 - 5
redis.proto

@@ -5,22 +5,22 @@ option go_package = ".;protos";
 
 // 用户基本信息,主要用于 login 服务器使用
 message UserBase {
-    uint64 guid         = 1;
+    uint64 userId       = 1;
     string username     = 2;
     string nickname     = 3;
     string password     = 4;
     int32 platform      = 5;
-    int32 from          = 6;
+    int32 publish       = 6;
     string token        = 7;
 }
 
 message User {
-    uint64 guid         = 1;    // 最少5位的 guid
+    uint64 userId       = 1;    // 最少5位的 guid
     string username     = 2;    // 注册邮箱或第三方登录拉取
     string nickname     = 3;    // 昵称,可以从第三方登录拉取,也可随机生成
-    int32 headerIcon    = 4;
+    string headerIcon   = 4;
     int32 platform      = 5;    // 客户端
-    int32 from          = 6;    // 注册渠道
+    int32 publish       = 6;    // 注册渠道
     int32 level         = 7;    // 等级
     string password     = 8;    // 密码
     string token        = 10;   // (临时数据)

+ 22 - 21
tajmahal.proto

@@ -3,8 +3,6 @@ package protos;
 
 option go_package = ".;protos";
 
-import "enums.proto";
-
 /// 逻辑服务器之外(大厅,对应进程 tajmahal )的到客户端的协议
 
 /// 无法识别
@@ -12,7 +10,7 @@ message S_NotFound {
 }
 
 message S_Offline {
-    NetCloseReason reason = 1;
+    int32 reason = 1;
 }
 
 /// 心跳
@@ -27,27 +25,30 @@ message S_Heartbeat {
 
 /// 登录逻辑服务器
 message C_Login {
-    string username = 1;
-    string token    = 2;
+    uint64 userId   = 1;
+    string username = 2;
+    string token    = 3;
 }
 
 message S_Login {
-    string nickname             = 1;
-    int32  headerIcon           = 2;
-    string remoteIP             = 3;
-    int32  level                = 4;
-    string username             = 5;        // 手机号或邮箱
-    int64 birthday              = 6;
-    int32 gender                = 7;
-    int64 score                 = 8;
-    string curTitle             = 9;        // 当前使用称号
-    map<string, int64> balances = 12;       // 币,数量
-    map<string, string> wallets = 14;       // 钱包地址
-    string verServer            = 16;       // 服务端当前版本号
-    string verClient            = 18;       // 客户端最新版本号
-    int32 lang                  = 20;       // 语言
-    int32 volBg                 = 21;       // 背景音量
-    int32 volFg                 = 22;       // 前景音量
+    uint64 userId               = 1;
+    string nickname             = 2;
+    int32  headerIcon           = 3;
+    string remoteIP             = 5;
+    int32  level                = 6;
+    string username             = 7;        // 手机号或邮箱
+    int64 birthday              = 10;
+    int32 gender                = 11;
+    int64 score                 = 12;
+    int64 balance               = 13;
+    string curTitle             = 14;        // 当前使用称号
+    map<string, int64> balances = 18;       // 币,数量
+    map<string, string> wallets = 19;       // 钱包地址
+    string verServer            = 31;       // 服务端当前版本号
+    string verClient            = 33;       // 客户端最新版本号
+    int32 lang                  = 35;       // 语言
+    int32 volBg                 = 41;       // 背景音量
+    int32 volFg                 = 42;       // 前景音量
 }
 
 // 背包