CMsgLoginEvent.cs 839 B

1234567891011121314151617181920212223242526272829
  1. using Common.Helper;
  2. using Common.Network;
  3. using Model;
  4. namespace Controller.Message
  5. {
  6. public class CMsgLogin
  7. {
  8. public byte[] Account { get; set; }
  9. public byte[] PassMd5 { get; set; }
  10. }
  11. [Message(MessageType.CMsgLogin)]
  12. internal class CMsgLoginEvent: IEventSync
  13. {
  14. public void Run(Env env)
  15. {
  16. var messageBytes = env.Get<byte[]>(EnvKey.Message);
  17. CMsgLogin cmsg = MongoHelper.FromBson<CMsgLogin>(messageBytes, 2);
  18. Unit unit = World.Instance.GetComponent<FactoryComponent<Unit>>().Create(UnitType.GatePlayer, 1);
  19. AChannel channel = env.Get<AChannel>(EnvKey.Channel);
  20. ChannelUnitInfoComponent channelUnitInfoComponent =
  21. channel.AddComponent<ChannelUnitInfoComponent>();
  22. channelUnitInfoComponent.Account = cmsg.Account;
  23. channelUnitInfoComponent.PlayerId = unit.Id;
  24. }
  25. }
  26. }