/// <summary> /// 지정된 NetworkChannel만을 생성하고 네트워킹을 시작합니다. /// </summary> /// <param name="networkChannelName">시작할 NetworkChannel 이름</param> /// <returns>해당 NetworkChannel 객체</returns> public static NetworkChannel StartNetwork(String networkChannelName) { ConfigNetworkChannel config = _listNetworkConfig.Find(v => v.NetworkChannelName == networkChannelName); if (config == null) { throw new AegisException(AegisResult.InvalidArgument, "Invalid NetworkChannel name({0}).", networkChannelName); } NetworkChannel channel = NetworkChannel.CreateChannel(config.NetworkChannelName); if (config.ListenIpAddress.Length == 0 || config.ListenPortNo == 0) { channel.StartNetwork( delegate { return(GenerateSession(config.SessionClassName)); }, config.InitSessionPoolCount, config.MaxSessionPoolCount); } else { channel.StartNetwork( delegate { return(GenerateSession(config.SessionClassName)); }, config.InitSessionPoolCount, config.MaxSessionPoolCount) .OpenListener(config.ListenIpAddress, config.ListenPortNo); } return(channel); }
private static void LoadConfigFile(String filename) { XmlDocument xml = new XmlDocument(); xml.Load(filename); // Aegis { XmlNode node = xml.SelectSingleNode("Aegis"); ServerID = GetAttributeValue(node.Attributes, "id").ToInt32(); Logger.EnabledLevel = GetAttributeValue(node.Attributes, "logLevel", "0").ToInt32(); String mutexName = GetAttributeValue(node.Attributes, "mutexName", ""); if (mutexName.Length > 0) { Boolean isNew; _mutex = new Mutex(true, mutexName, out isNew); if (isNew == false) { throw new AegisException(AegisResult.InvalidArgument, "The mutex name({0}) is already in use.", mutexName); } } } // Aegis/NetworkChannel foreach (XmlNode node in xml.SelectNodes("Aegis/NetworkChannel")) { ConfigNetworkChannel channelConfig = new ConfigNetworkChannel(); channelConfig.NetworkChannelName = GetAttributeValue(node.Attributes, "name"); channelConfig.SessionClassName = GetAttributeValue(node.Attributes, "sessionClass"); channelConfig.InitSessionPoolCount = GetAttributeValue(node.Attributes, "initSessionPoolCount", "0").ToInt32(); channelConfig.MaxSessionPoolCount = GetAttributeValue(node.Attributes, "maxSessionPoolCount", "0").ToInt32(); channelConfig.ListenIpAddress = GetAttributeValue(node.Attributes, "listenIpAddress", ""); channelConfig.ListenPortNo = GetAttributeValue(node.Attributes, "listenPortNo", "0").ToInt32(); if (_listNetworkConfig.Where(v => v.NetworkChannelName == channelConfig.NetworkChannelName).Count() > 0) { throw new AegisException(AegisResult.InvalidArgument, "The NetworkChannel name({0}) is already in use.", channelConfig.NetworkChannelName); } _listNetworkConfig.Add(channelConfig); } // Aegis/CustomData XmlNode nodeCustomData = xml.SelectSingleNode("Aegis/CustomData"); if (nodeCustomData != null) { LoadCustomData(nodeCustomData, CustomData); } }