Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Why does the connection remain open even when removed from DOM?

$
0
0

I'm using .NET 8 Blazor Server and I have a component with the following code block:

@if (isStreaming){<img src="@streamUrl" />}

When a button is pressed the isStreaming property is toggled. The img src is a mjepg url that remains open and is streamed to the browser. The button's @onclick event is bound to the method:

private void CloseStream(){    streamUrl = String.Empty;    StateHasChanged();}

Here is where I am confused, when it is set up as such and the button is pressed the connection closes and no longer shows in the browser. However, if I add isStreaming = false to the line before StateHasChanged(); The <img> tag doesn't appear in the DOM yet the connection remains open. Why is this happening? Shouldn't the connection terminate? The <img> tag is no longer on the page and even before that happened the URL was set to an empty string.

protected override async Task OnInitializedAsync(){    streamUrl = "https://examplestream"; //mjpeg}

Called by Parent Component with:

@rendermode InteractiveServer@attribute [StreamRendering]<StreamComponent stream="@clickedstream" @key="@clickedstream"></StreamComponent>

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>