Example #1
0
        public static void Hook()
        {
            // Prevent the server from starting up again once it is terminated.
            if (_stopping) { return; }

            lock (_lockObject)
            {
                if (_webServer == null)
                {
                    try
                    {
                        _webServer = new IntegratedWebServer();
                        _webServer.Start();
                        GnomanEmpire.Instance.Exiting += OnExiting;
                    }
                    catch (Exception ex)
                    {
                        LogException(ex);

                        // It's important that we still throw an exception here.
                        // Exceptions thrown at this point are undoubtedly on the GnomanEmpire.Instance property.
                        // So, exit here to avoid the risk of bricking someone's game save.
                        throw;
                    }
                }
            }
        }
Example #2
0
        public void Start()
        {
            //启动服务器
            server.Start(app =>
            {
                //注册WebSocket连接
                IDictionary <string, Type> webSocketConnectionDict = WebSocket.WebSocketManager.Instance.GetConnectionTypeDict();
                if (webSocketConnectionDict.Count > 0)
                {
                    var OwinExtensionType       = typeof(OwinExtension);
                    var MapWebSocketRouteMethod = OwinExtensionType.GetMethod(nameof(OwinExtension.MapWebSocketRoute), new Type[] { typeof(IAppBuilder), typeof(string), typeof(Microsoft.Practices.ServiceLocation.IServiceLocator) });

                    foreach (var item in webSocketConnectionDict)
                    {
                        var route          = item.Key;
                        var connectionType = item.Value;

                        var method = MapWebSocketRouteMethod.MakeGenericMethod(connectionType);
                        method.Invoke(null, new object[] { app, route, null });
                    }
                }
                //中间件上下文
                app.Use <MiddlewareContext>();
                //注册所有的中间件
                foreach (var register in middlewareRegisterActionList)
                {
                    register.Invoke(app);
                }
            }, endpoint);
            //初始化所有的中间件
            this.Middlewares = MiddlewareContext.Instance.Middlewares;
            HunterUtils.TryHunt(this.Middlewares, properties);
            MiddlewareContext.Instance.IsReady = true;
        }
Example #3
0
        public static void Main()
        {
            var        kernel    = new StandardKernel(new WebServerModule());
            IWebServer webServer = kernel.Get <IWebServer>();

            webServer.Start();
        }
Example #4
0
        public virtual TestReport Run()
        {
            _logger.Information("{1}{1}Starting Test Run: {0}{1}{1}"
                                .FormatWith(DateTime.Now, Environment.NewLine));

            _webServer.Start();
            foreach (var browser in _webBrowsers)
            {
                browser.Start();
            }
            _dialogMonitorRunner.Start();

            _browserThreadWaitHandle.WaitOne();

            _dialogMonitorRunner.Stop();
            foreach (var browser in _webBrowsers)
            {
                browser.Stop();
            }
            _webServer.Stop();

            var testReport = _testResultAggregator.CurrentReport;

            return(testReport);
        }
Example #5
0
        public virtual TestReport Run()
        {
            DateTime startOfRun = DateTime.Now;

            _logger.Information("{1}{1}Starting Test Run: {0}{1}{1}"
                                .FormatWith(DateTime.Now, Environment.NewLine));

            _webServer.Start();
            foreach (var browser in _webBrowsers)
            {
                browser.Start();
            }
            _dialogMonitorRunner.Start();

            _browserThreadWaitHandle.WaitOne();

            _dialogMonitorRunner.Stop();
            foreach (var browser in _webBrowsers)
            {
                browser.Stop();
            }
            _webServer.Stop();

            var testReport = _testResultAggregator.CurrentReport;

            ConsoleTestCompleteMessage.WriteOutCompletionStatement(testReport, startOfRun);
            return(testReport);
        }
Example #6
0
 internal virtual Func <RemoteWebDriver> StartPrivateServerAndCreateRemoteDriverWithCapabilities(ICapabilities capabilities, IWebServer localServer)
 {
     return(() =>
     {
         localServer.Start();
         return new RemoteWebDriver(new Uri(_configurationProvider.RemoteUrl), capabilities, CommandTimeOut);
     });
 }
        public TestReport Run()
        {
            _webServer.Start();

            _continuousRunnerThread.Start();
            _continuousRunnerThread.Join();

            return(new TestReport(_xapPath));
        }
Example #8
0
 private void MessagesTextBox_DoubleClick(object sender, EventArgs e)
 {
     if (webServer.IsStarted)
     {
         webServer.Stop();
     }
     else
     {
         webServer.Start();
     }
 }
Example #9
0
        public TestReport Run()
        {
            _webServer.Start();

            _logger.Information("Xap test web server started. You can browse to... {0}{1}".FormatWith(Environment.NewLine, _testHtmlPageUrl));

            _continuousRunnerThread.Start();
            _continuousRunnerThread.Join();

            return(new TestReport(_xapPath));
        }
Example #10
0
 private void StartStopButton_Click(object sender, EventArgs e)
 {
     if (webServer.IsStarted)
     {
         webServer.Stop();
     }
     else
     {
         webServer.Start();
     }
 }
        public void Run()
        {
            try
            {
                Process();

                if (appSettings.Watch)
                {
                    watchTimer = new Timer(OnWatchTimerCallback, null, Timeout.Infinite, Timeout.Infinite);
                    var watcher = new FileSystemWatcher
                    {
                        IncludeSubdirectories = true,
                        NotifyFilter          = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName,
                        Path = appSettings.Input,
                    };
                    watcher.Created            += FileChanged;
                    watcher.Changed            += FileChanged;
                    watcher.Deleted            += FileChanged;
                    watcher.Renamed            += FileChanged;
                    watcher.Error              += FileWatcherError;
                    watcher.EnableRaisingEvents = true;

                    Colorizer.WriteLine($"[Green!Watch mode started ({RollingDelayInSeconds} second delay)]");

                    webServer.Start();
                }
                else
                {
                    Colorizer.WriteLine("[Green!Completed]");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine();
                Colorizer.WriteLine("[Red!ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR]");
                Console.WriteLine();
                Console.WriteLine($"{ex.Message}");
                Console.WriteLine($"{ex.StackTrace}");
                if (ex.InnerException != null)
                {
                    Console.WriteLine();
                    Console.WriteLine($"{ex.InnerException.Message}");
                    Console.WriteLine($"{ex.InnerException.StackTrace}");
                }
            }
#if DEBUG
            Console.ReadKey();
#endif
        }
Example #12
0
        private static void Main(string[] args)
        {
            _ws               = new WebServer();
            _ws.PortNumber    = 8086;
            _ws.ServerAddress = "127.0.0.1";
            _ws.AllowBrowsing = true;

            Console.WriteLine(string.Format("Browsing started on {0}:{1}", _ws.ServerAddress, _ws.PortNumber));
            Console.WriteLine("Root directory : " + _ws.RootDirectory);

            Thread thread1 = new Thread(Program.ThreadFunc);

            thread1.Start();

            _ws.Start();
            Console.WriteLine(" Press a key to quit.");
            Console.ReadKey();
            _ws.Stop();
        }
Example #13
0
        public bool RunAllTests()
        {
            results.Clear();

            using (webServer.Start())
            {
                foreach (string testFile in testFileReader)
                {
                    string testFileUrl = webServer.MakeHttpUrl(testFile);

                    if (!fixtureRunner.RunFixture(GetFixtureUrl(testFileUrl), FixtureTimeoutInMilliseconds))
                    {
                        results.AddRange(fixtureRunner.Errors);
                    }
                }
            }

            return(HasErrors);
        }
Example #14
0
        public static int RunWebServer(IWebServer webServer, Logger log, ManualResetEvent exitLatch)
        {
            try
            {
                log.Info("Starting web server instance...");
                webServer.Start();
                Console.WriteLine("Server Started.... press CTRL + C to stop");
                Warmup(webServer);
                exitLatch.WaitOne();
                Console.WriteLine("Server shutting down, please wait...");
                webServer.Stop();

                return 0;
            }
            catch (WebCorePortException)
            {
                log.Error("Please allow the user to access the port. eg. 'netsh http add urlacl url=http://*:9999/ user={0}'", WindowsIdentity.GetCurrent().Name);
                return 1;
            }
        }
Example #15
0
 public void Start()
 {
     //APP构造器
     //var appBuilder = new AppBuilder();
     //启动服务器
     server.Start(app =>
     {
         //中间件上下文
         app.Use <MiddlewareContext>();
         //注册所有的中间件
         foreach (var register in middlewareRegisterActionList)
         {
             register.Invoke(app);
         }
     }, endpoint);
     //初始化所有的中间件
     this.Middlewares = MiddlewareContext.Instance.Middlewares;
     HunterUtils.TryHunt(this.Middlewares, properties);
     MiddlewareContext.Instance.IsReady = true;
 }
        public static int RunWebServer(IWebServer webServer, Logger log, ManualResetEvent exitLatch)
        {
            try
            {
                log.Info("Starting web server instance...");
                webServer.Start();
                Console.WriteLine("Server Started.... press CTRL + C to stop");
                Warmup(webServer);
                exitLatch.WaitOne();
                Console.WriteLine("Server shutting down, please wait...");
                webServer.Stop();

                return(0);
            }
            catch (WebCorePortException)
            {
                log.Error("Please allow the user to access the port. eg. 'netsh http add urlacl url=http://*:9999/ user={0}'", WindowsIdentity.GetCurrent().Name);
                return(1);
            }
        }
Example #17
0
        public static IWebServer CreateWebServer(string serverType, string remoteUrl, string webProjectPath, int port)
        {
            string serverTypeName = _webServerCreators.Keys.FirstOrDefault(x => x.IndexOf(serverType, StringComparison.InvariantCultureIgnoreCase) == 0);

            if (serverTypeName != null)
            {
                Func <IWebServer> instanceCreator = _webServerCreators[serverTypeName];
                IWebServer        webServer       = instanceCreator();
                if (webServer is ILocalWebServer)
                {
                    ((ILocalWebServer)webServer).Initialize(webProjectPath, port);
                }
                else if (webServer is IRemoteWebServer)
                {
                    ((IRemoteWebServer)webServer).Initialize(remoteUrl);
                }
                webServer.Start();
                return(webServer);
            }
            else
            {
                throw new WebServerException(string.Format("No web server type '{0}' registered", serverType));
            }
        }
Example #18
0
 public void Initialise()
 {
     _databaseInitialiser.InitialiseDatabase();
     _webServer.Start();
     _smtpServer.Listen();
 }
Example #19
0
 public void Run()
 {
     _WebServer.Start();
     _ServerWindow.Run();
     _WebServer.Dispose();
 }
Example #20
0
 public async Task Start()
 {
     await _server.Start();
 }