C2R_LoginHandler.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Net;
  3. using ETModel;
  4. namespace ETHotfix
  5. {
  6. [MessageHandler(AppType.Realm)]
  7. public class C2R_LoginHandler : AMRpcHandler<C2R_Login, R2C_Login>
  8. {
  9. protected override async ETTask Run(Session session, C2R_Login request, R2C_Login response, Action reply)
  10. {
  11. //if (message.Account != "abcdef" || message.Password != "111111")
  12. //{
  13. // response.Error = ErrorCode.ERR_AccountOrPasswordError;
  14. // reply(response);
  15. // return;
  16. //}
  17. // 随机分配一个Gate
  18. StartConfig config = Game.Scene.GetComponent<RealmGateAddressComponent>().GetAddress();
  19. //Log.Debug($"gate address: {MongoHelper.ToJson(config)}");
  20. IPEndPoint innerAddress = config.GetComponent<InnerConfig>().IPEndPoint;
  21. Session gateSession = Game.Scene.GetComponent<NetInnerComponent>().Get(innerAddress);
  22. // 向gate请求一个key,客户端可以拿着这个key连接gate
  23. G2R_GetLoginKey g2RGetLoginKey = (G2R_GetLoginKey)await gateSession.Call(new R2G_GetLoginKey() {Account = request.Account});
  24. string outerAddress = config.GetComponent<OuterConfig>().Address2;
  25. response.Address = outerAddress;
  26. response.Key = g2RGetLoginKey.Key;
  27. reply();
  28. }
  29. }
  30. }