tdlib-ruby 0.4.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +4 -0
- data/lib/tdlib/client.rb +12 -9
- data/lib/tdlib/update_manager.rb +6 -7
- data/lib/tdlib/version.rb +1 -1
- data/spec/support/update_manager_stub.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ae3602c33ec3fcc94afe086dfa85572d59d851b
|
4
|
+
data.tar.gz: 219b93cf45f05b909e276b6534b89be70a00f834
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f24b6e7d8c1821d00db49b1e45f653f040bb31e792cc46871c2789ba5e3f62de28f2eaa3a2921d3b0929ce502aa17f56093d44b26fe8044d9700c310b24429d
|
7
|
+
data.tar.gz: 42ba3c0ba60e5b7ed0f51be08314e607adf2da3a22c64d0fbaf2a84ee573adfce2d09ac6f1e050152964e7cef5f52595ea33f62a316e5a0be4a36ee4a0492667
|
data/ChangeLog.md
CHANGED
data/lib/tdlib/client.rb
CHANGED
@@ -69,6 +69,7 @@ class TD::Client
|
|
69
69
|
@update_manager = update_manager
|
70
70
|
@config = TD.config.client.to_h.merge(extra_config)
|
71
71
|
authorize
|
72
|
+
@update_manager.run
|
72
73
|
end
|
73
74
|
|
74
75
|
# Sends asynchronous request to the TDLib client
|
@@ -98,12 +99,13 @@ class TD::Client
|
|
98
99
|
@update_manager.add_handler(handler)
|
99
100
|
query['@extra'] = extra
|
100
101
|
TD::Api.client_send(@td_client, query)
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
result
|
102
|
+
time_start = Time.now
|
103
|
+
loop do
|
104
|
+
sleep 0.1
|
105
|
+
break if result
|
106
|
+
raise TD::TimeoutError if Time.now - time_start > timeout
|
105
107
|
end
|
106
|
-
|
108
|
+
result
|
107
109
|
end
|
108
110
|
|
109
111
|
# Synchronously executes TDLib request
|
@@ -131,11 +133,12 @@ class TD::Client
|
|
131
133
|
end
|
132
134
|
|
133
135
|
def on_ready(timeout: TIMEOUT, &_)
|
134
|
-
|
135
|
-
|
136
|
-
|
136
|
+
time_start = Time.now
|
137
|
+
loop do
|
138
|
+
sleep 0.1
|
139
|
+
break if @ready
|
140
|
+
raise TD::TimeoutError if Time.now - time_start > timeout
|
137
141
|
end
|
138
|
-
raise TD::TimeoutError unless promise.execute.then { self }.execute.value(timeout)
|
139
142
|
yield self
|
140
143
|
end
|
141
144
|
|
data/lib/tdlib/update_manager.rb
CHANGED
@@ -5,7 +5,6 @@ class TD::UpdateManager
|
|
5
5
|
@td_client = td_client
|
6
6
|
@handlers = []
|
7
7
|
@mutex = Mutex.new
|
8
|
-
init_update_loop
|
9
8
|
end
|
10
9
|
|
11
10
|
def add_handler(handler)
|
@@ -18,6 +17,12 @@ class TD::UpdateManager
|
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
20
|
+
def run
|
21
|
+
@update_loop_thread = Thread.start do
|
22
|
+
loop { stopped? ? break : handle_update }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
21
26
|
def stop
|
22
27
|
@stopped = true
|
23
28
|
end
|
@@ -28,12 +33,6 @@ class TD::UpdateManager
|
|
28
33
|
|
29
34
|
private
|
30
35
|
|
31
|
-
def init_update_loop
|
32
|
-
@update_loop_thread = Thread.start do
|
33
|
-
loop { stopped? ? break : handle_update }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
36
|
def handle_update
|
38
37
|
update = TD::Api.client_receive(@td_client, 10)
|
39
38
|
@mutex.synchronize do
|
data/lib/tdlib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdlib-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Southbridge
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|