C2G_LoginGateHandler.cs 761 B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using Model;
  3. namespace Hotfix
  4. {
  5. [MessageHandler(AppType.Gate)]
  6. public class C2G_LoginGateHandler : AMRpcHandler<C2G_LoginGate, G2C_LoginGate>
  7. {
  8. protected override async void Run(Session session, C2G_LoginGate message, Action<G2C_LoginGate> reply)
  9. {
  10. G2C_LoginGate response = new G2C_LoginGate();
  11. try
  12. {
  13. bool isCheckOK = Game.Scene.GetComponent<GateSessionKeyComponent>().Check(message.Key);
  14. if (!isCheckOK)
  15. {
  16. response.Error = ErrorCode.ERR_ConnectGateKeyError;
  17. response.Message = "Gate key验证失败!";
  18. }
  19. reply(response);
  20. await Game.Scene.GetComponent<TimerComponent>().WaitAsync(5000);
  21. session.Dispose();
  22. }
  23. catch (Exception e)
  24. {
  25. ReplyError(response, e, reply);
  26. }
  27. }
  28. }
  29. }