using System; using Base; using Model; namespace Controller { /// /// 初始化游戏 /// [Event(EventIdType.InitSceneStart)] public class InitSceneStartEvent_InitGame: IEvent { public async void Run() { try { Game.Scene.AddComponent(AppType.Client); ClientConfig clientConfig = Game.Scene.AddComponent().Config.GetComponent(); NetOuterComponent networkComponent = Game.Scene.AddComponent(); using (Session session = networkComponent.Create(clientConfig.Address)) { R2C_Login s2CLogin = await session.Call(new C2R_Login { Account = "abcdef", Password = "111111" }); networkComponent.Remove(session.Id); // 连接Gate using (Session gateSession = networkComponent.Create(s2CLogin.Address)) { await gateSession.Call(new C2G_LoginGate(s2CLogin.Key)); } Log.Info("连接Gate验证成功!"); } } catch (Exception e) { Log.Error(e.ToString()); } } } }