@@ -81,7 +81,7 @@ public OpenClient(string host, int port, TimeSpan heartbeatInerval, int maxReque
8181 public int MaxRequestPerSecond { get ; }
8282
8383 /// <summary>
84- /// If client is connected via websocket then this will return True, otherwise False
84+ /// If client is connected via Websocket then this will return True, otherwise False
8585 /// </summary>
8686 public bool IsUsingWebSocket { get ; }
8787
@@ -111,7 +111,7 @@ public OpenClient(string host, int port, TimeSpan heartbeatInerval, int maxReque
111111 public int MessagesQueueCount { get ; private set ; }
112112
113113 /// <summary>
114- /// Connects to the API based on you specified method (websocket or TCP)
114+ /// Connects to the API based on you specified method (Websocket or TCP)
115115 /// </summary>
116116 /// <exception cref="ObjectDisposedException">If client is disposed</exception>
117117 /// <exception cref="ConnectionException">If connection attempt fails, the client will be disposed and this exception will be thrown</exception>
@@ -154,9 +154,11 @@ public IDisposable Subscribe(IObserver<IMessage> observer)
154154 {
155155 ThrowObjectDisposedExceptionIfDisposed ( ) ;
156156
157- _observers . AddOrUpdate ( observer . GetHashCode ( ) , observer , ( key , oldObserver ) => observer ) ;
157+ var observerHashCode = observer . GetHashCode ( ) ;
158158
159- return Disposable . Create ( ( ) => OnObserverDispose ( observer ) ) ;
159+ _ = _observers . AddOrUpdate ( observerHashCode , observer , ( key , oldObserver ) => observer ) ;
160+
161+ return Disposable . Create ( ( ) => OnObserverDispose ( observerHashCode ) ) ;
160162 }
161163
162164 /// <summary>
@@ -267,7 +269,7 @@ public void Dispose()
267269
268270 _cancellationTokenSource . Cancel ( ) ;
269271
270- _messagesChannel . Writer . TryComplete ( ) ;
272+ _ = _messagesChannel . Writer . TryComplete ( ) ;
271273
272274 _cancellationTokenSource . Dispose ( ) ;
273275
@@ -291,7 +293,7 @@ public void Dispose()
291293 }
292294
293295 /// <summary>
294- /// Connects to API by using websocket
296+ /// Connects to API by using Websocket
295297 /// </summary>
296298 /// <returns>Task</returns>
297299 private async Task ConnectWebScoket ( )
@@ -433,7 +435,7 @@ private async void ReadTcp(CancellationToken cancellationToken)
433435 /// <summary>
434436 /// Returns the length of a received message without causing extra allocation
435437 /// </summary>
436- /// <param name="lengthBytes">The byte arrary of received lenght data</param>
438+ /// <param name="lengthBytes">The byte array of received length data</param>
437439 /// <returns>int</returns>
438440 private int GetLength ( byte [ ] lengthBytes )
439441 {
@@ -492,10 +494,10 @@ private void OnWebSocketDisconnectionHappened(DisconnectionInfo disconnectionInf
492494 /// <summary>
493495 /// Removes the disposed observer from client observers collection
494496 /// </summary>
495- /// <param name="observer"> </param>
496- private void OnObserverDispose ( IObserver < IMessage > observer )
497+ /// <param name="observerKey">The observer hash code key </param>
498+ private void OnObserverDispose ( int observerKey )
497499 {
498- _observers . TryRemove ( observer . GetHashCode ( ) , out _ ) ;
500+ _ = _observers . TryRemove ( observerKey , out _ ) ;
499501 }
500502
501503 /// <summary>
0 commit comments