A2C_DisconnectHandler.cs 1.6 KB

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