コード例 #1
0
ファイル: TcpServer.cs プロジェクト: L1nY4n/tnt
        public TcpServer(String ipAddress = DefaultServerIpAddress, UInt16 port = DefaultServerPort, ILog logger = null,
                         Boolean debug    = true, TcpServerConfig config        = null)
        {
            _config = config ?? new TcpServerConfig();
            AssignIpAddressAndPort(ipAddress, port);
            _clientProcessingTasks = new Task[_config.ParallelTask];
            _clientConnectingTask  = new Task(ClientConnectProcessing, new CancellationToken(_interruptRequested));
            if (logger != null)
            {
                _logger = logger;
            }
            else
            {
                Hierarchy hierarchy  = (Hierarchy)LogManager.GetRepository();
                Logger    loggerImpl = hierarchy.LoggerFactory.CreateLogger(hierarchy, "Logger4Tests");
                loggerImpl.Hierarchy = hierarchy;
                loggerImpl.AddAppender(new RollingFileAppender());
                loggerImpl.AddAppender(new ColoredConsoleAppender());
                loggerImpl.Repository.Configured = true;

                hierarchy.Threshold = debug ? Level.Debug : Level.Info;
                loggerImpl.Level    = Level.All;

                _logger = new LogImpl(loggerImpl);
            }
            if (debug)
            {
                _logger.Debug("Server was inited in DEBUG mode");
            }
        }
コード例 #2
0
 public FlexibleTcpServer(String scriptFile, String ipAddress, UInt16 port, CompilerOptions compilerOptions = null,
                          ILog logger = null, Boolean debug = false, TcpServerConfig config = null)
     : base(ipAddress, port, logger, debug, config)
 {
     if (String.IsNullOrEmpty(scriptFile))
     {
         throw new ArgumentNullException("scriptFile");
     }
     if (!File.Exists(Path.GetFullPath(scriptFile)))
     {
         throw new ApplicationException("script");
     }
     // todo: umv : maybe check what is inside script (some functions presence)
     _scriptFile = scriptFile;
     if (compilerOptions == null)
     {
         _compilerOptions = new CompilerOptions();
     }
     else
     {
         _compilerOptions = compilerOptions;
     }
 }
コード例 #3
0
 public FlexibleTcpServer(String scriptFile, String ipAddress, UInt16 port, ILog logger = null, Boolean debug = false, TcpServerConfig config = null)
     : base(ipAddress, port, logger, debug, config)
 {
     if (String.IsNullOrEmpty(scriptFile))
     {
         throw new ArgumentNullException("scriptFile");
     }
     if (!File.Exists(Path.GetFullPath(scriptFile)))
     {
         throw new ApplicationException("script");
     }
     // todo: umv : maybe check what is inside script (some functions presence)
     _scriptFile = scriptFile;
     // compiler settings ...
     _parameters.GenerateExecutable = false;
     _parameters.GenerateInMemory   = true;
 }