| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- using System;
- using ET;
- namespace GFGGame
- {
- public static class SecurityHelper
- {
- /// <summary>
- /// 未进入游戏前--请求获取验证码
- /// </summary>
- /// <param name="account"></param>
- /// <param name="reqType"></param>
- /// <returns></returns>
- public static async ETTask<S2C_GetMobileVerificationCode> GetMobileVerificationCode(string account,
- SendCodeType reqType)
- {
- S2C_GetMobileVerificationCode s2CGetMobileVerificationCode = null;
- Session session = null;
- try
- {
- session = GameGlobal.zoneScene.GetComponent<NetKcpComponent>()
- .Create(NetworkHelper.ToIPEndPoint(GameConfig.LoginAddress));
- s2CGetMobileVerificationCode = (S2C_GetMobileVerificationCode)await session.Call(
- new C2S_GetMobileVerificationCode()
- {
- PhoneNumber = account,
- ReqType = reqType,
- });
- }
- catch (Exception e)
- {
- session?.Dispose();
- Log.Debug(e.ToString());
- return s2CGetMobileVerificationCode;
- }
-
- return s2CGetMobileVerificationCode;
- }
- /// <summary>
- /// 账号找回
- /// </summary>
- /// <param name="code"></param>
- /// <param name="phoneNumber"></param>
- /// <returns></returns>
- public static async ETTask<A2C_GetAccountListByPhone> GetAccountListByPhone(string code,
- string phoneNumber)
- {
- A2C_GetAccountListByPhone res = null;
- Session session = null;
- try
- {
- session = GameGlobal.zoneScene.GetComponent<NetKcpComponent>()
- .Create(NetworkHelper.ToIPEndPoint(GameConfig.LoginAddress));
- res = (A2C_GetAccountListByPhone)await session.Call(
- new C2A_GetAccountListByPhone()
- {
- Code = code,
- ChannelId = LauncherConfig.ChannelId,
- PhoneNumber = phoneNumber
- });
- }
- catch (Exception e)
- {
- session?.Dispose();
- Log.Debug(e.ToString());
- return res;
- }
- return res;
- }
- /// <summary>
- /// 修改密码
- /// </summary>
- /// <param name="code"></param>
- /// <param name="phoneNumber"></param>
- /// <param name="account"></param>
- /// <param name="password"></param>
- /// <returns></returns>
- public static async ETTask<A2C_UpPassword> UpPassword(string code,
- string phoneNumber, string account, string password)
- {
- A2C_UpPassword res = null;
- Session session = null;
- password = MD5Helper.stringMD5(password);
- try
- {
- session = GameGlobal.zoneScene.GetComponent<NetKcpComponent>()
- .Create(NetworkHelper.ToIPEndPoint(GameConfig.LoginAddress));
- res = (A2C_UpPassword)await session.Call(
- new C2A_UpPassword()
- {
- Code = code,
- ChannelId = LauncherConfig.ChannelId,
- PhoneNumber = phoneNumber,
- Account = account,
- Password = password,
- });
- }
- catch (Exception e)
- {
- session?.Dispose();
- Log.Debug(e.ToString());
- return res;
- }
- return res;
- }
- /// <summary>
- /// 游戏内获取验证码
- /// </summary>
- /// <param name="phoneNumber"></param>
- /// <param name="reqType"></param>
- /// <returns></returns>
- public static async ETTask<S2C_GetMobileVerificationCodeUnit> GetMobileVerification(string phoneNumber,
- SendCodeType reqType)
- {
- S2C_GetMobileVerificationCodeUnit res = null;
- try
- {
- res = (S2C_GetMobileVerificationCodeUnit)await MessageHelper.SendToServer(
- new C2S_GetMobileVerificationCodeUnit() { PhoneNumber = phoneNumber, ReqType = reqType });
- }
- catch (Exception e)
- {
- Log.Debug(e.ToString());
- return res;
- }
- return res;
- }
- /// <summary>
- /// 游戏内绑定手机
- /// </summary>
- /// <param name="phoneNumber"></param>
- /// <param name="code"></param>
- /// <returns></returns>
- public static async ETTask<S2C_BindMobilePhoneNumber> BindMobilePhoneNumber(string phoneNumber, string code)
- {
- S2C_BindMobilePhoneNumber res = null;
- try
- {
- res = (S2C_BindMobilePhoneNumber)await MessageHelper.SendToServer(new C2S_BindMobilePhoneNumber()
- { PhoneNumber = phoneNumber, VerCode = code });
- }
- catch (Exception e)
- {
- Log.Debug(e.ToString());
- return res;
- }
- return res;
- }
- /// <summary>
- /// 游戏内解除手机号绑定
- /// </summary>
- /// <param name="phoneNumber"></param>
- /// <param name="code"></param>
- /// <returns></returns>
- public static async ETTask<S2C_UnbindMobilePhoneNumber> UnbindMobilePhoneNumber(string phoneNumber, string code)
- {
- S2C_UnbindMobilePhoneNumber res = null;
- try
- {
- res = (S2C_UnbindMobilePhoneNumber)await MessageHelper.SendToServer(new C2S_UnbindMobilePhoneNumber()
- { PhoneNumber = phoneNumber, VerCode = code });
- }
- catch (Exception e)
- {
- Log.Debug(e.ToString());
- return res;
- }
- return res;
- }
- }
- }
|