Inheritance: IDisposable, IChangeSetHandler
Example #1
0
        public IClientConnector Start(IApplication application, WebApplicationConfiguration additionalConfiguration = null)
        {
            var port     = additionalConfiguration?.Port ?? PortFinder.FindPort(5000);
            var hostname = additionalConfiguration?.Hostname ?? "localhost";

            _application = application;

            BaseAddress = $"http://{hostname}:{port}";

            var webSockets = new WebSocketsHandler();

            _commands = new CommandRunner(application);


            Client = new ClientConnector(webSockets, _commands.HandleJson)
            {
                WebSocketsAddress = $"ws://{hostname}:{port}"
            };

            startWebServer(hostname, port, webSockets);

#if DEBUG
            _watcher = new AssetFileWatcher(Client);
            _watcher.Start(_input);
#endif

            return(Client);
        }
        public IClientConnector Start(IApplication application)
        {
            var port = PortFinder.FindPort(5000);

            _application = application;

            BaseAddress = "http://localhost:" + port;

            var webSockets = new WebSocketsHandler();

            _commands = new CommandRunner(application);


            Client = new ClientConnector(webSockets, _commands.HandleJson)
            {
                WebSocketsAddress = $"ws://127.0.0.1:{port}"
            };

            startWebServer(port, webSockets);

#if DEBUG
            _watcher = new AssetFileWatcher(Client);
            _watcher.Start(_input);
#endif

            return(Client);
        }
Example #3
0
        private void configureStaticFiles(IApplicationBuilder app)
        {
            var baseDirectory = AssetFileWatcher.FindRootFolder();

            var clientRoot = AssetFileWatcher.FindClientFolder();

            app.UseStaticFiles(new StaticFileOptions
            {
                ServeUnknownFileTypes = true,
                FileProvider          = new CompositeFileProvider(new PhysicalFileProvider(baseDirectory), new PhysicalFileProvider(clientRoot))
            });
        }
Example #4
0
 public StartWatchingAssets(AssetFileWatcher watcher)
 {
     _watcher = watcher;
 }
        public IClientConnector Start(IApplication application)
        {
            var port = PortFinder.FindPort(5000);

            _application = application;

            BaseAddress = "http://localhost:" + port;

            var webSockets = new WebSocketsHandler();

            _commands = new CommandRunner(application);


            Client = new ClientConnector(webSockets, _commands.HandleJson)
            {
                WebSocketsAddress = $"ws://127.0.0.1:{port}"
            };

            startWebServer(port, webSockets);

#if DEBUG
            _watcher = new AssetFileWatcher(Client);
            _watcher.Start();
#endif

            return Client;
        }
Example #6
0
        public void Start()
        {
            Controller = _input.BuildRemoteController();
            var context = new StorytellerContext(Controller, _input);

            Controller.AssertValid();


            context.Start();

            var port = PortFinder.FindPort(5000);

            if (_input.WebSocketAddressFlag.IsNotEmpty())
            {
                port = new Uri(_input.WebSocketAddressFlag).Port;
            }


            BaseAddress = "http://localhost:" + port;

            var webSockets = new WebSocketsHandler();


            var webSocketsAddress = $"ws://127.0.0.1:{port}";

            // TODO -- fugly as hell. Either do it all the SM way, or rip out SM
            var registry = new WebApplicationRegistry(webSocketsAddress, webSockets, Controller, context);

            _container = new Container(registry);


            var baseDirectory = AppContext.BaseDirectory;
            var host          = new WebHostBuilder()
                                .UseKestrel()
                                .UseContentRoot(baseDirectory)
                                .UseUrls($"http://localhost:{port}")
                                .Configure(app =>
            {
                app.UseWebSockets();

                app.Use(async(http, next) =>
                {
                    if (http.WebSockets.IsWebSocketRequest)
                    {
                        await webSockets.HandleSocket(http).ConfigureAwait(false);
                    }
                    else
                    {
                        await next().ConfigureAwait(false);
                    }
                });

#if DEBUG
                configureStaticFiles(app);
#endif

                app.Run(async(http) =>
                {
                    var endpoint = _container.GetInstance <HomeEndpoint>();
                    var html     = endpoint.Index().ToString();

                    http.Response.ContentType = "text/html";
                    await http.Response.WriteAsync(html).ConfigureAwait(false);
                });
            });

            _server = host.Start();


            Controller.AddListener(_container.GetInstance <IClientConnector>());

            _container.GetInstance <AssetFileWatcher>().Start();

            var persistence = _container.GetInstance <IPersistenceController>();

            persistence.StartWatching(context.SpecPath);
            context.AddRemoteListener(persistence);

            var dsl = _container.GetInstance <IFixtureController>();

            dsl.StartWatching(context.FixturePath);
            context.AddRemoteListener(dsl);

#if DEBUG
            _watcher = new AssetFileWatcher(_container.GetInstance <IClientConnector>());
#endif
        }