12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- namespace ET.Server
- {
- /// <summary>
- /// 登陆验证
- /// </summary>
- [MessageHandler(SceneType.Realm)]
- public class C2R_LoginHandler: AMRpcHandler<C2R_Login, R2C_Login>
- {
- protected override async ETTask Run(Session session, C2R_Login request, R2C_Login response, Action reply)
- {
- if (session.DomainScene().SceneType != SceneType.Realm)
- {
- Log.Debug($"请求的Scene错误...SceneType={session.DomainScene().SceneType}");
- session.Dispose();
- return;
- }
- // 重复请求
- if (session.GetComponent<SessionLockComponent>() != null)
- {
- response.Error = ErrorCode.ERR_RequestRepeatedly;
- reply();
- return;
- }
- session.AddComponent<SessionLockComponent>();
- // todo 生成token, 后期改成正式token
- // string token = request.RoomId;
- // todo 服务器列表,暂定根据cpu负载做负载均衡
- List<StartSceneConfig> gameList = RealmGateAddressHelper.GetAllGame(session.DomainZone());
- if (gameList is { Count: > 0 })
- {
- response.Address = new List<string>();
- foreach (StartSceneConfig config in gameList)
- {
- response.Address.Add(config.OuterIPPort.ToString());
- }
- }
- reply();
- await ETTask.CompletedTask;
- }
- }
- }
|