@page "/hub"

Hub

@using Microsoft.AspNetCore.SignalR.Client @using Squirrowse.Core.Models @using Squirrowse.Core.Services @inject IConnectionManager _connection;
@if (agents.Any()) { @foreach (var agent in agents) {

@agent.AgentName -> @agent.UserType.ToString()

} } else {

No Cams

}
@code{ private IEnumerable agents = new List(); HubConnection connection; string imageSource = null; string CurrentViewCastAgent = null; protected async override Task OnInitializedAsync() { await _connection.InitConnection(ConnectionType.Server); connection = await _connection.GetConnection(); connection.On>("RecData", OnStreamDataReceived); agents = await connection.InvokeAsync>("GetListOfTypeUser",ConnectionType.Client); //connection.On("NewScreenCastAgent", NewScreenCastAgent); //connection.On("RemoveScreenCastAgent", RemoveScreenCastAgent); //connection.On("OnStreamDataReceived", OnStreamDataReceived); //await connection.StartAsync(); } bool IsViewingCastOf(string agentName) { return agentName == CurrentViewCastAgent; } async void OnStreamDataReceived(IAsyncEnumerable streamData) { await foreach (var t in streamData) { var base64 = Convert.ToBase64String(t); imageSource = String.Format("data:image/jpg;base64,{0}", base64); StateHasChanged(); } } private async Task OnViewCastClicked(string agentName) { CurrentViewCastAgent = agentName; await connection.InvokeAsync("Startstream", agentName); } private async Task OnStopViewCastClicked(string agentName) { CurrentViewCastAgent = null; await connection.InvokeAsync("Stopstream", agentName); imageSource = null; StateHasChanged(); } }