Пример #1
0
        /// <summary>
        /// Hook up the Markdown Page Processing functionality in the Startup.Configure method
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public static IApplicationBuilder UseLiveReload(this IApplicationBuilder builder)
        {
            var configuration = builder.ApplicationServices.GetRequiredService <IOptionsMonitor <LiveReloadConfiguration> >();

            builder.UseWhen(
                // Decide if the middleware should activate
                (_) => configuration.CurrentValue.LiveReloadEnabled,
                (subAppBuilder) =>
            {
                var webSocketOptions = new WebSocketOptions()
                {
                    KeepAliveInterval = TimeSpan.FromSeconds(240),
                    ReceiveBufferSize = 256
                };
                subAppBuilder.UseWebSockets(webSocketOptions);

                subAppBuilder.UseMiddleware <LiveReloadMiddleware>();

                LiveReloadFileWatcher.StartFileWatcher(configuration);

                // this isn't necessary as the browser disconnects and on reconnect refreshes
                //LiveReloadMiddleware.RefreshWebSocketRequest();
            }
                );

            return(builder);
        }
Пример #2
0
        /// <summary>
        /// Hook up the Markdown Page Processing functionality in the Startup.Configure method
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public static IApplicationBuilder UseLiveReload(this IApplicationBuilder builder)
        {
            var config = LiveReloadConfiguration.Current;

            if (config.LiveReloadEnabled)
            {
                var webSocketOptions = new WebSocketOptions()
                {
                    KeepAliveInterval = TimeSpan.FromSeconds(240),
                    ReceiveBufferSize = 256
                };
                builder.UseWebSockets(webSocketOptions);

                builder.UseMiddleware <LiveReloadMiddleware>();

                LiveReloadFileWatcher.StartFileWatcher();
            }

            return(builder);
        }
        /// <summary>
        /// Hook up the Markdown Page Processing functionality in the Startup.Configure method
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public static IApplicationBuilder UseLiveReload(this IApplicationBuilder builder)
        {
            var config = LiveReloadConfiguration.Current;

            if (config.LiveReloadEnabled)
            {
                var webSocketOptions = new WebSocketOptions()
                {
                    KeepAliveInterval = TimeSpan.FromSeconds(240),
                };
                builder.UseWebSockets(webSocketOptions);

                builder.UseMiddleware <LiveReloadMiddleware>();

                LiveReloadFileWatcher.StartFileWatcher();

                // always refresh when the server restarts...
                _ = LiveReloadMiddleware.RefreshWebSocketRequest();
            }

            return(builder);
        }
Пример #4
0
        /// <summary>
        /// Hook up the Markdown Page Processing functionality in the Startup.Configure method
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public static IApplicationBuilder UseLiveReload(this IApplicationBuilder builder)
        {
            var config = LiveReloadConfiguration.Current;

            if (config.LiveReloadEnabled)
            {
                var webSocketOptions = new WebSocketOptions()
                {
                    KeepAliveInterval = TimeSpan.FromSeconds(240),
                    ReceiveBufferSize = 256
                };
                builder.UseWebSockets(webSocketOptions);

                builder.UseMiddleware <LiveReloadMiddleware>();

                LiveReloadFileWatcher.StartFileWatcher();

                // this isn't necessary as the browser disconnects and on reconnect refreshes
                //LiveReloadMiddleware.RefreshWebSocketRequest();
            }

            return(builder);
        }