public TdClient(ITdLibBindings bindings) { _tdJsonClient = new TdJsonClient(bindings); _tasks = new ConcurrentDictionary <int, Action <TdApi.Object> >(); _receiver = new Receiver(_tdJsonClient); _receiver.Received += OnReceived; _receiver.AuthorizationStateChanged += OnAuthorizationStateChanged; }
public TdClient( TdJsonClient tdJsonClient) { _tdJsonClient = tdJsonClient; _tasks = new ConcurrentDictionary <int, Action <TdApi.Object> >(); _receiver = new Receiver(tdJsonClient); _receiver.Received += OnReceived; _receiver.Start(); }
/// <summary> /// Disposes client and json client /// Updates are stopped from being sent to updates handler /// </summary> public void Dispose() { lock (_disposeLock) { if (_receiver == null || _tdJsonClient == null) { return; } CloseSynchronously(); _receiver.Dispose(); _receiver.Received -= OnReceived; _receiver.AuthorizationStateChanged -= OnAuthorizationStateChanged; _receiver = null; _tdJsonClient.Dispose(); _tdJsonClient = null; } }