static public int Dispose(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif ETModel.Session self = (ETModel.Session)checkSelf(l); self.Dispose(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
public static async ETVoid OnLoginAsync(Entity domain, string account) { try { // 创建一个ETModel层的Session ETModel.Session session = ETModel.Game.Scene.GetComponent<NetOuterComponent>().Create(GlobalConfigComponent.Instance.GlobalProto.Address); // 创建一个ETHotfix层的Session, ETHotfix的Session会通过ETModel层的Session发送消息 Session realmSession = EntityFactory.Create<Session, ETModel.Session>(domain, session); R2C_Login r2CLogin = (R2C_Login) await realmSession.Call(new C2R_Login() { Account = account, Password = "******" }); realmSession.Dispose(); // 创建一个ETModel层的Session,并且保存到ETModel.SessionComponent中 ETModel.Session gateSession = ETModel.Game.Scene.GetComponent<NetOuterComponent>().Create(r2CLogin.Address); ETModel.Game.Scene.AddComponent<ETModel.SessionComponent>().Session = gateSession; // 创建一个ETHotfix层的Session, 并且保存到ETHotfix.SessionComponent中 Game.Scene.AddComponent<SessionComponent>().Session = EntityFactory.Create<Session, ETModel.Session>(Game.Scene, gateSession); G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await SessionComponent.Instance.Session.Call( new C2G_LoginGate() { Key = r2CLogin.Key, GateId = r2CLogin.GateId}); Log.Info("登陆gate成功!"); // 创建Player Player player = ETModel.EntityFactory.CreateWithId<Player>(ETModel.Game.Scene, g2CLoginGate.PlayerId); PlayerComponent playerComponent = ETModel.Game.Scene.GetComponent<PlayerComponent>(); playerComponent.MyPlayer = player; Game.EventSystem.Run(EventIdType.LoginFinish); // 测试消息有成员是class类型 G2C_PlayerInfo g2CPlayerInfo = (G2C_PlayerInfo) await SessionComponent.Instance.Session.Call(new C2G_PlayerInfo()); } catch (Exception e) { Log.Error(e); } }
private async Task RequestUpdateServer() { UINetLoadingComponent.showNetLoading(); IPEndPoint manager = UILoginComponent.ToIPEndPointWithYuMing(10000); ETModel.Session managerSession = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(manager); M2C_Reload g2cUpdateServer = (M2C_Reload)await managerSession.Call(new C2M_Reload() { AppType = AppType.Map }); UINetLoadingComponent.closeNetLoading(); if (g2cUpdateServer.Error != ErrorCode.ERR_Success) { ToastScript.createToast(g2cUpdateServer.Message); return; } ToastScript.createToast("更新成功"); managerSession.Dispose(); }
//A0 01注册 02登录realm 03登录gate public static async ETVoid Login(string account, string password) { LandLoginComponent login = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandLogin).GetComponent <LandLoginComponent>(); //创建Realm session Session sessionRealm = Game.Scene.GetComponent <NetOuterComponent>().Create(GlobalConfigComponent.Instance.GlobalProto.Address); A0002_Login_R2C messageRealm = (A0002_Login_R2C)await sessionRealm.Call(new A0002_Login_C2R() { Account = account, Password = password }); sessionRealm.Dispose(); login.prompt.text = "正在登录中..."; //判断Realm服务器返回结果 if (messageRealm.Error == ErrorCode.ERR_AccountOrPasswordError) { login.prompt.text = "登录失败,账号或密码错误"; login.account.text = ""; login.password.text = ""; login.isLogining = false; return; } //判断通过则登陆Realm成功 //创建网关 session Session sessionGate = Game.Scene.GetComponent <NetOuterComponent>().Create(messageRealm.GateAddress); if (SessionComponent.Instance == null) { Log.Debug("创建唯一Session"); Game.Scene.AddComponent <SessionComponent>().Session = sessionGate; } else { //存入SessionComponent方便我们随时使用 Log.Debug("存入SessionComponent方便我们随时使用"); SessionComponent.Instance.Session = sessionGate; //Game.EventSystem.Run(EventIdType.SetHotfixSession); } A0003_LoginGate_G2C messageGate = (A0003_LoginGate_G2C)await sessionGate.Call(new A0003_LoginGate_C2G() { GateLoginKey = messageRealm.GateLoginKey }); //判断登陆Gate服务器返回结果 if (messageGate.Error == ErrorCode.ERR_ConnectGateKeyError) { login.prompt.text = "连接网关服务器超时"; login.account.text = ""; login.password.text = ""; sessionGate.Dispose(); login.isLogining = false; return; } //判断通过则登陆Gate成功 login.prompt.text = ""; User user = ComponentFactory.Create <User, long>(messageGate.UserID); GamerComponent.Instance.MyUser = user; //Log.Debug("登陆成功"); //加载透明界面 退出当前界面 Game.EventSystem.Run(UIEventType.LandLoginFinish); // 加载大厅界面 Game.EventSystem.Run(UIEventType.LandInitLobby); }
public static async ETVoid Login(string account, string password) { SekiaLoginComponent login = Game.Scene.GetComponent <FUIComponent>().Get(FUIType.SekiaLogin).GetComponent <SekiaLoginComponent>(); Session sessionRealm = Game.Scene.GetComponent <NetOuterComponent>().Create(GlobalConfigComponent.Instance.GlobalProto.Address); A0002_Login_R2C messageRealm = (A0002_Login_R2C)await sessionRealm.Call(new A0002_Login_C2R() { Account = account, Password = password }); sessionRealm.Dispose(); login.Prompt.GObject.asTextField.text = "正在登录中..."; //判断Realm服务器返回结果 if (messageRealm.Error == ErrorCode.ERR_AccountOrPasswordError) { login.Prompt.GObject.asTextField.text = "登录失败,账号或密码错误"; login.AccountInput.Get("Input").GObject.asTextInput.text = ""; login.PasswordInput.Get("Input").GObject.asTextInput.text = ""; login.isLogining = false; return; } //判断通过则登陆Realm成功 //创建唯一Session Session sessionGate = Game.Scene.GetComponent <NetOuterComponent>().Create(messageRealm.GateAddress); if (SessionComponent.Instance == null) { //Log.Debug("创建唯一Session"); Game.Scene.AddComponent <SessionComponent>().Session = sessionGate; } else { SessionComponent.Instance.Session = sessionGate; } A0003_LoginGate_G2C messageGate = (A0003_LoginGate_G2C)await sessionGate.Call(new A0003_LoginGate_C2G() { GateLoginKey = messageRealm.GateLoginKey }); //判断登陆Gate服务器返回结果 if (messageGate.Error == ErrorCode.ERR_ConnectGateKeyError) { login.Prompt.GObject.asTextField.text = "连接网关服务器超时"; login.AccountInput.Get("Input").GObject.asTextInput.text = ""; login.PasswordInput.Get("Input").GObject.asTextInput.text = ""; sessionGate.Dispose(); login.isLogining = false; return; } //判断通过则登陆Gate成功 login.Prompt.GObject.asTextField.text = ""; User user = ComponentFactory.Create <User, long>(messageGate.UserID); GamerComponent.Instance.MyUser = user; //Log.Debug("登陆成功"); //获取角色信息判断应该进入哪个界面 A0008_GetUserInfo_G2C messageUser = (A0008_GetUserInfo_G2C)await sessionGate.Call(new A0008_GetUserInfo_C2G()); //消息中包含了3个CharacterInfo //正常的角色等级为正整数 if (messageUser.Characters.Count == 3 && messageUser.Characters[0].Level == 0 && messageUser.Characters[1].Level == 0 && messageUser.Characters[2].Level == 0) { //进入创建角色界面 CreateCharacterFactory.Create(messageUser); CreateCharacterComponent creater = Game.Scene.GetComponent <FUIComponent>().Get(FUIType.CreateCharacter).GetComponent <CreateCharacterComponent>(); creater.Seat = 1; //创建第一个空位的角色 } else if (messageUser.Characters.Count == 3 && (messageUser.Characters[0].Level > 0 || messageUser.Characters[1].Level > 0 || messageUser.Characters[2].Level > 0)) { //进入角色选择界面 SelectCharacterFactory.Create(messageUser); } Game.EventSystem.Run(EventIdType.SekiaLoginFinish); }