Stream work, client leak memory
This commit is contained in:
parent
71c437d8d7
commit
15112abac9
@ -46,7 +46,12 @@ namespace Squirrowse.Client.Service
|
||||
|
||||
public async Task StartStream()
|
||||
{
|
||||
await SendStreamAsync(camera.GetFramesAsyncEnumerator());
|
||||
while (true)
|
||||
{
|
||||
await SendStreamAsync(camera.GetFramesAsyncEnumerator());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -77,10 +77,11 @@ namespace Squirrowse.Service.Hubs
|
||||
|
||||
public async Task UploadByteStream(IAsyncEnumerable<byte[]> stream)
|
||||
{
|
||||
foreach (var user in manager.getServerSideUsers().ToList())
|
||||
await Clients.Client(user.ConnectionId).SendAsync("RecData", stream);
|
||||
//await Clients.Groups(Core.Models.Groups.superUser.ToString()).SendAsync("DUPA", "beniz");
|
||||
//await Clients.Groups(Core.Models.Groups.superUser.ToString()).SendAsync("RecData", stream);
|
||||
await foreach (var frame in stream)
|
||||
{
|
||||
await Clients.Groups(Core.Models.Groups.superUser.ToString()).SendAsync("RecData", frame);
|
||||
logger.LogInformation($"Got frame size: {frame.Length} ");
|
||||
await Task.Delay(100); //leave some delay for debug purpose
|
||||
}
|
||||
@ -90,7 +91,7 @@ namespace Squirrowse.Service.Hubs
|
||||
{
|
||||
if (t == ConnectionType.Client) return manager.getClientSideUsers();
|
||||
if (t == ConnectionType.Server) return manager.getServerSideUsers();
|
||||
throw new Exception("not found");
|
||||
return manager.getAllUsers();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<User>> GetAllUsers()
|
||||
|
@ -56,8 +56,8 @@
|
||||
{
|
||||
await _connection.InitConnection(ConnectionType.Server);
|
||||
connection = await _connection.GetConnection();
|
||||
|
||||
connection.On<IAsyncEnumerable<byte[]>>("RecData", OnStreamDataReceived);
|
||||
connection.On<string>("DUPA", DuPa);
|
||||
connection.On<byte[]>("RecData", OnStreamDataReceived);
|
||||
|
||||
await foreach (var user in connection.StreamAsync<User>("GetListOfTypeUserAsync", ConnectionType.Client).ConfigureAwait(false))
|
||||
{
|
||||
@ -73,14 +73,23 @@
|
||||
return agentName == CurrentViewCastAgent;
|
||||
}
|
||||
|
||||
async Task OnStreamDataReceived(IAsyncEnumerable<byte[]> streamData)
|
||||
public void DuPa(string duuupa)
|
||||
{
|
||||
await foreach (var t in streamData)
|
||||
{
|
||||
var base64 = Convert.ToBase64String(t);
|
||||
var s= "DuPa";
|
||||
|
||||
}
|
||||
async Task OnStreamDataReceived(byte[] streamData)
|
||||
{
|
||||
//await foreach (var t in streamData)
|
||||
//{
|
||||
// var base64 = Convert.ToBase64String(t);
|
||||
// imageSource = String.Format("data:image/jpg;base64,{0}", base64);
|
||||
// StateHasChanged();
|
||||
//}
|
||||
|
||||
var base64 = Convert.ToBase64String(streamData);
|
||||
imageSource = String.Format("data:image/jpg;base64,{0}", base64);
|
||||
StateHasChanged();
|
||||
}
|
||||
StateHasChanged();
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user