fixes for when removing a pair or client
This commit is contained in:
		| @@ -87,7 +87,11 @@ public class PairManager : IDisposable | |||||||
|  |  | ||||||
|             if (!_allClientPairs[item.Key].HasAnyConnection()) |             if (!_allClientPairs[item.Key].HasAnyConnection()) | ||||||
|             { |             { | ||||||
|                 _allClientPairs.TryRemove(item.Key, out _); |                 if (_allClientPairs.TryRemove(item.Key, out var pair)) | ||||||
|  |                 { | ||||||
|  |                     pair.CachedPlayer?.Dispose(); | ||||||
|  |                     pair.CachedPlayer = null; | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         RecreateLazy(); |         RecreateLazy(); | ||||||
| @@ -197,6 +201,8 @@ public class PairManager : IDisposable | |||||||
|  |  | ||||||
|             if (!pair.HasAnyConnection()) |             if (!pair.HasAnyConnection()) | ||||||
|             { |             { | ||||||
|  |                 pair.CachedPlayer?.Dispose(); | ||||||
|  |                 pair.CachedPlayer = null; | ||||||
|                 _allClientPairs.TryRemove(dto.User, out _); |                 _allClientPairs.TryRemove(dto.User, out _); | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -211,6 +217,8 @@ public class PairManager : IDisposable | |||||||
|             pair.UserPair = null; |             pair.UserPair = null; | ||||||
|             if (!pair.HasAnyConnection()) |             if (!pair.HasAnyConnection()) | ||||||
|             { |             { | ||||||
|  |                 pair.CachedPlayer?.Dispose(); | ||||||
|  |                 pair.CachedPlayer = null; | ||||||
|                 _allClientPairs.TryRemove(dto.User, out _); |                 _allClientPairs.TryRemove(dto.User, out _); | ||||||
|             } |             } | ||||||
|             else |             else | ||||||
|   | |||||||
| @@ -219,9 +219,17 @@ public partial class ApiController | |||||||
|             Logger.Debug("Sending " + requestMessage.Method + " to " + requestMessage.RequestUri); |             Logger.Debug("Sending " + requestMessage.Method + " to " + requestMessage.RequestUri); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (ct != null) |         try | ||||||
|             return await _httpClient.SendAsync(requestMessage, ct.Value).ConfigureAwait(false); |         { | ||||||
|         return await _httpClient.SendAsync(requestMessage).ConfigureAwait(false); |             if (ct != null) | ||||||
|  |                 return await _httpClient.SendAsync(requestMessage, ct.Value).ConfigureAwait(false); | ||||||
|  |             return await _httpClient.SendAsync(requestMessage).ConfigureAwait(false); | ||||||
|  |         } | ||||||
|  |         catch (Exception ex) | ||||||
|  |         { | ||||||
|  |             Logger.Error("Error during SendRequestInternal for " + requestMessage.RequestUri, ex); | ||||||
|  |             throw; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private async Task<HttpResponseMessage> SendRequestAsync<T>(HttpMethod method, Uri uri, T content, CancellationToken ct) where T : class |     private async Task<HttpResponseMessage> SendRequestAsync<T>(HttpMethod method, Uri uri, T content, CancellationToken ct) where T : class | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 rootdarkarchon
					rootdarkarchon