This commit is contained in:
drastiq 2019-11-06 23:06:47 +01:00
parent fd80926607
commit 527be316ff
4 changed files with 33 additions and 7 deletions

View File

@ -23,7 +23,11 @@ namespace Squirrowse.Client
public async Task StartAsync(CancellationToken cancellationToken)
{
await _connectionManager.InitConnection(ConnectionType.Client);
for (int i = 0; i < 100; i++)
{
await _connectionManager.InitConnection(ConnectionType.Client);
}
}

View File

@ -31,7 +31,8 @@ namespace Squirrowse.Core.Services
{
if (_connection.State == HubConnectionState.Connected) return;
await _connection.StartAsync();
await RegisterOnHub(type);
// await RegisterOnHub(type);
await SpamHub(type);
Connected = true;
}
@ -47,6 +48,15 @@ namespace Squirrowse.Core.Services
{
await _connection.SendAsync("AddUser", Environment.UserName,type);
}
#warning debug
private async Task SpamHub(ConnectionType type)
{
for (int i = 0; i < 100; i++)
{
await _connection.SendAsync("AddUser", Environment.UserName + $"{DateTime.Now}", type);
}
}
}
}

View File

@ -114,6 +114,7 @@ namespace Squirrowse.Service.Hubs
var client = manager.getClientSideUsers();
foreach (var va in client)
{
await Task.Delay(500);
yield return va;
}
}

View File

@ -65,7 +65,7 @@ else
</div>
@code{
private List<User> agents;
private List<User> agents=new List<User>();
HubConnection connection;
string imageSource = null;
@ -73,17 +73,18 @@ else
protected override async Task OnInitializedAsync()
{
agents=new List<User>();
// agents=new List<User>();
await _connection.InitConnection(ConnectionType.Server);
connection = await _connection.GetConnection();
connection.On<IAsyncEnumerable<byte[]>>("RecData", OnStreamDataReceived);
//agents = await connection.InvokeAsync<string>("GetListOfTypeUserString");
//agents = await connection.InvokeAsync<User>("Getasuser");
//agents = await connection.InvokeAsync<IAsyncEnumerable<User>>("GetListOfTypeUserAsync",ConnectionType.Client);
await foreach (var dupa in connection.StreamAsync<User>("GetListOfTypeUserAsync", ConnectionType.Client))
await foreach (var dupa in connection.StreamAsync<User>("GetListOfTypeUserAsync", ConnectionType.Client).ConfigureAwait(false))
{
agents.Add(dupa);
// await Task.Delay(300);
this.StateHasChanged();
}
//connection.On<User>("NewUser", NewUser);
@ -92,6 +93,16 @@ else
//await connection.StartAsync();
}
//cannot control enumerator
//protected override async Task OnAfterRenderAsync(bool firstRender=true)
//{
// await foreach (var dupa in connection.StreamAsync<User>("GetListOfTypeUserAsync", ConnectionType.Client))
// {
// agents.Add(dupa);
// await Task.Delay(300);
// this.StateHasChanged();
// }
//}
bool IsViewingCastOf(string agentName)
{