protected override async ETTask Run(Session session, C2G_LoginGate request, G2C_LoginGate response, Action reply) { Scene scene = session.DomainScene(); string account = scene.GetComponent <GateSessionKeyComponent>().Get(request.Key); if (account == null) { response.Error = ErrorCore.ERR_ConnectGateKeyError; response.Message = "Gate key验证失败!"; reply(); return; } session.RemoveComponent <SessionAcceptTimeoutComponent>(); PlayerComponent playerComponent = scene.GetComponent <PlayerComponent>(); Player player = playerComponent.AddChild <Player, string>(account); playerComponent.Add(player); session.AddComponent <SessionPlayerComponent>().PlayerId = player.Id; session.AddComponent <MailBoxComponent, MailboxType>(MailboxType.GateSession); response.PlayerId = player.Id; reply(); await ETTask.CompletedTask; }
public static void Add(this PlayerComponent self, Player player) { self.idPlayers.Add(player.Id, player); }
public static void Remove(this PlayerComponent self, long id) { self.idPlayers.Remove(id); }
public static Player[] GetAll(this PlayerComponent self) { return(self.idPlayers.Values.ToArray()); }
public static Player Get(this PlayerComponent self, long id) { self.idPlayers.TryGetValue(id, out Player gamer); return(gamer); }