using System; using ET; namespace GFGGame { public static class SecurityHelper { /// /// 未进入游戏前--请求获取验证码 /// /// /// /// public static async ETTask GetMobileVerificationCode(string account, SendCodeType reqType) { S2C_GetMobileVerificationCode s2CGetMobileVerificationCode = null; Session session = null; try { session = GameGlobal.zoneScene.GetComponent() .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; } /// /// 账号找回 /// /// /// /// public static async ETTask GetAccountListByPhone(string code, string phoneNumber) { A2C_GetAccountListByPhone res = null; Session session = null; try { session = GameGlobal.zoneScene.GetComponent() .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; } /// /// 修改密码 /// /// /// /// /// /// public static async ETTask 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() .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; } /// /// 游戏内获取验证码 /// /// /// /// public static async ETTask 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; } /// /// 游戏内绑定手机 /// /// /// /// public static async ETTask 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; } /// /// 游戏内解除手机号绑定 /// /// /// /// public static async ETTask 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; } } }