diff --git a/MareSynchronosServer/MareSynchronosServer/Services/GrpcClientIdentificationService.cs b/MareSynchronosServer/MareSynchronosServer/Services/GrpcClientIdentificationService.cs index f944af2..9ffab32 100644 --- a/MareSynchronosServer/MareSynchronosServer/Services/GrpcClientIdentificationService.cs +++ b/MareSynchronosServer/MareSynchronosServer/Services/GrpcClientIdentificationService.cs @@ -27,8 +27,8 @@ public class GrpcClientIdentificationService : IHostedService private CancellationTokenSource _streamCts = new(); private CancellationTokenSource _faultCheckCts = new(); - public GrpcClientIdentificationService(ILogger logger, IdentificationService.IdentificationServiceClient gprcIdentClient, - IdentificationService.IdentificationServiceClient gprcIdentClientStreamOut, + public GrpcClientIdentificationService(ILogger logger, IdentificationService.IdentificationServiceClient gprcIdentClient, + IdentificationService.IdentificationServiceClient gprcIdentClientStreamOut, IdentificationService.IdentificationServiceClient gprcIdentClientStreamIn, MareMetrics metrics, IConfiguration configuration) { var config = configuration.GetSection("MareSynchronos"); @@ -226,9 +226,8 @@ public class GrpcClientIdentificationService : IHostedService { ServerId = _shardName, }); - while (await stream.ResponseStream.MoveNext(cts).ConfigureAwait(false)) + await foreach (var cur in stream.ResponseStream.ReadAllAsync(cts).ConfigureAwait(false)) { - var cur = stream.ResponseStream.Current; if (cur.IsOnline) { RemoteCachedIdents[cur.UidWithIdent.Uid.Uid] = cur.UidWithIdent; diff --git a/MareSynchronosServer/MareSynchronosServices/Identity/IdentityService.cs b/MareSynchronosServer/MareSynchronosServices/Identity/IdentityService.cs index cf4e19d..7477139 100644 --- a/MareSynchronosServer/MareSynchronosServices/Identity/IdentityService.cs +++ b/MareSynchronosServer/MareSynchronosServices/Identity/IdentityService.cs @@ -148,9 +148,10 @@ internal class IdentityService : IdentificationService.IdentificationServiceBase { _logger.LogInformation("Enqueued " + identchange.UidWithIdent.Uid.Uid + ":" + identchange.IsOnline + " from " + identchange.UidWithIdent.Ident.ServerId); - foreach (var dict in identChanges.Where(k => k.Key != identchange.UidWithIdent.Ident.ServerId)) + foreach (var k in identChanges.Keys) { - dict.Value.Enqueue(identchange); + if (string.Equals(k, identchange.UidWithIdent.Ident.ServerId, System.StringComparison.Ordinal)) continue; + identChanges[k].Enqueue(identchange); } }