protected virtual void Dispose(bool disposing) { if (_disposed) { return; } Logger.LogInformation("Disposing socket."); if (disposing) { //first dispose ping/pong and message subscriptions because we don't want to receive those now _pingPongSubscription?.Dispose(); _messageSubscription?.Dispose(); //dispose socket so it fires disconnect event _socket?.Dispose(); //now dispose disconnect once socket it disposed _disconnectSubscription?.Dispose(); //dispose all events because user should not keep subscriptions or create new ones Events?.Dispose(); } _disposed = true; }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { _ws?.Dispose(); _pingEventsSource?.OnCompleted(); _pingEventsSource?.Dispose(); _connectedEventSource?.OnCompleted(); _connectedEventSource?.Dispose(); _messageEventsSource?.OnCompleted(); _messageEventsSource?.Dispose(); _errorEventsSource?.OnCompleted(); _errorEventsSource?.Dispose(); foreach (var taskCompletionSource in _operations) { // TODO: custom exception taskCompletionSource.Value.TrySetException(new Exception("Client disposed.")); } _operations.Clear(); foreach (var channel in _channels) { channel.Value.Dispose(); } _channels.Clear(); }
public void Dispose() { _websocketClient?.Dispose(); _connected = false; _timer.Stop(); _timer.Dispose(); _blockTree.NewHeadBlock -= BlockTreeOnNewHeadBlock; _timer.Elapsed -= TimerOnElapsed; }
public virtual void Dispose() { if (_websocketClient != null) { _websocketClient.ConnectionEvent -= OnConnectionEvent; _websocketClient.MessageEvent -= OnMessageEvent; _websocketClient.ErrorEvent -= OnErrorEvent; _websocketClient.Dispose(); } }
public async Task <bool> Disconnect() { try { await Client.Stop(WebSocketCloseStatus.Empty, string.Empty); PubSubPingTimer.Dispose(); Client.Dispose(); return(true); } catch { return(false); } }
protected virtual void Dispose(bool disposing) { if (!isDisposed) { if (disposing) { _client?.Dispose(); _client = null; } isDisposed = true; } }
public void Dispose() { _connected = false; _blockTree.NewHeadBlock -= BlockTreeOnNewHeadBlock; Timer?timer = _timer; if (timer is not null) { timer.Elapsed -= TimerOnElapsed; timer.Stop(); timer.Dispose(); } _websocketClient?.Dispose(); }
public void Dispose() { webSocketClient.Dispose(); }
public void Dispose() { _client?.Dispose(); }
public Task DisconnectAsync() { _client?.Dispose(); return(Task.CompletedTask); }