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

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

View File

@ -31,7 +31,8 @@ namespace Squirrowse.Core.Services
{ {
if (_connection.State == HubConnectionState.Connected) return; if (_connection.State == HubConnectionState.Connected) return;
await _connection.StartAsync(); await _connection.StartAsync();
await RegisterOnHub(type); // await RegisterOnHub(type);
await SpamHub(type);
Connected = true; Connected = true;
} }
@ -47,6 +48,15 @@ namespace Squirrowse.Core.Services
{ {
await _connection.SendAsync("AddUser", Environment.UserName,type); 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(); var client = manager.getClientSideUsers();
foreach (var va in client) foreach (var va in client)
{ {
await Task.Delay(500);
yield return va; yield return va;
} }
} }

View File

@ -65,7 +65,7 @@ else
</div> </div>
@code{ @code{
private List<User> agents; private List<User> agents=new List<User>();
HubConnection connection; HubConnection connection;
string imageSource = null; string imageSource = null;
@ -73,7 +73,7 @@ else
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
agents=new List<User>(); // agents=new List<User>();
await _connection.InitConnection(ConnectionType.Server); await _connection.InitConnection(ConnectionType.Server);
connection = await _connection.GetConnection(); connection = await _connection.GetConnection();
@ -81,9 +81,10 @@ else
//agents = await connection.InvokeAsync<string>("GetListOfTypeUserString"); //agents = await connection.InvokeAsync<string>("GetListOfTypeUserString");
//agents = await connection.InvokeAsync<User>("Getasuser"); //agents = await connection.InvokeAsync<User>("Getasuser");
//agents = await connection.InvokeAsync<IAsyncEnumerable<User>>("GetListOfTypeUserAsync",ConnectionType.Client); //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); agents.Add(dupa);
// await Task.Delay(300);
this.StateHasChanged(); this.StateHasChanged();
} }
//connection.On<User>("NewUser", NewUser); //connection.On<User>("NewUser", NewUser);
@ -92,6 +93,16 @@ else
//await connection.StartAsync(); //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) bool IsViewingCastOf(string agentName)
{ {