Exemple #1
0
        public void Awake(string path, int appId)
        {
            string[] ss = File.ReadAllText(path).Split('\n');
            foreach (string s in ss)
            {
                string s2 = s.Trim();
                if (s2 == "")
                {
                    continue;
                }
                try
                {
                    StartConfig startConfig = MongoHelper.FromJson <StartConfig>(s2);
                    this.allConfigs.Add(startConfig);
                    this.configDict.Add(startConfig.AppId, startConfig);

                    if (startConfig.AppType.Is(AppType.Realm))
                    {
                        this.RealmConfig = startConfig;
                    }

                    if (startConfig.AppType.Is(AppType.Location))
                    {
                        this.LocationConfig = startConfig;
                    }
                }
                catch (Exception)
                {
                    Log.Error($"config错误: {s2}");
                }
            }

            this.StartConfig = this.Get(appId);
        }
Exemple #2
0
        public void Awake(string[] args)
        {
            if (!Parser.Default.ParseArguments(args, this.Options))
            {
                throw new Exception($"命令行格式错误!");
            }

            string[] ss = File.ReadAllText(this.Options.Config).Split('\n');
            foreach (string s in ss)
            {
                string s2 = s.Trim();
                if (s2 == "")
                {
                    continue;
                }
                try
                {
                    StartConfig startConfig = MongoHelper.FromJson <StartConfig>(s2);
                    this.allConfigs.Add(startConfig);
                    this.configDict.Add(startConfig.AppId, startConfig);
                }
                catch (Exception)
                {
                    Log.Error($"config错误: {s2}");
                }
            }

            this.MyConfig = this.Get(this.Options.AppId);
        }
Exemple #3
0
        public void Awake()
        {
            StartConfig startConfig = Game.Scene.GetComponent <StartConfigComponent>().StartConfig;

            this.appType    = startConfig.AppType;
            this.HttpConfig = startConfig.GetComponent <HttpConfig>();

            this.Load();

            try
            {
                this.listener = new HttpListener();

                if (this.HttpConfig.Url == null)
                {
                    this.HttpConfig.Url = "";
                }
                foreach (string s in this.HttpConfig.Url.Split(';'))
                {
                    if (s.Trim() == "")
                    {
                        continue;
                    }
                    this.listener.Prefixes.Add(s);
                }

                this.listener.Start();

                this.Accept();
            }
            catch (HttpListenerException e)
            {
                throw new Exception($"http server error: {e.ErrorCode}", e);
            }
        }
        private void StartProcess(int appId)
        {
            OptionComponent      optionComponent      = Game.Scene.GetComponent <OptionComponent>();
            StartConfigComponent startConfigComponent = Game.Scene.GetComponent <StartConfigComponent>();
            string      configFile  = optionComponent.Options.Config;
            StartConfig startConfig = startConfigComponent.Get(appId);

#if __MonoCS__
            const string exe       = @"mono";
            string       arguments = $"--debug App.exe --appId={startConfig.AppId} --appType={startConfig.AppType} --config={configFile}";
#else
            const string exe       = @"App.exe";
            string       arguments = $"--appId={startConfig.AppId} --appType={startConfig.AppType} --config={configFile}";
#endif

            Log.Info($"{exe} {arguments}");
            try
            {
                ProcessStartInfo info = new ProcessStartInfo {
                    FileName = exe, Arguments = arguments, CreateNoWindow = true, UseShellExecute = true
                };

                Process process = Process.Start(info);
                this.processes.Add(startConfig.AppId, process);
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
            }
        }
Exemple #5
0
        public void Start()
        {
            StartConfig startConfig = this.GetComponent <StartConfigComponent>().StartConfig;

            this.AppType = startConfig.AppType;
            this.Load();
        }
Exemple #6
0
        public void Awake(string path, int appId)
        {
            this.configDict  = new Dictionary <int, StartConfig>();
            this.DdzConfigs  = new List <StartConfig>();
            this.GateConfigs = new List <StartConfig>();

            string[] ss = File.ReadAllText(path).Split('\n');
            foreach (string s in ss)
            {
                string s2 = s.Trim();
                if (s2 == "")
                {
                    continue;
                }
                try
                {
                    StartConfig startConfig = MongoHelper.FromJson <StartConfig>(s2);
                    this.configDict.Add(startConfig.AppId, startConfig);

                    if (startConfig.AppType.Is(AppType.Realm))
                    {
                        this.RealmConfig = startConfig;
                    }

                    if (startConfig.AppType.Is(AppType.Location))
                    {
                        this.LocationConfig = startConfig;
                    }

                    if (startConfig.AppType.Is(AppType.DB))
                    {
                        this.DBConfig = startConfig;
                    }

                    if (startConfig.AppType.Is(AppType.DDZ))
                    {
                        this.DdzConfigs.Add(startConfig);
                    }

                    if (startConfig.AppType.Is(AppType.Gate))
                    {
                        this.GateConfigs.Add(startConfig);
                    }

                    if (startConfig.AppType.Is(AppType.Match))
                    {
                        this.MatchConfig = startConfig;
                    }
                }
                catch (Exception e)
                {
                    Log.Error($"config错误: {s2} {e}");
                }
            }

            this.StartConfig = this.Get(appId);
        }
Exemple #7
0
        public void Awake()
        {
            StartConfigComponent startConfigComponent = Game.Scene.GetComponent <StartConfigComponent>();

            this.AppId = startConfigComponent.StartConfig.AppId;

            StartConfig startConfig = startConfigComponent.LocationConfig;

            this.LocationAddress = startConfig.GetComponent <InnerConfig>().IPEndPoint;
        }
 public StartConfig GetAddressByAccount(string account)
 {
     if (AccountGateIndex.ContainsKey(account))
     {
         return(this.GateAddress[AccountGateIndex[account]]);
     }
     else
     {
         int         n      = RandomHelper.RandomNumber(0, this.GateAddress.Count);
         StartConfig config = this.GateAddress[n];
         AccountGateIndex.Add(account, n);
         return(config);
     }
 }
        public StartConfig GetAddress(long roleId)
        {
            StartConfig ret = null;

            if (mLoginedAdrees.TryGetValue(roleId, out ret))
            {
                return(ret);
            }
            else
            {
                int n = RandomHelper.RandomNumber(0, this.GateAddress.Count);
                ret = this.GateAddress[n];
                mLoginedAdrees[roleId] = ret;
                return(ret);
            }
        }
		private void Awake(string path, int appId)
		{
			string[] ss = File.ReadAllText(path).Split('\n');
			foreach (string s in ss)
			{
				string s2 = s.Trim();
				if (s2 == "")
				{
					continue;
				}
				try
				{
					StartConfig startConfig = MongoHelper.FromJson<StartConfig>(s2);
					this.allConfigs.Add(startConfig);
					this.configDict.Add(startConfig.AppId, startConfig);
				}
				catch (Exception)
				{
					Log.Error($"config错误: {s2}");
				}
			}

			this.StartConfig = this.Get(appId);
		}
Exemple #11
0
        public void Awake()
        {
            StartConfig dbStartConfig = Game.Scene.GetComponent <StartConfigComponent>().DBConfig;

            dbAddress = dbStartConfig.GetComponent <InnerConfig>().IPEndPoint;
        }
		private void Awake()
		{
			string s = File.ReadAllText("../Config/StartConfig/ClientConfig.txt");
			this.Config = MongoHelper.FromJson<StartConfig>(s);
		}
		private void OnGUI()
		{
			GUILayout.BeginHorizontal();
			string[] filesArray = this.files.ToArray();
			this.selectedIndex = EditorGUILayout.Popup(this.selectedIndex, filesArray);

			string lastFile = this.fileName;
			this.fileName = this.files[this.selectedIndex];

			if (this.fileName != lastFile)
			{
				this.LoadConfig();
			}
			
			this.newFileName = EditorGUILayout.TextField("文件名", this.newFileName);

			if (GUILayout.Button("添加"))
			{
				this.fileName = this.newFileName;
				this.newFileName = "";
				File.WriteAllText(this.GetFilePath(), "");
				this.files = this.GetConfigFiles();
				this.selectedIndex = this.files.IndexOf(this.fileName);
				this.LoadConfig();
			}

			if (GUILayout.Button("复制"))
			{
				this.fileName = $"{this.fileName}-copy";
				this.Save();
				this.files = this.GetConfigFiles();
				this.selectedIndex = this.files.IndexOf(this.fileName);
				this.newFileName = "";
			}

			if (GUILayout.Button("重命名"))
			{
				if (this.newFileName == "")
				{
					Log.Debug("请输入新名字!");
				}
				else
				{
					File.Delete(this.GetFilePath());
					this.fileName = this.newFileName;
					this.Save();
					this.files = this.GetConfigFiles();
					this.selectedIndex = this.files.IndexOf(this.fileName);
					this.newFileName = "";
				}
			}

			if (GUILayout.Button("删除"))
			{
				File.Delete(this.GetFilePath());
				this.files = this.GetConfigFiles();
				this.selectedIndex = 0;
				this.newFileName = "";
			}

			GUILayout.EndHorizontal();

			GUILayout.Label("配置内容:");
			for (int i = 0; i < this.startConfigs.Count; ++i)
			{
				StartConfig startConfig = this.startConfigs[i];
				GUILayout.BeginHorizontal();
				GUILayout.Label($"AppId:");
				startConfig.AppId = EditorGUILayout.IntField(startConfig.AppId);
				GUILayout.Label($"服务器IP:");
				startConfig.ServerIP = EditorGUILayout.TextField(startConfig.ServerIP);
				GUILayout.Label($"AppType:");
				startConfig.AppType = (AppType)EditorGUILayout.EnumPopup(startConfig.AppType);

				InnerConfig innerConfig = startConfig.GetComponent<InnerConfig>();
				if (innerConfig != null)
				{
					GUILayout.Label($"InnerHost:");
					innerConfig.Host = EditorGUILayout.TextField(innerConfig.Host);
					GUILayout.Label($"InnerPort:");
					innerConfig.Port = EditorGUILayout.IntField(innerConfig.Port);
				}

				OuterConfig outerConfig = startConfig.GetComponent<OuterConfig>();
				if (outerConfig != null)
				{
					GUILayout.Label($"OuterHost:");
					outerConfig.Host = EditorGUILayout.TextField(outerConfig.Host);
					GUILayout.Label($"OuterPort:");
					outerConfig.Port = EditorGUILayout.IntField(outerConfig.Port);
				}

				ClientConfig clientConfig = startConfig.GetComponent<ClientConfig>();
				if (clientConfig != null)
				{
					GUILayout.Label($"Host:");
					clientConfig.Host = EditorGUILayout.TextField(clientConfig.Host);
					GUILayout.Label($"Port:");
					clientConfig.Port = EditorGUILayout.IntField(clientConfig.Port);
				}

				if (GUILayout.Button("删除"))
				{
					this.startConfigs.Remove(startConfig);
					break;
				}
				if (GUILayout.Button("复制"))
				{
					for (int j = 1; j < this.copyNum + 1; ++j)
					{
						StartConfig newStartConfig = (StartConfig)startConfig.Clone();
						newStartConfig.AppId += j;
						this.startConfigs.Add(newStartConfig);
					}
					break;
				}
				GUILayout.EndHorizontal();
			}

			GUILayout.Label("");

			GUILayout.BeginHorizontal();
			this.copyNum = EditorGUILayout.IntField("复制数量: ", this.copyNum);

			GUILayout.Label($"添加的AppType:");
			this.AppType = (AppType)EditorGUILayout.EnumPopup(this.AppType);

			if (GUILayout.Button("添加一行配置"))
			{
				StartConfig newStartConfig = new StartConfig();

				newStartConfig.AppType = this.AppType;
				
				if (this.AppType.Is(AppType.Gate | AppType.Realm | AppType.Manager))
				{
					newStartConfig.AddComponent<InnerConfig>();
					newStartConfig.AddComponent<OuterConfig>();
				}

				if (this.AppType.Is(AppType.Benchmark))
				{
					newStartConfig.AddComponent<ClientConfig>();
				}

				this.startConfigs.Add(newStartConfig);
			}
			GUILayout.EndHorizontal();


			GUILayout.BeginHorizontal();

			if (GUILayout.Button("保存"))
			{
				this.Save();
			}

			if (GUILayout.Button("启动"))
			{
				StartConfig startConfig = null;
				foreach (StartConfig config in this.startConfigs)
				{
					if (config.AppType.Is(AppType.Manager))
					{
						startConfig = config;
					}
				}

				if (startConfig == null)
				{
					Log.Error("没有配置Manager!");
					return;
				}

				string arguments = $"--appId={startConfig.AppId} --appType={startConfig.AppType} --config=../Config/StartConfig/{this.fileName}";

				ProcessStartInfo info = new ProcessStartInfo(@"App.exe", arguments)
				{
					UseShellExecute = true,
					WorkingDirectory = @"..\Bin\"
				};
				Process.Start(info);
			}
			GUILayout.EndHorizontal();
		}
        private void Awake()
        {
            string s = File.ReadAllText("../Config/StartConfig/ClientConfig.txt");

            this.Config = MongoHelper.FromJson <StartConfig>(s);
        }
Exemple #15
0
        public void Awake()
        {
            string s = File.ReadAllText("./StartConfig.txt");

            this.Config = MongoHelper.FromJson <StartConfig>(s);
        }