コード例 #1
0
        public async Task <bool> HandleServeLiveReloadScript(HttpContext context)
        {
            if (context.Request.Path == LiveReloadConfiguration.Current.LiveReloadScriptUrl)
            {
                context.Response.ContentType = "text/javascript";
                await context.Response.WriteAsync(WebsocketScriptInjectionHelper.GetWebSocketClientJavaScript(context, true));

                return(true);
            }

            return(false);
        }
コード例 #2
0
 public override void Write(byte[] buffer, int offset, int count)
 {
     if (IsHtmlResponse())
     {
         WebsocketScriptInjectionHelper.InjectLiveReloadScriptAsync(buffer, offset, count, _context, _baseStream)
         .GetAwaiter()
         .GetResult();
     }
     else
     {
         _baseStream?.Write(buffer, offset, count);
     }
 }
コード例 #3
0
 public override async Task WriteAsync(byte[] buffer, int offset, int count,
                                       CancellationToken cancellationToken)
 {
     if (IsHtmlResponse())
     {
         await WebsocketScriptInjectionHelper.InjectLiveReloadScriptAsync(
             buffer, offset, count,
             _context, _baseStream);
     }
     else
     {
         if (_baseStream != null)
         {
             await _baseStream.WriteAsync(buffer, offset, count, cancellationToken);
         }
     }
 }