A2C_DisconnectHandler.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using GFGGame;
  2. using UnityEngine;
  3. namespace ET
  4. {
  5. public class A2C_DisconnectHandler : AMHandler<A2C_Disconnect>
  6. {
  7. protected override async ETTask Run(Session session, A2C_Disconnect message)
  8. {
  9. session?.GetComponent<DisConnectedCompnent>()?.CancelAlert();
  10. session.Dispose();
  11. switch (message.Error)
  12. {
  13. case ErrorCode.ERR_loginTimeOut:
  14. AlertSystem.Show("登录超时,请重新登录!")
  15. .SetLeftButton(true, "返回登录", (obj) =>
  16. {
  17. GameController.QuitToLoginView(false);
  18. });
  19. break;
  20. case ErrorCode.ERR_loginByOther:
  21. AlertSystem.Show("账号已在其他地方登录!")
  22. .SetLeftButton(true, "返回登录", (obj) =>
  23. {
  24. GameController.QuitToLoginView(true);
  25. });
  26. break;
  27. case ErrorCode.Err_ServerMaintain:
  28. AlertUI.Show("服务器维护中!")
  29. .SetLeftButton(true, "稍后再试", (obj) =>
  30. {
  31. Application.Quit();
  32. });
  33. break;
  34. default:
  35. if (string.IsNullOrEmpty(message.Message))
  36. {
  37. AlertSystem.Show(message.Message)
  38. .SetLeftButton(true, "返回登录", (obj) =>
  39. {
  40. GameController.QuitToLoginView(true);
  41. });
  42. }
  43. else
  44. {
  45. AlertSystem.Show("您已被迫下线!");
  46. }
  47. break;
  48. }
  49. await ETTask.CompletedTask;
  50. }
  51. }
  52. }