Exemplo n.º 1
0
        public async void Run()
        {
            Game.Scene.AddComponent <MessageDispatherComponent, AppType>(AppType.Client);
            ClientConfig     clientConfig     = Game.Scene.AddComponent <ClientConfigComponent>().Config;
            NetworkComponent networkComponent = Game.Scene.AddComponent <NetOuterComponent>();
            Session          session          = networkComponent.Get(clientConfig.Address);

            try
            {
                R2C_Login s2CLogin = await session.Call <C2R_Login, R2C_Login>(new C2R_Login { Account = "abcdef", Password = "******" });

                networkComponent.Remove(session.Id);

                // 连接Gate
                Log.Debug(MongoHelper.ToJson(s2CLogin));
                Session gateSession = networkComponent.Get(s2CLogin.Address);
                await gateSession.Call <C2G_LoginGate, G2C_LoginGate>(new C2G_LoginGate(s2CLogin.Key));

                Log.Info("连接Gate验证成功!");
            }
            catch (RpcException e)
            {
                Log.Error(e.ToString());
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
            }
        }
Exemplo n.º 2
0
        private void OnGUI()
        {
            if (!Application.isPlaying)
            {
                GUILayout.Label("请启动游戏!");
                return;
            }


            AppType reloadType = AppType.None;

            this.isAll = GUILayout.Toggle(this.isAll, "All");
            if (this.isAll)
            {
                for (int i = 0; i < this.isCheck.Length; ++i)
                {
                    this.isCheck[i] = true;
                }
            }

            for (int i = 0; i < this.serverTypes.Count; ++i)
            {
                this.isCheck[i] = GUILayout.Toggle(this.isCheck[i], this.serverTypes[i].ToString());
                if (!this.isCheck[i])
                {
                    this.isAll = false;
                }
            }

            this.managerAddress = EditorGUILayout.TextField("Manager Address: ", this.managerAddress);

            if (GUILayout.Button("Reload"))
            {
                for (int i = 0; i < this.isCheck.Length; ++i)
                {
                    if (this.isCheck[i])
                    {
                        reloadType = reloadType | this.serverTypes[i];
                    }
                }
                NetworkComponent networkComponent = Game.Scene.GetComponent <NetOuterComponent>();
                Session          session          = networkComponent.Get($"{this.managerAddress}");
                try
                {
                    session.Call <C2M_Reload, M2C_Reload>(new C2M_Reload {
                        AppType = reloadType
                    });
                }
                catch (RpcException e)
                {
                    Log.Error(e.ToString());
                }
                Log.Info("Reload OK!");
            }
        }