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()
|
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)
|
public async Task UploadByteStream(IAsyncEnumerable<byte[]> stream)
|
||||||
{
|
{
|
||||||
foreach (var user in manager.getServerSideUsers().ToList())
|
//await Clients.Groups(Core.Models.Groups.superUser.ToString()).SendAsync("DUPA", "beniz");
|
||||||
await Clients.Client(user.ConnectionId).SendAsync("RecData", stream);
|
//await Clients.Groups(Core.Models.Groups.superUser.ToString()).SendAsync("RecData", stream);
|
||||||
await foreach (var frame in 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} ");
|
logger.LogInformation($"Got frame size: {frame.Length} ");
|
||||||
await Task.Delay(100); //leave some delay for debug purpose
|
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.Client) return manager.getClientSideUsers();
|
||||||
if (t == ConnectionType.Server) return manager.getServerSideUsers();
|
if (t == ConnectionType.Server) return manager.getServerSideUsers();
|
||||||
throw new Exception("not found");
|
return manager.getAllUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<User>> GetAllUsers()
|
public async Task<IEnumerable<User>> GetAllUsers()
|
||||||
|
@ -56,31 +56,40 @@
|
|||||||
{
|
{
|
||||||
await _connection.InitConnection(ConnectionType.Server);
|
await _connection.InitConnection(ConnectionType.Server);
|
||||||
connection = await _connection.GetConnection();
|
connection = await _connection.GetConnection();
|
||||||
|
connection.On<string>("DUPA", DuPa);
|
||||||
connection.On<IAsyncEnumerable<byte[]>>("RecData", OnStreamDataReceived);
|
connection.On<byte[]>("RecData", OnStreamDataReceived);
|
||||||
|
|
||||||
await foreach (var user in connection.StreamAsync<User>("GetListOfTypeUserAsync", ConnectionType.Client).ConfigureAwait(false))
|
await foreach (var user in connection.StreamAsync<User>("GetListOfTypeUserAsync", ConnectionType.Client).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
agents.Add(user);
|
agents.Add(user);
|
||||||
this.StateHasChanged();
|
this.StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool IsViewingCastOf(string agentName)
|
bool IsViewingCastOf(string agentName)
|
||||||
{
|
{
|
||||||
return agentName == CurrentViewCastAgent;
|
return agentName == CurrentViewCastAgent;
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task OnStreamDataReceived(IAsyncEnumerable<byte[]> streamData)
|
public void DuPa(string duuupa)
|
||||||
{
|
{
|
||||||
await foreach (var t in streamData)
|
var s= "DuPa";
|
||||||
{
|
|
||||||
var base64 = Convert.ToBase64String(t);
|
}
|
||||||
|
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);
|
imageSource = String.Format("data:image/jpg;base64,{0}", base64);
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user