AccountSProxy.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using ET;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace GFGGame
  8. {
  9. public static class AccountSProxy
  10. {
  11. public static async ETTask<bool> ReqDeleteAccount(string name, string identityNum)
  12. {
  13. A2C_ReqDeleteAccount response = null;
  14. bool notLogin = false;
  15. Session accountSession = GameGlobal.zoneScene.GetComponent<SessionComponent>().AccountSession;
  16. if (accountSession == null || accountSession.IsDisposed)
  17. {
  18. notLogin = true;
  19. accountSession = GameGlobal.zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(GameConfig.LoginAddress));
  20. }
  21. try
  22. {
  23. AccountInfoComponent accountInfoComponent = GameGlobal.zoneScene.GetComponent<AccountInfoComponent>();
  24. response = (A2C_ReqDeleteAccount)await accountSession?.Call(new C2A_ReqDeleteAccount()
  25. {
  26. Account = accountInfoComponent.Account,
  27. Name = name,
  28. IdentityNum = identityNum,
  29. PlatformId = LauncherConfig.platformId,
  30. ChannelId = LauncherConfig.ChannelId
  31. });
  32. }
  33. catch(Exception e)
  34. {
  35. Log.Debug(e.ToString());
  36. ErrorCodeController.Handler(ErrorCode.ERR_NetWorkError);
  37. if (notLogin)
  38. {
  39. accountSession?.Dispose();
  40. }
  41. return false;
  42. }
  43. if(response.Error != ErrorCode.ERR_Success)
  44. {
  45. ErrorCodeController.Handler(response.Error);
  46. if (notLogin)
  47. {
  48. accountSession?.Dispose();
  49. }
  50. return false;
  51. }
  52. if (notLogin)
  53. {
  54. accountSession?.Dispose();
  55. }
  56. return true;
  57. }
  58. }
  59. }