Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        public TdClient(
            TdJsonClient tdJsonClient)
        {
            _tdJsonClient = tdJsonClient;

            _tasks = new ConcurrentDictionary <int, Action <TdApi.Object> >();

            _receiver           = new Receiver(tdJsonClient);
            _receiver.Received += OnReceived;
            _receiver.Start();
        }
Ejemplo n.º 3
0
        /// <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;
            }
        }