AccountSProxy.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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<NetWSComponent>()
  20. .Create(null, GameConfig.LoginAddress);
  21. }
  22. try
  23. {
  24. AccountInfoComponent accountInfoComponent = GameGlobal.zoneScene.GetComponent<AccountInfoComponent>();
  25. response = (A2C_ReqDeleteAccount)await accountSession?.Call(new C2A_ReqDeleteAccount()
  26. {
  27. Account = accountInfoComponent.Account,
  28. Name = name,
  29. IdentityNum = identityNum,
  30. PlatformId = LauncherConfig.platformId,
  31. ChannelId = LauncherConfig.ChannelId
  32. });
  33. }
  34. catch (Exception e)
  35. {
  36. Log.Debug(e.ToString());
  37. ErrorCodeController.Handler(ErrorCode.ERR_NetWorkError);
  38. if (notLogin)
  39. {
  40. accountSession?.Dispose();
  41. }
  42. return false;
  43. }
  44. if (response.Error != ErrorCode.ERR_Success)
  45. {
  46. ErrorCodeController.Handler(response.Error);
  47. if (notLogin)
  48. {
  49. accountSession?.Dispose();
  50. }
  51. return false;
  52. }
  53. if (notLogin)
  54. {
  55. accountSession?.Dispose();
  56. }
  57. return true;
  58. }
  59. }
  60. }