Exemplo n.º 1
0
        /// <summary>
        /// config구조체로 초기화
        /// </summary>
        /// <param name="config"></param>
        private void Setup(TcpServiceConfig config)
        {
            // 콘솔 로거 생성
            if (config.Log != null)
            {
                if (config.Log.Equals("console", StringComparison.OrdinalIgnoreCase))
                {
                    this.Logger = new ConsoleLogger();
                }
                else if (config.Log.Equals("file", StringComparison.OrdinalIgnoreCase))
                {
                    this.Logger = new SimpleFileLogger(@"netservice.log");
                }
                else
                {
                    this.Logger = new NullLogger();
                }
            }
            else
            {
                this.Logger = new ConsoleLogger();
            }

            this.Logger.Level = LogLevel.Error;
            if (config.LogLevel != null)
            {
                this.Logger.Level = (LogLevel)Enum.Parse(typeof(LogLevel), config.LogLevel, true);
            }

            // 16, 128, 256, 1024, 4096 사이즈의 풀을 생성하는 설정
            int[] poolSizes = new int[] { 4096, 16, 128, 256, 1024 };
            this._pooledBufferManager = new PooledBufferManager(poolSizes);

            this.Config = config;
            if (Config.MessageFactoryTypeName != "")
            {
                try
                {
                    System.Runtime.Remoting.ObjectHandle objHandle = Activator.CreateInstance(this.Config.MessageFactoryAssemblyName, this.Config.MessageFactoryTypeName);
                    _messageFactory = (NetService.Message.IMessageFactory)objHandle.Unwrap();
                }
                catch (Exception e)
                {
                    Logger.Log(LogLevel.Error, "메세지 팩토리 생성 실패", e);
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 생성자
 /// </summary>
 /// <param name="config">
 /// tcp service 에 필요한 config
 /// </param>
 public TcpService(TcpServiceConfig config)
 {
     Setup(config);
     return;
 }