diff --git a/ChangeLog.md b/ChangeLog.md index a6d0781..795792c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,7 @@ +### 0.9.3 / 2018-05-04 + +* Add proxy support + ### 0.9.2 / 2018-05-04 * Fix some potential deadlocks diff --git a/bin/console b/bin/console new file mode 100755 index 0000000..6942a29 --- /dev/null +++ b/bin/console @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +require 'bundler/setup' +require 'tdlib-ruby' + +TD.configure do |config| + config.lib_path = File.join(File.expand_path("#{TD.root_path}/../"), 'td', 'build') + + config.client.api_id = ENV['TD_API_ID'] + config.client.api_hash = ENV['TD_API_HASH'] + config.client.use_test_dc = true +end + +TD::Api.set_log_verbosity_level(1) + +require 'irb' +IRB.start(__FILE__) diff --git a/lib/tdlib/client.rb b/lib/tdlib/client.rb index 545cdc8..d85024d 100644 --- a/lib/tdlib/client.rb +++ b/lib/tdlib/client.rb @@ -62,10 +62,12 @@ class TD::Client def initialize(td_client = TD::Api.client_create, update_manager = TD::UpdateManager.new(td_client), + proxy: { '@type' => 'proxyEmpty' }, **extra_config) @td_client = td_client @update_manager = update_manager @config = TD.config.client.to_h.merge(extra_config) + @proxy = proxy @ready_condition_mutex = Mutex.new @ready_condition = ConditionVariable.new authorize @@ -98,9 +100,10 @@ def broadcast_and_receive(query, timeout: TIMEOUT) result = nil mutex = Mutex.new handler = ->(update) do - next unless update['@extra'] == extra + return unless update['@extra'] == extra mutex.synchronize do result = update + @update_manager.remove_handler(handler) condition.signal end end @@ -174,6 +177,7 @@ def authorize when 'authorizationStateWaitEncryptionKey' broadcast(encryption_key_query) else + broadcast('@type' => 'setProxy', 'proxy' => @proxy) @update_manager.remove_handler(handler) @ready_condition_mutex.synchronize do @ready = true diff --git a/lib/tdlib/version.rb b/lib/tdlib/version.rb index 1be5f88..53f1176 100644 --- a/lib/tdlib/version.rb +++ b/lib/tdlib/version.rb @@ -1,4 +1,4 @@ module TD # tdlib-ruby version - VERSION = "0.9.2" + VERSION = "0.9.3" end diff --git a/tdlib-ruby.gemspec b/tdlib-ruby.gemspec index a31417e..d11c4cb 100644 --- a/tdlib-ruby.gemspec +++ b/tdlib-ruby.gemspec @@ -30,7 +30,6 @@ Gem::Specification.new do |gem| gem.require_paths = ['lib'] gem.add_runtime_dependency 'dry-configurable', '~> 0.7' - gem.add_runtime_dependency 'celluloid', '~> 0.17' gem.add_development_dependency 'bundler', '~> 1.10' gem.add_development_dependency 'rake', '12.3.1'