Ejemplo n.º 1
0
			public CreateLordConfigUnit(GameServer server)
			{
                Server = server;
                IsDone = false;
                IsSuccess = false;
			}
Ejemplo n.º 2
0
		/// <summary>
		/// 删除游戏服务器
		/// </summary>
		public void DeleteGameServer(GameServer server)
		{
			IBlazeDatabase db = DbFactory.GetDatabase();
			DeleteGameServer(server, db);
		}
Ejemplo n.º 3
0
		public void Confirm(GameServer server)
		{
			_success = true;
			server.OnConnected(_connectionId, _communicationKey, _port);

			Dispose();
		}
Ejemplo n.º 4
0
		void SendConfigPackage(GameServer server)
		{
			string fileContentString = null;
			using (MemoryStream configStream = new MemoryStream())
			{
				server.LordConfig.WriteGuardConfig(configStream);
                fileContentString = SystemConfig.Current.DefaultEncoding.GetString(configStream.ToArray()); //Encoding.ASCII.GetString(configStream.ToArray());
			}

			int x = s_random.Next(1000);
			int y = Util.CaculateY(x);

			string encryptFileContent = fileContentString;
			//string encryptFileContent = string.Empty;
			//util.DBEncrypt(fileContentString, ref encryptFileContent);

			string md5 = UtilDllWrap.MD5(y.ToString(), SystemConfig.Current.DefaultEncoding);

			e2g_ConfigInfo configInfo = new e2g_ConfigInfo();
			configInfo.X = x;
			configInfo.Y = md5;
			configInfo.ConfigFileDataLength = (ushort)encryptFileContent.Length;
			configInfo.ConfigFileData = encryptFileContent;
			//configProtocol.X = x;
			//configProtocol.Y = md5;
			//configProtocol.ConfigFileDataLength = (ushort)encryptFileContent.Length;
			//configProtocol.ConfigFileData = encryptFileContent;

			server.CommunicationKey = UtilDllWrap.CreateRandomKey(8);

            byte[] encryptedKey = server.CommunicationKey;//romandou UtilDllWrap.RSAEncrypt(server.CommunicationKey);
            byte[] encryptedConfigInfo = configInfo.ToBytes();//romandou UtilDllWrap.RC4Encrypt(configInfo.ToBytes(), server.CommunicationKey);

			e2g_config configProtocol = new e2g_config();
			Array.Copy(encryptedKey, configProtocol.Key.Data, encryptedKey.Length);
			Array.Copy(encryptedConfigInfo, configProtocol.ConfigInfo, encryptedConfigInfo.Length);

			IPEndPoint target = new IPEndPoint(IPAddress.Parse(server.IpAddress), SystemConfig.Current.ConfigGuardPort);
			if (AdminServer.TheInstance.ConnectionManager.SendTo(target, configProtocol.ToBytes()))
				server.AppendMessage(StringDef.AttemptToConfigGuard, GameServer.MessageInfo.Type.Normal);
		}
Ejemplo n.º 5
0
		/// <summary>
		/// 添加游戏服务器
		/// </summary>
		public void AddGameServer(GameServer server)
		{
			IBlazeDatabase db = DbFactory.GetDatabase();
			AddGameServer(server, db);
		}
Ejemplo n.º 6
0
		/// <summary>
		/// 创建服务器列表相关文件
		/// </summary>
		/// <param name="fileDir">生成文件的目录</param>
		/// <param name="encoding">编码</param>
		/// <remarks>包括列表文件和列表文件校验文件</remarks>
		public void CreateServerListFiles(GameServer[] servers, string fileDir, Encoding encoding)
		{
			if (fileDir == null)
				throw new ArgumentNullException("fileDir");

			Encoding usingEncoding = (encoding != null ? encoding : SystemConfig.Current.DefaultEncoding);

			string filePath = fileDir + SystemConfig.Current.ServerListFileName;
			using (FileStream fileStream = new FileStream(filePath, FileMode.Create))
			{
				CreateServerListFile(servers, fileStream, usingEncoding);
			}

			using (FileStream fileStream = new FileStream(filePath, FileMode.Open))
			{
				string crcFilePath = fileDir + SystemConfig.Current.ServerListCRCFileName;
				using (TextWriter crcWriter = new StreamWriter(crcFilePath, false, usingEncoding))
				{
					long crc32 = CryptographyManager.TheInstance.CRC32(fileStream);
					crcWriter.Write(crc32);
				}
			}
		}
Ejemplo n.º 7
0
		/// <summary>
		/// 创建服务器列表文件
		/// </summary>
		public void CreateServerListFile(GameServer[] servers, Stream outputStream, Encoding encoding)
		{
			if (outputStream == null)
				throw new ArgumentNullException("outputStream");

			IList<GameServer> displayServerList = new List<GameServer>(servers);

			try
			{
				using (TextWriter writer = new StreamWriter(outputStream, (encoding != null ? encoding : SystemConfig.Current.DefaultEncoding)))
				{
					writer.NewLine = SystemConfig.Current.DefaultNewLine;

					IList netGroupList = TopServerGroups;
										
					writer.WriteLine("[List]");
					writer.WriteLine("Version=1");
					writer.WriteLine("NetCount={0}", netGroupList.Count);
					writer.WriteLine();

					for (int netIndex = 0; netIndex < netGroupList.Count; netIndex++)
					{
						ServerGroup netGroup = netGroupList[netIndex] as ServerGroup;

						if (netGroup.GroupType == ServerGroup.Type.Group)
						{
							IList regionGroupList = netGroup.List;
							IList<ServerGroup> displayRegionList = new List<ServerGroup>();

							foreach (ServerGroup regionGroup in regionGroupList)
							{
								if (ExistDisplayServer(regionGroup, displayServerList))
								{
									displayRegionList.Add(regionGroup);
								}
							}

							writer.WriteLine("[Net_{0}]", netIndex);
							writer.WriteLine("NetName={0}", netGroup.Name);
							writer.WriteLine("RegionNum={0}", displayRegionList.Count);
							writer.WriteLine();

							for (int regionIndex = 0; regionIndex < displayRegionList.Count; regionIndex++)
							{
								ServerGroup regionGroup = displayRegionList[regionIndex] as ServerGroup;

								if (regionGroup.GroupType == ServerGroup.Type.Server)
								{
									IList serverList = regionGroup.List;
									IList<GameServer> displayerServerListInThisRegion = new List<GameServer>();

									foreach (GameServer server in serverList)
									{
										if (displayServerList.Contains(server))
										{
											displayerServerListInThisRegion.Add(server);
										}
									}

									writer.WriteLine("[Net_{0}_Region_{1}]", netIndex, regionIndex);
									writer.WriteLine("RegionName={0}", regionGroup.Name);
									writer.WriteLine("ServerNum={0}", displayerServerListInThisRegion.Count);
									writer.WriteLine();

									for (int serverIndex = 0; serverIndex < displayerServerListInThisRegion.Count; serverIndex++)
									{
										GameServer server = displayerServerListInThisRegion[serverIndex] as GameServer;

                                        writer.WriteLine("{0}_Server_Name={1}", serverIndex, server.Name);
										writer.WriteLine("{0}_Server_State={1}", serverIndex, "Good");
										writer.WriteLine("{0}_Server_IP={1}", serverIndex, server.IpAddress);
										writer.WriteLine();
									}
								}
								else
								{
									throw new Exception("Invalid GameServerGroup structure: RegionGroup must be consist of Servers.");
								}
							}
						}
						else
						{
							throw new Exception("Invalid GameServerGroup structure: NetGroup must be consist of RegionGroups.");
						}
					}
				}
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
Ejemplo n.º 8
0
        /// <summary>
        /// 添加多个服务器
        /// </summary>
        /// <param name="name">服务器名</param>
        /// <param name="comment">服务器描述</param>
        /// <param name="ipAddress">IP地址</param>
        /// <param name="gameDir">游戏目录</param>
        /// <param name="group">服务器组</param>
        public bool AddGameServers(
            IList<object[]> para
        )
        {
            IList<GameServer> gameServers = new List<GameServer>();
            IBlazeDatabase db = null;
            try
            {
                db = DbFactory.GetDatabase();
                db.BeginTrans();

                foreach (object[] strPara in para)
                {
                    string name = ((string)strPara[0]).ToString();
                    string comment = ((string)strPara[1]).ToString();
                    string ipAddress = ((string)strPara[2]).ToString();
                    string gameDir = ((string)strPara[3]).ToString();
                    ServerGroup group = (ServerGroup)strPara[4];
                    GameServer.ConfigGuardState configState = (GameServer.ConfigGuardState)strPara[5];
                    string cfgContent = ((string)strPara[6]).ToString();
                    GameServer.ServerType serverType = (GameServer.ServerType)strPara[7];

                    SecurityManager sm = AdminServer.TheInstance.SecurityManager;

                    //构造相关安全对象
                    string newGameServerObjPath = group.SecurityObject.FullPath + SecurityManager.ObjectPathDelimiter + name;
                    FSEyeObject newGameServerObj = sm.Get(newGameServerObjPath, db);
                    newGameServerObj.Comment = comment;
                    sm.Set(newGameServerObj);
                    sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.Console, db);
                    sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo, db);
                    sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.PlugIn, db);
                    sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.Process, db);
                    sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.NetCard, db);
                    sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.BasicInfo, db);
                    sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.Cpu, db);
                    sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.Disk, db);
                    sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.FMTask, db);
                    sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.Memory, db);

                    //插入数据到服务器表
                    string[] fields = new string[] { 
					TableString.GameServerFieldId,
					TableString.GameServerFieldNetAddress,
					TableString.GameServerFieldGameDir,
					TableString.GameServerFieldHasBeenConfigGuard,
					TableString.GameServerFieldServerType,
                    TableString.GameServerFieldCfgString
				};

                    object[] values = new object[] {
					newGameServerObj.Id,
					ipAddress,
					gameDir,
					(int)configState,
					(int)serverType,
                    cfgContent
				};
                    IBlazeTable serverTable = db.GetTable(TableString.GameServerTableName);
                    serverTable.Add(fields, values);

                    GameServer server = new GameServer();
                    server.SecurityObject = newGameServerObj;
                    server.IpAddress = ipAddress;
                    server.GameDir = gameDir;
                    server.ConfigState = configState;
                    server.Type = serverType;
                    server.ConfigContent = cfgContent;                    
                    group.AddGameServer(server, db);

                    //如果group的Type是Group必须将其变为Server型的
                    if (group.GroupType == ServerGroup.Type.Group)
                    {
                        group.GroupType = ServerGroup.Type.Server;
                        IBlazeTable serverGroupTable = db.GetTable(TableString.ServerGroupTableName);
                        serverGroupTable.Set(TableString.ServerGroupFieldType, (int)group.GroupType, FilterFactory.CreateEqualFilter(TableString.ServerGroupFieldId, group.Id));
                    }

                    //加入默认权限,即其直接父亲的权限
                    AdminServer.TheInstance.SecurityManager.CopyAce(newGameServerObj.Parent, newGameServerObj, true);
                    
                    gameServers.Add(server);                                       
                }
                db.CommitTrans();
                foreach(GameServer server in gameServers)
                {
                _gameServerList.Add(server); 
                server.Initialize();
                _systemTickTimer.Elapsed += new System.Timers.ElapsedEventHandler(server.OnTick);
                }
                

                return true;
            }
            catch (Exception)
            {
                if (db != null)
                    db.RollbackTrans();
            }
            finally
            {
                if (db != null)
                    db.Close();
            }
            return false;
        }
Ejemplo n.º 9
0
		/// <summary>
		/// 修改游戏服务器
		/// </summary>
		/// <param name="server">服务器</param>
		/// <param name="name">服务器名</param>
		/// <param name="comment">服务器描述</param>
		/// <param name="ipAddress">IP地址</param>
		/// <param name="macAddress">MAC地址</param>
		/// <param name="gameDir">游戏目录</param>
		/// <param name="newGroup">服务器组</param>
		/// <param name="lordConfig">Lord配置</param>
		public bool ModifyGameServer(
			GameServer server,
			string name,
			string comment,
			string ipAddress,
			string gameDir,
			ServerGroup newGroup,
			LordConfig lordConfig,
            GameServer.ConfigGuardState configState,
            string cfgContent,
			//bool hasBeenConfigGuard,
			GameServer.ServerType serverType,
            int ftpServer
		)
		{
			if (server == null)
				throw new ArgumentNullException("server");
			if (name == null)
				throw new ArgumentNullException("name");
			if (comment == null)
				throw new ArgumentNullException("comment");
			if (ipAddress == null)
				throw new ArgumentNullException("ipAddress");
			if (gameDir == null)
				throw new ArgumentNullException("gameDir");
			if (newGroup == null)
				throw new ArgumentNullException("newGroup");
            if (cfgContent == null)
                throw new ArgumentNullException("cfgContent");
			IBlazeDatabase db = null;
			try
			{
				SecurityManager sm = AdminServer.TheInstance.SecurityManager;

				db = DbFactory.GetDatabase();
				db.BeginTrans();

				FSEyeObject serverObject = server.SecurityObject;
				serverObject.Name = name;
				serverObject.Comment = comment;
				sm.Set(serverObject, db);
                //游戏服务器配置值
				string[] gameServerFields = null;
				object[] gameServerValues = null;

				if (lordConfig == null)
				{
					gameServerFields = new string[] { 
						TableString.GameServerFieldNetAddress,
						TableString.GameServerFieldGameDir,
						TableString.GameServerFieldHasBeenConfigGuard,
						TableString.GameServerFieldServerType,
                        TableString.GameServerFieldCfgString,
                        TableString.GameServerFieldFtpDownloadServer
					};

					gameServerValues = new object[] {
						ipAddress,
						gameDir,
						(int)configState,
						(int)serverType,
                        cfgContent,
                        ftpServer
					};
				}
				else
				{
                    ArrayList gameServerFieldList = new ArrayList();
                    ArrayList gameServerValueList = new ArrayList();

                    //TODO: HUANGBIAO 2008-1-20 下面代码可能没用
                    //gameServerFieldList.Add(TableString.GameServerFieldNetAddress);
                    //gameServerFieldList.Add(TableString.GameServerFieldGameDir);
                    //gameServerFieldList.Add(TableString.GameServerFieldLordPort);
                    //gameServerFieldList.Add(TableString.GameServerFieldMaxPlayer);
                    //gameServerFieldList.Add(TableString.GameServerFieldIntranetMask);
                    //gameServerFieldList.Add(TableString.GameServerFieldInternetMask);

                    //gameServerValueList.Add(ipAddress);
                    //gameServerValueList.Add(gameDir);
                    //gameServerValueList.Add(lordConfig.ServerCount);
                    //gameServerValueList.Add(lordConfig.MaxPlayer);
                    //gameServerValueList.Add(lordConfig.IntranetMask);
                    //gameServerValueList.Add(lordConfig.InternetMask);

                    //Payasys是否配置
                    if (lordConfig.PaysysIp != null && lordConfig.PaysysIp.Length != 0)
                    {
                        gameServerFieldList.Add(TableString.GameServerFieldPaysysIp);
                        gameServerFieldList.Add(TableString.GameServerFieldPaysysPort);
                        gameServerFieldList.Add(TableString.GameServerFieldPaysysLoginName);
                        gameServerFieldList.Add(TableString.GameServerFieldPaysysLoginPwd);

                        gameServerValueList.Add(lordConfig.PaysysIp);
                        gameServerValueList.Add(lordConfig.PaysysPort);
                        gameServerValueList.Add(lordConfig.PaysysLoginName);
                        gameServerValueList.Add(lordConfig.PaysysLoginPwd);
                    }

                    if (cfgContent.Length != 0)
                    {
                        gameServerFieldList.Add(TableString.GameServerFieldCfgString);
                        gameServerValueList.Add(cfgContent);
                    }

                    //Db是否配置
                    if (lordConfig.DbHost != null && lordConfig.DbHost.Length != 0)
                    {
                        gameServerFieldList.Add(TableString.GameServerFieldDbHost);
                        gameServerFieldList.Add(TableString.GameServerFieldDbName);
                        gameServerFieldList.Add(TableString.GameServerFieldDbLoginName);
                        gameServerFieldList.Add(TableString.GameServerFieldDbLoginPwd);
                        gameServerFieldList.Add(TableString.GameServerFieldDbBackupDir);

                        gameServerValueList.Add(lordConfig.DbHost);
                        gameServerValueList.Add(lordConfig.DbName);
                        gameServerValueList.Add(lordConfig.DbLoginName);
                        gameServerValueList.Add(lordConfig.DbLoginPwd);
                        gameServerValueList.Add(lordConfig.DbBackupPath);
                    }

                    //是否配置GMCIp和GMCAccount这两个字段
                    if (lordConfig.GMCIp != null && lordConfig.GMCIp.Length != 0)
                    {
                        gameServerFieldList.Add(TableString.GameServerFieldGmcIp);
                        gameServerValueList.Add(lordConfig.GMCIp);
                    }
                    if (lordConfig.GMCAccount != null && lordConfig.GMCAccount.Length != 0)
                    {
                        gameServerFieldList.Add(TableString.GameServerFieldGmcAccount);
                        gameServerValueList.Add(lordConfig.GMCAccount);
                    }

                    gameServerFieldList.Add(TableString.GameServerFieldFSEyeIp);
                    gameServerFieldList.Add(TableString.GameServerFieldFSEyePort);
                    gameServerFieldList.Add(TableString.GameServerFieldHasBeenConfigGuard);
                    gameServerFieldList.Add(TableString.GameServerFieldServerType);

                    gameServerValueList.Add(lordConfig.FSEyeIp);
                    gameServerValueList.Add(lordConfig.FSEyePort);
                    gameServerValueList.Add((int)configState);
                    gameServerValueList.Add((int)serverType);

                    gameServerFields = (string[])gameServerFieldList.ToArray(typeof(string));
                    gameServerValues = (object[])gameServerValueList.ToArray();
				}

				IBlazeTable gameServerTable = db.GetTable(TableString.GameServerTableName);
				gameServerTable.Set(gameServerFields, gameServerValues, FilterFactory.CreateEqualFilter(TableString.GameServerFieldId, server.Id));

				server.SecurityObject.Name = name;
				server.SecurityObject.Comment = comment;

				server.IpAddress = ipAddress;
				server.GameDir = gameDir;
				server.ConfigState = configState;
				server.Type = serverType;
                server.ConfigContent = cfgContent;
                server.FtpServer = ftpServer;

				if (lordConfig != null)
				{
					server.LordConfig.Copy(lordConfig);					
				}

				ServerGroup oldGroup = server.Group;
				if (oldGroup != null && newGroup != null)
				{					
					oldGroup.List.Remove(server);
					oldGroup.SecurityObject.RemoveChild(server.SecurityObject.Name);
					sm.Set(oldGroup.SecurityObject, db);

					newGroup.List.Add(server);
					newGroup.SecurityObject.AddChild(server.SecurityObject);
					sm.Set(newGroup.SecurityObject, db);

					server.Group = newGroup;
				}

				sm.Set(serverObject, db);

				db.CommitTrans();

				return true;
			}
			catch (Exception)
			{
				if (db != null)
					db.RollbackTrans();
			}
			finally
			{
				if (db != null)
					db.Close();
			}
			
			return false;
		}
Ejemplo n.º 10
0
		/// <summary>
		/// 删除游戏服务器
		/// </summary>
		/// <param name="id">服务器编号</param>
		public bool DeleteGameServer(GameServer server)
		{
			if (server == null)
				throw new ArgumentNullException("server");

			IBlazeDatabase db = null;
			try
			{
				db = DbFactory.GetDatabase();
				db.BeginTrans();

				ServerGroup group = server.Group;
				if (group != null)
				{
                    group.DeleteGameServer(server, db);
                    //如果该server所在的group没有server了就把组设为Group型的
                    if (group.SecurityObject.Children.Length == 0)
                    {
                        group.GroupType = ServerGroup.Type.Group;
                        db.GetTable(TableString.ServerGroupTableName).Set(TableString.ServerGroupFieldType, (int)group.GroupType, FilterFactory.CreateEqualFilter(TableString.ServerGroupFieldId, group.Id));
                    }					
				}                

				IBlazeTable serverTable = db.GetTable(TableString.GameServerTableName);
				serverTable.Delete(FilterFactory.CreateEqualFilter(TableString.GameServerFieldId, server.Id));
				
                //继续删除GaveServer的插件
                serverTable = db.GetTable(TableString.ServerPlugInTableName);
                serverTable.Delete(FilterFactory.CreateEqualFilter(TableString.ServerPlugInFieldGameServerId, server.Id));

				SecurityManager sm = AdminServer.TheInstance.SecurityManager;
				sm.Delete(server.Id, db);

				db.CommitTrans();

				_gameServerList.Remove(server);
				_systemTickTimer.Elapsed -= new System.Timers.ElapsedEventHandler(server.OnTick);
				server.Dispose();

				return true;
			}
			catch (Exception ex)
			{
				if (db != null)
					db.RollbackTrans();
				throw ex;
			}
			finally
			{
				if (db != null)
					db.Close();
			}
		}
Ejemplo n.º 11
0
		/// <summary>
		/// 添加游戏服务器
		/// </summary>
		/// <param name="name">服务器名</param>
		/// <param name="comment">服务器描述</param>
		/// <param name="ipAddress">IP地址</param>
		/// <param name="macAddress">MAC地址</param>
		/// <param name="gameDir">游戏目录</param>
		/// <param name="group">服务器组</param>
		public bool AddGameServer(
			string name,
			string comment,
			string ipAddress,
			string gameDir,
			ServerGroup group,
			GameServer.ConfigGuardState configState,
			//bool hasBeenConfigGuard,
            string cfgContent,
			GameServer.ServerType serverType,
            int ftpServer
		)
		{
			if (name == null)
				throw new ArgumentNullException("name");
			if (comment == null)
				throw new ArgumentNullException("comment");
			if (ipAddress == null)
				throw new ArgumentNullException("ipAddress");
			if (gameDir == null)
				throw new ArgumentNullException("gameDir");
			if (group == null)
				throw new ArgumentNullException("group");
            if (cfgContent == null)
                throw new ArgumentNullException("cfgContent");
			IBlazeDatabase db = null;
			try
			{
				db = DbFactory.GetDatabase();
				db.BeginTrans();

				SecurityManager sm = AdminServer.TheInstance.SecurityManager;

				//构造相关安全对象
				string newGameServerObjPath = group.SecurityObject.FullPath + SecurityManager.ObjectPathDelimiter + name;
				FSEyeObject newGameServerObj = sm.Get(newGameServerObjPath, db);
				newGameServerObj.Comment = comment;
				sm.Set(newGameServerObj);
                
                //2008-07-16 为了改善性能和简化权限配置,不再生成这些object了
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.Console, db);
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo, db);				
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.PlugIn, db);
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.Process, db);
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.NetCard, db);
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.BasicInfo, db);
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.Cpu, db);
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.Disk, db);
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.FMTask, db);
                //sm.Get(newGameServerObjPath + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.ServerInfo + SecurityManager.ObjectPathDelimiter + PredefinedSecurityObjects.Memory, db);
				
				//插入数据到服务器表
				string[] fields = new string[] { 
					TableString.GameServerFieldId,
					TableString.GameServerFieldNetAddress,
					TableString.GameServerFieldGameDir,
					TableString.GameServerFieldHasBeenConfigGuard,
					TableString.GameServerFieldServerType,
                    TableString.GameServerFieldCfgString,
                    TableString.GameServerFieldFtpDownloadServer
				};
                
				object[] values = new object[] {
					newGameServerObj.Id,
					ipAddress,
					gameDir,
					(int)configState,
					(int)serverType,
                    cfgContent,
                    ftpServer
				};
				IBlazeTable serverTable = db.GetTable(TableString.GameServerTableName);
				serverTable.Add(fields, values);

				GameServer server = new GameServer();
				server.SecurityObject = newGameServerObj;
				server.IpAddress = ipAddress;
				server.GameDir = gameDir;
				server.ConfigState = configState;
				server.Type = serverType;
                server.ConfigContent = cfgContent;
                server.FtpServer = ftpServer;
                server.GameServiceState = GameServer.ServiceState.OKStopped;
				group.AddGameServer(server, db);

                //如果group的Type是Group必须将其变为Server型的
                if (group.GroupType == ServerGroup.Type.Group)
                {
                    group.GroupType = ServerGroup.Type.Server;
                    IBlazeTable serverGroupTable = db.GetTable(TableString.ServerGroupTableName);
                    serverGroupTable.Set(TableString.ServerGroupFieldType, (int)group.GroupType, FilterFactory.CreateEqualFilter(TableString.ServerGroupFieldId, group.Id));
                }

                /*2008-07-16 GameServer的权限不再单独控制,而是统一由GameServerManager控制,所以就不再复制父一级的权限过来了。
                 * 
                 * 
                //加入默认权限,即其直接父亲的权限
                AdminServer.TheInstance.SecurityManager.CopyAce(newGameServerObj.Parent, newGameServerObj, true);
                 */

				db.CommitTrans();

				_gameServerList.Add(server);
				server.Initialize();
				_systemTickTimer.Elapsed += new System.Timers.ElapsedEventHandler(server.OnTick);

				return true;
			}
			catch (Exception)
			{
				if (db != null)
					db.RollbackTrans();
			}
			finally
			{
				if (db != null)
					db.Close();
			}

			return false;
		}
Ejemplo n.º 12
0
		protected override void OnCommandComplete(GameServer server, bool success, string output)
		{
			if (success && (output == null || output.Length == 0))
			{
				server.GameServiceState = GameServer.ServiceState.Stopping;
			}
			else
			{
				server.AppendMessage(StringDef.StopGameFailed + ":" + output, GameServer.MessageInfo.Type.Failure);
			}
		}
Ejemplo n.º 13
0
		protected override bool CreateScript(GameServer server, out string script, out string input)
		{
			if (server.GameServiceState == GameServer.ServiceState.Running)
			{
				script = (string)server.GetPlugInData(0, GameServerControl.PlugInGuid, GameServerControl.DataKeyStopGameScript);
				input = null;

				return (script != null);
			}
			else
			{
				script = null;
				input = null;

				return false;
			}
		}
Ejemplo n.º 14
0
		protected override bool CreateScript(GameServer server, out string script, out string input)
		{
			script = (string)server.GetPlugInData(0, GameServerControl.PlugInGuid, GameServerControl.DataKeyRollbackDbScript, _backupFileName);
			input = null;

			return (script != null);
		}
Ejemplo n.º 15
0
		public void GameStateChanged(GameServer server, GameServer.ServiceState originalState, GameServer.ServiceState newState)
		{
            GameServer.ServerEventType eventType = GameServer.ServerEventType.UnknownEvent;

            switch (originalState)
                {
                    case GameServer.ServiceState.Starting:
                        {
                            if (newState == GameServer.ServiceState.Running)
                            {
                                //游戏正常启动
                                server.AppendMessage("Start", GameServer.MessageInfo.Type.Success);

                                AutomationContext context = new AutomationContext();
                                context.Message = string.Format("{0} Start", server.ToString()); ;
                                context.Server = server;
                                AdminServer.TheInstance.StrategyManager.OnEvent(FSEyeEvent.GameStart, context);

                                eventType = GameServer.ServerEventType.GameStart;
                            }
                            else if (newState == GameServer.ServiceState.ErrorStopped)
                            {
                                //游戏启动失败
                                server.AppendMessage("StartFail", GameServer.MessageInfo.Type.Failure);

                                AutomationContext context = new AutomationContext();
                                context.Message = string.Format("{0} StartFail", server.ToString()); ;
                                context.Server = server;
                                AdminServer.TheInstance.StrategyManager.OnEvent(FSEyeEvent.StartGameFail, context);

                                eventType = GameServer.ServerEventType.GameStartFail;
                            }
                        } break;
                    case GameServer.ServiceState.Stopping:
                        {
                            if (newState == GameServer.ServiceState.OKStopped || newState == GameServer.ServiceState.ErrorStopped)
                            {
                                //停止,指web主动关闭服务器程序
                                //游戏正常关闭
                                server.AppendMessage("Stop", GameServer.MessageInfo.Type.Alert);

                                AutomationContext context = new AutomationContext();
                                context.Message = string.Format("{0} Stop", server.ToString()); ;
                                context.Server = server;
                                AdminServer.TheInstance.StrategyManager.OnEvent(FSEyeEvent.GameStop, context);

                                eventType = GameServer.ServerEventType.GameStop;
                            }
                        } break;
                    case GameServer.ServiceState.ErrorStopped:
                    case GameServer.ServiceState.OKStopped :
                        {
                            if (newState == GameServer.ServiceState.Running)
                            {
                                //游戏意外启动
                                server.AppendMessage("StartByAccident", GameServer.MessageInfo.Type.Failure);

                                AutomationContext context = new AutomationContext();
                                context.Message = string.Format("{0} StartByAccident", server.ToString()); ;
                                context.Server = server;
                                AdminServer.TheInstance.StrategyManager.OnEvent(FSEyeEvent.GameStartByAccident, context);

                                eventType = GameServer.ServerEventType.GameStartByAccident;
                            }
                        } break;
                    case GameServer.ServiceState.Running:
                        {
                            if (newState == GameServer.ServiceState.ErrorStopped)
                            {
                                //游戏崩溃
                                server.AppendMessage("StopByAccident", GameServer.MessageInfo.Type.Failure);

                                AutomationContext context = new AutomationContext();
                                context.Message = string.Format("{0} StopByAccident", server.ToString()); ;
                                context.Server = server;
                                AdminServer.TheInstance.StrategyManager.OnEvent(FSEyeEvent.GameStopByAccident, context);

                                eventType = GameServer.ServerEventType.GameStopByAccident;
                            }
                        } break;
                }

                if (eventType != GameServer.ServerEventType.UnknownEvent)
                {
                    DateTime eventTime = DateTime.Now;

                    using (IBlazeDatabase db = DbFactory.GetDatabase())
                    {
                        IBlazeTable table = db.GetTable(TableString.ServerEventTableName);

                        string[] fieldNames = {
					TableString.ServerEventFieldServerId,
					TableString.ServerEventFieldEventTime,
					TableString.ServerEventFieldEventType
				    };

                        object[] fieldValues = {
					server.Id,
					eventTime,
					(Int16)eventType
				    };

                        table.Add(fieldNames, fieldValues);
                    }
                }
            
		}
Ejemplo n.º 16
0
 public void ReBuildLordConfig(GameServer server)
 {
     server.LordConfig.ServerIDs = server.SameGuardServerIDs;
     server.LordConfig.ServerCount = server.SameGuardServerCount;
     server.LordConfig.BindIp = server.IpAddress;
 }
Ejemplo n.º 17
0
		/// <summary>
		/// 创建服务器列表相关文件
		/// </summary>
		public void CreateServerListFiles(GameServer[] servers)
		{
			CreateServerListFiles(servers, SystemConfig.Current.AdminServerUploadFileRootPath, SystemConfig.Current.DefaultEncoding);
		}
Ejemplo n.º 18
0
		/// <summary>
		/// 移动到服务器组
		/// </summary>
		/// <param name="group"></param>
		public void MoveToServerGroup(GameServer server, ServerGroup newGroup)
		{
			if (server == null)
				throw new ArgumentNullException("server");
			if (newGroup == null)
				throw new ArgumentNullException("newGroup");
			if (newGroup.GroupType == ServerGroup.Type.Group && newGroup.List.Count > 0)
				throw new Exception(string.Format("ServerGroup {0} contains server groups.", newGroup.Name));

			ServerGroup oldGroup = server.Group;
			if (oldGroup != null)
			{
				using (IBlazeDatabase db = DbFactory.GetDatabase())
				{
					try
					{
						db.BeginTrans();
						SecurityManager sm = AdminServer.TheInstance.SecurityManager;						

						oldGroup.List.Remove(server);
						oldGroup.SecurityObject.RemoveChild(server.SecurityObject.Name);
						sm.Set(oldGroup.SecurityObject, db);

                        //如果该server所在的group没有server了就把组设为Group型的
                        if (oldGroup.SecurityObject.Children.Length == 0)
                        {
                            oldGroup.GroupType = ServerGroup.Type.Group;                            
                            db.GetTable(TableString.ServerGroupTableName).Set(TableString.ServerGroupFieldType, (int)oldGroup.GroupType, FilterFactory.CreateEqualFilter(TableString.ServerGroupFieldId, oldGroup.Id));
                        }

						if (newGroup.GroupType == ServerGroup.Type.Group)
						{
							newGroup.GroupType = ServerGroup.Type.Server;
						}

						IBlazeTable serverGroupTable = db.GetTable(TableString.ServerGroupTableName);
						serverGroupTable.Set(TableString.ServerGroupFieldType, (int)newGroup.GroupType, FilterFactory.CreateEqualFilter(TableString.ServerGroupFieldId, newGroup.Id));

                        newGroup.List.Add(server);
						newGroup.SecurityObject.AddChild(server.SecurityObject);
						sm.Set(newGroup.SecurityObject, db);

						server.Group = newGroup;

						sm.Set(server.SecurityObject, db);
						db.CommitTrans();
					}
					catch (Exception ex)
					{
						if (db != null)
							db.RollbackTrans();

                        throw ex;
					}
				}
			}
		}
Ejemplo n.º 19
0
		/// <summary>
		/// 创建服务器列表文件
		/// </summary>
		public void CreateServerListFile(GameServer[] servers, Stream outputStream)
		{
			CreateServerListFile(servers, outputStream, null);
		}
Ejemplo n.º 20
0
		/// <summary>
		/// 实现了IMessageHandler接口
		/// </summary>
		public void ProcessMessage(GameServer server, IProtocol message)
		{
			if (server != null)
			{
				server.OnMessageReceived(message);
			}
		}
Ejemplo n.º 21
0
 /// <summary>
 /// 得到服务器状态描述
 /// </summary>
 /// <param name="server">服务器</param>
 public string GetServerStateDesc(GameServer.ReadableState serverState)
 {
     string stateDesc = string.Empty;
     switch (serverState)
     {
         case GameServer.ReadableState.Good:
             stateDesc = StringDef.StateGood;
             break;
         case GameServer.ReadableState.Busy:
             stateDesc = StringDef.StateBusy;
             break;
         case GameServer.ReadableState.Full:
             stateDesc = StringDef.StateFull;
             break;
         case GameServer.ReadableState.Stop:
             stateDesc = StringDef.StateStoped;
             break;
     }
     return stateDesc;
 }
Ejemplo n.º 22
0
 /// <summary>
 /// GameServer的插件的修改操作
 /// </summary>
 /// <param name="plugIns"></param>
 public bool EditPlugIn(GameServer server, IList plugIns)
 {
     IBlazeDatabase db = null;
     //插入数据到服务器表
     string[] fields = new string[] {
             TableString.ServerPlugInFieldGameServerId,
             TableString.ServerPlugInFieldPlugInGuid,
             TableString.ServerPlugInFieldParameter1,
             TableString.ServerPlugInFieldParameter2,
             TableString.ServerPlugInFieldParameter3,
             TableString.ServerPlugInFieldPlugInName
         };
     try
     {
         db = DbFactory.GetDatabase();
         db.BeginTrans();
         foreach (IPlugIn plugIn in plugIns)
         {                    
             IBlazeTable plugInTable = db.GetTable(TableString.ServerPlugInTableName);
             plugInTable.Set(fields, ServerPlugInFactory.GetData(server.Id, plugIn),
                 FilterFactory.CreateAndFilter(
                 FilterFactory.CreateEqualFilter(TableString.ServerPlugInFieldGameServerId, server.Id),
                 FilterFactory.CreateEqualFilter(TableString.ServerPlugInFieldPlugInGuid, plugIn.Guid)));
             //server.UnInstallPlugIn(plugIn);
             //server.InstallPlugIn(plugIn);
         }
         db.CommitTrans();
         return true;
     }
     catch (Exception)
     {
         if (db != null)
             db.RollbackTrans();
         return false;
     }
     finally
     {
         if (db != null)
             db.Close();
     }
 }
Ejemplo n.º 23
0
        public void SendServerConfigFile(GameServer svr)
        {
            //serve配置状态
            //if (server.ConfigState == GameServer.ConfigGuardState.Configuring)
            foreach(GameServer server in _gameServerList)
            {
                if (server.IpAddress != svr.IpAddress)
                    continue;

                string[] para = new string[3];
                para[0] = server.Id.ToString();
                para[1] = server.ConfigContent;
                para[2] = server.GameDir;

                if (server.Type == GameServer.ServerType.bishop) para[2] += JX2Lib.JXConfigFileName.Gateway;
                if (server.Type == GameServer.ServerType.gamecenter) para[2] += JX2Lib.JXConfigFileName.GameCenter;
                if (server.Type == GameServer.ServerType.gameserver) para[2] += JX2Lib.JXConfigFileName.GameServer;
                if (server.Type == GameServer.ServerType.goddess) para[2] += JX2Lib.JXConfigFileName.RoleServer;
                if (server.Type == GameServer.ServerType.unidentified) para[2] += JX2Lib.JXConfigFileName.Unidentified;
                if (server.Type == GameServer.ServerType.logserver) para[2] += JX2Lib.JXConfigFileName.LogServer;

                //传该服务器的cgf文件
                if (server.DoPlugInAction(0, E2gSendfile.PlugInGuid, E2gSendfile.actionKey, para))
                {
                    server.AppendMessage("Transfer Server Config File:" + para[2], GameServer.MessageInfo.Type.Normal);
                    //para[1] = "[Server]" + SystemConfig.Current.DefaultNewLine + "Server=" + server.Id.ToString() + SystemConfig.Current.DefaultNewLine;
                    //para[2] = server.GameDir + "shm.ini";
                    //server.AppendMessage("Transfer Server ShareMemery File:" + para[2], GameServer.MessageInfo.Type.Normal);
                    //传该服务器的shm.ini
                    //if (server.DoPlugInAction(0, E2gSendfile.PlugInGuid, E2gSendfile.actionKey, para))
                    //{
                    //    server.ConfigState = GameServer.ConfigGuardState.Configured;
                    //    server.AppendMessage(StringDef.StopConfigGuard, GameServer.MessageInfo.Type.Normal);
                    //}
                }
            }

        }
Ejemplo n.º 24
0
 /// <summary>
 /// GameServer的插件的删除操作
 /// </summary>
 /// <param name="plugIns"></param>
 public bool DeletePlugIn(GameServer server,IList plugIns)
 {
     IBlazeDatabase db = null;
     try
     {                
         db = DbFactory.GetDatabase();
         db.BeginTrans();
         foreach (IPlugIn plugIn in plugIns)
         {
             
             IBlazeTable plugInTable = db.GetTable(TableString.ServerPlugInTableName);
             plugInTable.Delete(FilterFactory.CreateAndFilter(
                 FilterFactory.CreateEqualFilter(TableString.ServerPlugInFieldGameServerId,server.Id),
                 FilterFactory.CreateEqualFilter(TableString.ServerPlugInFieldPlugInGuid,plugIn.Guid)));                                        
             server.UnInstallPlugIn(plugIn);
         }
         db.CommitTrans();
         return true;
     }
     catch (Exception)
     {
         if (db != null)
             db.RollbackTrans();
         return false;
     }
     finally
     {
         if (db != null)
             db.Close();
     }
 }
Ejemplo n.º 25
0
		/// <summary>
		/// 添加游戏服务器
		/// </summary>
		public void AddGameServer(GameServer server, IBlazeDatabase db)
		{
			if (server == null)
				throw new ArgumentNullException("server");
			if (db == null)
				throw new ArgumentNullException("db");
			if (_type != Type.Server && _list.Count > 0)
				throw new Exception("GameServerGroup width Type=" + _type + " does not support this operation.");

			try
			{
				db.BeginTrans();

				this.SecurityObject.AddChild(server.SecurityObject);
				AdminServer.TheInstance.SecurityManager.Set(this.SecurityObject, db);
				AdminServer.TheInstance.SecurityManager.Set(server.SecurityObject, db);

				db.CommitTrans();

				if (_type != Type.Server)
				{
					_type = Type.Group;
				}
				IBlazeTable serverGroupTable = db.GetTable(TableString.ServerGroupTableName);
				serverGroupTable.Set(TableString.ServerGroupFieldType, (int)_type, FilterFactory.CreateEqualFilter(TableString.ServerGroupFieldId, this.Id));

				_list.Add(server);
				server.Group = this;
			}
			catch (Exception ex)
			{
				db.RollbackTrans();
				throw ex;
			}
		}
Ejemplo n.º 26
0
        /// <summary>
        /// 对服务器或是服务器组的操作写日志,返回此次操作的流水号(内部自动生成的)
        /// targetId = -2表示对多个组开始进行操作,多个组名存在description字段中
        /// </summary>
        public Int64 WriteServerOperationLog(int userId, ServerGroup.Type targetType, int targetId, GameServer.ServerOperationType operationType, bool operationSuccessful, string description,string region)
        {
            System.Random random = new Random(new RNGCryptoServiceProvider().GetHashCode());
            Int64 OperationID = Int64.Parse(DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Millisecond.ToString() + random.Next(1, 100));
            random = null;

            using (IBlazeDatabase db = DbFactory.GetDatabase())
            {
                IBlazeTable table = db.GetTable(TableString.ServerOperationLogTableName);

                string[] fieldNames = {
					        TableString.ServerOperationLogFieldOperationId,
					        TableString.ServerOperationLogFieldUserId,
					        TableString.ServerOperationLogFieldServerOrGroup,
                            TableString.ServerOperationLogFieldTargetId,
                            TableString.ServerOperationLogFieldOperationType,
                            TableString.ServerOperationLogFieldOperationResult,
                            TableString.ServerOperationLogFieldDescription,
                            TableString.ServerOperationLogFieldLogTime,
                            TableString.ServerOperationLogFieldFatherRegion
				    };

                object[] fieldValues = {
				        OperationID,
				        userId,
				        (Int16)targetType,
                        targetId,
                        (Int16)operationType,
                        Convert.ToInt16(operationSuccessful),
                        description,
                        DateTime.Now,
                        region
			        };

                //添加此次的操作日志
                table.Add(fieldNames, fieldValues);                

                return OperationID;
            }
        }
Ejemplo n.º 27
0
		/// <summary>
		/// 删除游戏服务器
		/// </summary>
		public void DeleteGameServer(GameServer server, IBlazeDatabase db)
		{
			if (server == null)
				throw new ArgumentNullException("server");
			if (db == null)
				throw new ArgumentNullException("db");

			try
			{
				db.BeginTrans();

				this.SecurityObject.RemoveChild(server.SecurityObject.Name);
				AdminServer.TheInstance.SecurityManager.Set(this.SecurityObject, db);
				AdminServer.TheInstance.SecurityManager.Set(server.SecurityObject, db);

				db.CommitTrans();

				this.List.Remove(server);
				server.Group = null;
			}
			catch (Exception ex)
			{
				db.RollbackTrans();
				throw ex;
			}
		}
Ejemplo n.º 28
0
        /// <summary>
        /// 对服务器或是服务器组的操作写日志,参数中要指定操作流水号
        /// </summary>
        public void WriteServerOperationLog(Int64 operationId, int userId, ServerGroup.Type targetType, int targetId, GameServer.ServerOperationType operationType, bool operationSuccessful, string description, string region)
        {
            using (IBlazeDatabase db = DbFactory.GetDatabase())
            {
                IBlazeTable table = db.GetTable(TableString.ServerOperationLogTableName);

                string[] fieldNames = {
					        TableString.ServerOperationLogFieldOperationId,
					        TableString.ServerOperationLogFieldUserId,
					        TableString.ServerOperationLogFieldServerOrGroup,
                            TableString.ServerOperationLogFieldTargetId,
                            TableString.ServerOperationLogFieldOperationType,
                            TableString.ServerOperationLogFieldOperationResult,
                            TableString.ServerOperationLogFieldDescription,
                            TableString.ServerOperationLogFieldLogTime,
                            TableString.ServerOperationLogFieldFatherRegion
				    };

                object[] fieldValues = {
                        operationId,
                        userId,
				        (Int16)targetType,
                        targetId,
                        (Int16)operationType,
                        Convert.ToInt16(operationSuccessful),
                        description,
                        DateTime.Now,
                        region
			        };

                //添加此次的操作日志
                table.Add(fieldNames, fieldValues);
            }
        }
Ejemplo n.º 29
0
		/// <summary>
		/// 载入游戏服务器
		/// </summary>
		private void LoadGameServers()
		{
			lock (this)
			{
				IBlazeDatabase db = null;
				try
				{
					db = DbFactory.GetDatabase();
					IBlazeTable table = db.GetTable(TableString.GameServerTableName);					

					DataSet data = new DataSet();
					table.Get(data);
					DataRowCollection rows = data.Tables[TableString.GameServerTableName].Rows;
					for (int i = 0; i < rows.Count; i++)
					{
						DataRow row = rows[i];
						int serverId = (int)row[TableString.GameServerFieldId];
						string serverNetAddress = row[TableString.GameServerFieldNetAddress] as string;
						string gameDir = row[TableString.GameServerFieldGameDir] as string;
                        string configcontent = row[TableString.GameServerFieldCfgString] as string;
                        int ftpServer = (int)row[TableString.GameServerFieldFtpDownloadServer];
						GameServer.ConfigGuardState configState = (GameServer.ConfigGuardState)row[TableString.GameServerFieldHasBeenConfigGuard];
						GameServer.ServerType serverType = (GameServer.ServerType)row[TableString.GameServerFieldServerType];
												
						FSEyeObject serverObj = AdminServer.TheInstance.SecurityManager.Get(serverId);
						if (serverObj != null)
						{
							GameServer server = new GameServer();
							server.SecurityObject = serverObj;
							server.IpAddress = serverNetAddress;
							server.GameDir = gameDir;
							server.ConfigState = configState;
							server.Type = serverType;
                            server.ConfigContent = configcontent;
                            server.FtpServer = ftpServer;

                            //取得gmc_ip
                            string GMCIp = row[TableString.GameServerFieldGmcIp] as string;
                            if ((GMCIp != null) && (GMCIp.Length != 0))
                            {
                                server.LordConfig.GMCIp = GMCIp;
                            }
                            
                            //取得gmc_account
                            string GMCAccount = row[TableString.GameServerFieldGmcAccount] as string;
                            if ((GMCAccount != null) && (GMCAccount.Length != 0))
                            {
                                server.LordConfig.GMCAccount = GMCAccount;
                            }

                            try
                            {
                                server.LordConfig.FSEyeIp = (string)row[TableString.GameServerFieldFSEyeIp];
                                server.LordConfig.FSEyePort = (int)row[TableString.GameServerFieldFSEyePort];
                            }
                            catch (Exception)
                            { }

                            try
                            {
                                server.LordConfig.PaysysIp = (string)row[TableString.GameServerFieldPaysysIp];
                                server.LordConfig.PaysysPort = (int)row[TableString.GameServerFieldPaysysPort];
                                server.LordConfig.PaysysLoginName = (string)row[TableString.GameServerFieldPaysysLoginName];
                                server.LordConfig.PaysysLoginPwd = (string)row[TableString.GameServerFieldPaysysLoginPwd];
                            }
                            catch (Exception)
                            { }

                            try
                            {
								server.LordConfig.DbHost = (string)row[TableString.GameServerFieldDbHost];
								server.LordConfig.DbName = (string)row[TableString.GameServerFieldDbName];
								server.LordConfig.DbLoginName = (string)row[TableString.GameServerFieldDbLoginName];
								server.LordConfig.DbLoginPwd = (string)row[TableString.GameServerFieldDbLoginPwd];
								server.LordConfig.DbBackupPath = (string)row[TableString.GameServerFieldDbBackupDir];
							}
							catch (Exception)
							{
							}
                            server.LordConfig.BindIp = server.IpAddress;
							
							server.Initialize();
							server.GameStateChanged += new GameStateChangeEventHandler(GameStateChanged);
							_systemTickTimer.Elapsed += new System.Timers.ElapsedEventHandler(server.OnTick);
							_gameServerList.Add(server);
						}
					}					
				}
				catch (Exception ex)
				{
					throw ex;
				}
				finally
				{
					if (db != null)
					{
						db.Close();
					}
				}
			}
		}
Ejemplo n.º 30
0
		protected override bool CreateScript(GameServer server, out string script, out string input)
		{
			script = _scriptText;
			input = _input;

			return (script != null);
		}