コード例 #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var settings = new CefSettings
            {
                CachePath = Path.Combine(Path.GetDirectoryName(typeof(App).Assembly.Location), "cache")
            };

            Cef.Initialize(settings);

            _ = Task.Run(async() =>
            {
                var builder = new WebHostBuilder();

                builder.ConfigureServices(services =>
                {
                    var server = new OwinServer();
                    server.UseOwin(appFunc =>
                    {
                        var requestContext = Cef.GetGlobalRequestContext();
                        requestContext.RegisterOwinSchemeHandlerFactory("https", "cefsharp.test", appFunc);
                    });

                    services.AddSingleton <IServer>(server);
                });

                _host = builder
                        .UseStartup <Startup>()
                        .UseContentRoot(Directory.GetCurrentDirectory())
                        .Build();

                await _host.RunAsync();
            });
        }
コード例 #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development");

            _ = Task.Run(async() =>
            {
                var builder = new WebHostBuilder();

                builder.ConfigureServices(services =>
                {
                    var server = new OwinServer();
                    server.UseOwin(appFunc =>
                    {
                        _appFunc = appFunc;
                    });

                    services.AddSingleton <IServer>(server);
                    services.AddMvc();
                });

                builder.ConfigureLogging(logging =>
                {
                    logging.AddConsole();
                });

                _host = builder
                        .UseStartup <Startup>()
                        .UseContentRoot(Directory.GetCurrentDirectory())
                        .Build();

                await _host.RunAsync();
            });
        }
コード例 #3
0
        public async Task TestHelloWorldAsync()
        {
            var host    = "localhost";
            var port    = 50051;
            var handler = new GroupCacheHandler();

            using (var server = new OwinServer(handler, port, host)){
                server.Start();
                var endpoint = new PeerEndpoint()
                {
                    HostName = host, Port = port
                };
                using (var client = new OwinClient(endpoint))
                {
                    using (var stream = new MemoryStream())
                    {
                        var cacheControl = new CacheControl();
                        await client.GetAsync("groupA", "key1", stream, cacheControl, CancellationToken.None);

                        var str = stream.StreamToString();
                        Assert.AreEqual(str, "HelloWorld");
                        Assert.IsFalse(cacheControl.NoStore);
                    }
                }
            }
        }
コード例 #4
0
        public async Task TestServerSideExceptionAsync()
        {
            var host    = "localhost";
            var port    = 50051;
            var handler = new BadGroupCacheHandler();

            using (var server = new OwinServer(handler, port, host))
            {
                server.Start();
                var endpoint = new PeerEndpoint()
                {
                    HostName = host, Port = port
                };
                using (var client = new OwinClient(endpoint))
                {
                    using (var stream = new MemoryStream())
                    {
                        await client.GetAsync("groupA", "key1", stream, new CacheControl(), CancellationToken.None);

                        var str = stream.StreamToString();
                        Assert.Fail();
                    }
                }
            }
        }
コード例 #5
0
        public static async Task Main(string[] args)
        {
            AppFunc appFunc = null;

            //Only setup our AspNet Core host if within the Browser Process
            //Not needed for the sub processes (render, gpu, etc)
            //TODO: Move this somewhere internal to Chromely that
            //doesn't require the extra check and supports async
            if (!args.Any(x => x.StartsWith("--type")))
            {
                var tcs = new TaskCompletionSource <AppFunc>();

                var builder = new WebHostBuilder();

                builder.ConfigureServices(services =>
                {
                    var server = new OwinServer();
                    server.UseOwin(appFunc =>
                    {
                        tcs.SetResult(appFunc);
                    });

                    services.AddSingleton <IServer>(server);
                });

                _host = builder
                        .UseStartup <Startup>()
                        .UseContentRoot(Directory.GetCurrentDirectory())
                        .Build();

                _ = _host.RunAsync();

                appFunc = await tcs.Task;
            }

            var config = DefaultConfiguration.CreateForRuntimePlatform();

            config.WindowOptions.Title = "Title Window";
            config.StartUrl            = "https://chromely.test";
            //config.StartUrl = "chrome://version";

            var app = new OwinChromelyBasicApp(appFunc);

            AppBuilder
            .Create()
            .UseConfig <DefaultConfiguration>(config)
            .UseApp <OwinChromelyBasicApp>(app)
            .Build()
            .Run(args);

            await _host.StopAsync();
        }
コード例 #6
0
 private static void Main(string[] args)
 {
     OwinServer.StartServer();
 }
コード例 #7
0
 internal void InitManager(Uri url)
 {
     _owinServerRef = OwinServerFactory.CreateOwinServer(url);
 }