pubnub 4.0.5 → 4.0.6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pubnub might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +6 -6
- data/VERSION +1 -1
- data/fixtures/vcr_cassettes/lib/events/subscribe-channel-groups.yml +77 -0
- data/fixtures/vcr_cassettes/lib/events/subscribe-with-presence.yml +78 -0
- data/lib/pubnub/client.rb +0 -2
- data/lib/pubnub/event.rb +11 -9
- data/lib/pubnub/version.rb +1 -1
- data/spec/lib/events/subscribe_spec.rb +68 -4
- metadata +4 -3
- data/lib/pubnub/client/connections.rb +0 -80
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 768a2d3986e2ec06209a0d5c7e230b06b8faedfb
|
4
|
+
data.tar.gz: d87f33805d875aedc89ebd7f6217549fd3bf04fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca31a6b9ba2d4010202a1781b4c166009d13d45266e27c321ccb4e065f4709968507bed3eb4dd215f9ad815757941dcb0b2efdcfc0d2842580326e0e747194e9
|
7
|
+
data.tar.gz: 17b248c0103838208a7cf96fc2764a29c298ae71ae529183ed9921b4a87d955c3115cf50cf81ffe8c09db07f3927b2d0f03d1b74ca0f8cbd2aaac0684d33ff5f
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pubnub (4.0.
|
4
|
+
pubnub (4.0.5)
|
5
5
|
celluloid (~> 0.17)
|
6
6
|
dry-validation (~> 0.8)
|
7
7
|
httpclient (~> 2.8)
|
@@ -42,7 +42,7 @@ GEM
|
|
42
42
|
safe_yaml (~> 1.0.0)
|
43
43
|
diff-lcs (1.2.5)
|
44
44
|
docile (1.1.5)
|
45
|
-
dry-configurable (0.1.
|
45
|
+
dry-configurable (0.1.7)
|
46
46
|
concurrent-ruby (~> 1.0)
|
47
47
|
dry-container (0.3.4)
|
48
48
|
concurrent-ruby (~> 1.0)
|
@@ -52,7 +52,7 @@ GEM
|
|
52
52
|
dry-container (~> 0.2, >= 0.2.6)
|
53
53
|
dry-equalizer (~> 0.2)
|
54
54
|
dry-monads (0.0.2)
|
55
|
-
dry-types (0.8.
|
55
|
+
dry-types (0.8.1)
|
56
56
|
concurrent-ruby (~> 1.0)
|
57
57
|
dry-configurable (~> 0.1)
|
58
58
|
dry-container (~> 0.3)
|
@@ -61,16 +61,16 @@ GEM
|
|
61
61
|
dry-monads (>= 0.0.1)
|
62
62
|
ice_nine (~> 0.11)
|
63
63
|
inflecto (~> 0.0.0, >= 0.0.2)
|
64
|
-
dry-validation (0.
|
64
|
+
dry-validation (0.9.3)
|
65
65
|
concurrent-ruby (~> 1.0)
|
66
66
|
dry-configurable (~> 0.1, >= 0.1.3)
|
67
67
|
dry-container (~> 0.2, >= 0.2.8)
|
68
68
|
dry-equalizer (~> 0.2)
|
69
69
|
dry-logic (~> 0.3, >= 0.3.0)
|
70
|
-
dry-types (~> 0.8, >= 0.8.
|
70
|
+
dry-types (~> 0.8, >= 0.8.1)
|
71
71
|
ffi (1.9.10-java)
|
72
72
|
hitimes (1.2.4)
|
73
|
-
httpclient (2.8.
|
73
|
+
httpclient (2.8.1)
|
74
74
|
ice_nine (0.11.2)
|
75
75
|
inflecto (0.0.2)
|
76
76
|
json (1.8.3)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.0.
|
1
|
+
4.0.6
|
@@ -0,0 +1,77 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://pubsub.pubnub.com/v2/subscribe/sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f/,/0?auth=ruby-test-auth&channel-group=demo&pnsdk=PubNub-Ruby/4.0.5&t=%7B%22r%22:0,%22t%22:0%7D&uuid=ruby-test-uuid
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- HTTPClient/1.0 (2.8.1, ruby 2.3.1 (2016-04-26))
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
Date:
|
15
|
+
- Wed, 10 Aug 2016 20:56:18 GMT
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Wed, 10 Aug 2016 20:56:19 GMT
|
23
|
+
Content-Type:
|
24
|
+
- text/javascript; charset="UTF-8"
|
25
|
+
Content-Length:
|
26
|
+
- '44'
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
Cache-Control:
|
30
|
+
- no-cache
|
31
|
+
Access-Control-Allow-Origin:
|
32
|
+
- "*"
|
33
|
+
Access-Control-Allow-Methods:
|
34
|
+
- GET
|
35
|
+
body:
|
36
|
+
encoding: UTF-8
|
37
|
+
string: '{"t":{"t":"14708625795088197","r":2},"m":[]}'
|
38
|
+
http_version:
|
39
|
+
recorded_at: Wed, 10 Aug 2016 20:56:19 GMT
|
40
|
+
- request:
|
41
|
+
method: get
|
42
|
+
uri: http://pubsub.pubnub.com/v2/subscribe/sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f/,/0?auth=ruby-test-auth&channel-group=demo&pnsdk=PubNub-Ruby/4.0.5&t=%7B%22r%22:2,%22t%22:%2214708625795088197%22%7D&uuid=ruby-test-uuid
|
43
|
+
body:
|
44
|
+
encoding: UTF-8
|
45
|
+
string: ''
|
46
|
+
headers:
|
47
|
+
User-Agent:
|
48
|
+
- HTTPClient/1.0 (2.8.1, ruby 2.3.1 (2016-04-26))
|
49
|
+
Accept:
|
50
|
+
- "*/*"
|
51
|
+
Date:
|
52
|
+
- Wed, 10 Aug 2016 20:56:19 GMT
|
53
|
+
response:
|
54
|
+
status:
|
55
|
+
code: 200
|
56
|
+
message: OK
|
57
|
+
headers:
|
58
|
+
Date:
|
59
|
+
- Wed, 10 Aug 2016 20:56:23 GMT
|
60
|
+
Content-Type:
|
61
|
+
- text/javascript; charset="UTF-8"
|
62
|
+
Content-Length:
|
63
|
+
- '260'
|
64
|
+
Connection:
|
65
|
+
- keep-alive
|
66
|
+
Cache-Control:
|
67
|
+
- no-cache
|
68
|
+
Access-Control-Allow-Origin:
|
69
|
+
- "*"
|
70
|
+
Access-Control-Allow-Methods:
|
71
|
+
- GET
|
72
|
+
body:
|
73
|
+
encoding: UTF-8
|
74
|
+
string: '{"t":{"t":"14708625831727907","r":2},"m":[{"a":"5","f":0,"i":"53a9d412-e062-4c9b-9d0f-63661107a3eb","s":1,"o":{"t":"14708625829775958"},"p":{"t":"14708625831717419","r":2},"k":"sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f","c":"demo","d":"whatever","b":"demo"}]}'
|
75
|
+
http_version:
|
76
|
+
recorded_at: Wed, 10 Aug 2016 20:56:23 GMT
|
77
|
+
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,78 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://pubsub.pubnub.com/v2/subscribe/sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f/demo,demo-pnpres,demo.*,demo.*-pnpres,demo1,demo1-pnpres/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.0.5&t=%7B%22r%22:0,%22t%22:0%7D&uuid=ruby-test-uuid
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- HTTPClient/1.0 (2.8.1, ruby 2.3.1 (2016-04-26))
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
Date:
|
15
|
+
- Wed, 10 Aug 2016 13:00:56 GMT
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Wed, 10 Aug 2016 13:00:57 GMT
|
23
|
+
Content-Type:
|
24
|
+
- text/javascript; charset="UTF-8"
|
25
|
+
Content-Length:
|
26
|
+
- '44'
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
Cache-Control:
|
30
|
+
- no-cache
|
31
|
+
Access-Control-Allow-Origin:
|
32
|
+
- "*"
|
33
|
+
Access-Control-Allow-Methods:
|
34
|
+
- GET
|
35
|
+
body:
|
36
|
+
encoding: UTF-8
|
37
|
+
string: '{"t":{"t":"14708340574849564","r":2},"m":[]}'
|
38
|
+
http_version:
|
39
|
+
recorded_at: Wed, 10 Aug 2016 13:00:57 GMT
|
40
|
+
- request:
|
41
|
+
method: get
|
42
|
+
uri: http://pubsub.pubnub.com/v2/subscribe/sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f/demo,demo-pnpres,demo.*,demo.*-pnpres,demo1,demo1-pnpres/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.0.5&t=%7B%22r%22:2,%22t%22:%2214708340574849564%22%7D&uuid=ruby-test-uuid
|
43
|
+
body:
|
44
|
+
encoding: UTF-8
|
45
|
+
string: ''
|
46
|
+
headers:
|
47
|
+
User-Agent:
|
48
|
+
- HTTPClient/1.0 (2.8.1, ruby 2.3.1 (2016-04-26))
|
49
|
+
Accept:
|
50
|
+
- "*/*"
|
51
|
+
Date:
|
52
|
+
- Wed, 10 Aug 2016 13:00:57 GMT
|
53
|
+
response:
|
54
|
+
status:
|
55
|
+
code: 200
|
56
|
+
message: OK
|
57
|
+
headers:
|
58
|
+
Date:
|
59
|
+
- Wed, 10 Aug 2016 13:00:58 GMT
|
60
|
+
Content-Type:
|
61
|
+
- text/javascript; charset="UTF-8"
|
62
|
+
Content-Length:
|
63
|
+
- '272'
|
64
|
+
Connection:
|
65
|
+
- keep-alive
|
66
|
+
Cache-Control:
|
67
|
+
- no-cache
|
68
|
+
Access-Control-Allow-Origin:
|
69
|
+
- "*"
|
70
|
+
Access-Control-Allow-Methods:
|
71
|
+
- GET
|
72
|
+
body:
|
73
|
+
encoding: UTF-8
|
74
|
+
string: '{"t":{"t":"14708340581394476","r":2},"m":[{"a":"5","f":0,"p":{"t":"14708340580815003","r":1},"k":"sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f","c":"demo1-pnpres","d":{"action":
|
75
|
+
"join", "timestamp": 1470834058, "uuid": "ruby-test-uuid", "occupancy": 1},"b":"demo1-pnpres"}]}'
|
76
|
+
http_version:
|
77
|
+
recorded_at: Wed, 10 Aug 2016 13:00:58 GMT
|
78
|
+
recorded_with: VCR 3.0.1
|
data/lib/pubnub/client.rb
CHANGED
@@ -24,7 +24,6 @@ require 'pubnub/subscriber'
|
|
24
24
|
require 'pubnub/envelope'
|
25
25
|
require 'pubnub/error_envelope'
|
26
26
|
|
27
|
-
require 'pubnub/client/connections'
|
28
27
|
require 'pubnub/client/events'
|
29
28
|
require 'pubnub/client/paged_history'
|
30
29
|
require 'pubnub/client/helpers'
|
@@ -68,7 +67,6 @@ module Pubnub
|
|
68
67
|
# Pubnub client Class.
|
69
68
|
class Client
|
70
69
|
include Configuration
|
71
|
-
include Connections
|
72
70
|
include Events
|
73
71
|
include PagedHistory
|
74
72
|
include Helpers
|
data/lib/pubnub/event.rb
CHANGED
@@ -3,12 +3,13 @@ module Pubnub
|
|
3
3
|
# Event module holds most basic and required infrastructure for every pubnub
|
4
4
|
# event, there are also SingleEvent module and SubscribeEvent module
|
5
5
|
class Event
|
6
|
-
attr_reader :origin, :callback, :channel, :fresh_clone,
|
6
|
+
attr_reader :origin, :callback, :channel, :channel_group, :fresh_clone,
|
7
7
|
:open_timeout, :read_timeout, :idle_timeout, :group,
|
8
8
|
:presence_callback, :wildcard_channel, :ssl, :state,
|
9
|
-
:given_options
|
9
|
+
:given_options, :with_presence
|
10
10
|
|
11
11
|
alias_method :channels, :channel
|
12
|
+
alias_method :channel_groups, :channel_group
|
12
13
|
|
13
14
|
def initialize(options, app)
|
14
15
|
@app = app
|
@@ -73,8 +74,9 @@ module Pubnub
|
|
73
74
|
end
|
74
75
|
|
75
76
|
def format_channels
|
76
|
-
@channel =
|
77
|
+
@channel = Formatter.format_channel(@channel || @channels)
|
77
78
|
@channel += Formatter.format_presence_channel(@presence)
|
79
|
+
@channel += Formatter.format_presence_channel(@channel || @channels) if @with_presence
|
78
80
|
@wildcard_channel = @channel.select { |e| e.index('.*') } || []
|
79
81
|
end
|
80
82
|
|
@@ -104,9 +106,9 @@ module Pubnub
|
|
104
106
|
@envelopes = format_envelopes response, request
|
105
107
|
end
|
106
108
|
|
107
|
-
def connection
|
108
|
-
|
109
|
-
end
|
109
|
+
# def connection
|
110
|
+
# @app.connection_for(self)
|
111
|
+
# end
|
110
112
|
|
111
113
|
def create_variables_from_options(options)
|
112
114
|
variables = %w(channel channels message http_sync callback
|
@@ -115,8 +117,8 @@ module Pubnub
|
|
115
117
|
open_timeout read_timeout idle_timeout heartbeat
|
116
118
|
group action read write manage ttl presence start
|
117
119
|
end count reverse presence_callback store skip_validate
|
118
|
-
state channel_group compressed meta customs include_token
|
119
|
-
replicate)
|
120
|
+
state channel_group channel_groups compressed meta customs include_token
|
121
|
+
replicate with_presence)
|
120
122
|
|
121
123
|
options = options.each_with_object({}) { |option, obj| obj[option.first.to_sym] = option.last }
|
122
124
|
|
@@ -130,7 +132,7 @@ module Pubnub
|
|
130
132
|
end
|
131
133
|
|
132
134
|
def format_group
|
133
|
-
@group = @channel_group if @channel_group && @group.blank?
|
135
|
+
@group = (@channel_group || @channel_groups) if (@channel_group || @channel_groups) && @group.blank?
|
134
136
|
@group = Formatter.format_group(@group)
|
135
137
|
|
136
138
|
if @group.first.to_s.count(':') > 0
|
data/lib/pubnub/version.rb
CHANGED
@@ -15,9 +15,9 @@ describe Pubnub::Subscribe do
|
|
15
15
|
@statuses = []
|
16
16
|
|
17
17
|
@callbacks = Pubnub::SubscribeCallback.new(
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
message: ->(envelope) { @messages << envelope },
|
19
|
+
presence: ->(_envelope) {},
|
20
|
+
status: ->(envelope) { @statuses << envelope }
|
21
21
|
)
|
22
22
|
end
|
23
23
|
|
@@ -117,7 +117,7 @@ describe Pubnub::Subscribe do
|
|
117
117
|
|
118
118
|
VCR.use_cassette('lib/events/subscribe-cipher-async', record: :once) do
|
119
119
|
@pubnub.subscribe(channel: :whatever, http_sync: true)
|
120
|
-
@messages =
|
120
|
+
@messages = @pubnub.subscribe(channel: :whatever, http_sync: true)
|
121
121
|
eventually do
|
122
122
|
expect(@messages.first.result[:data][:message]).to eq('text' => 'hey')
|
123
123
|
end
|
@@ -165,5 +165,69 @@ describe Pubnub::Subscribe do
|
|
165
165
|
end
|
166
166
|
end
|
167
167
|
end
|
168
|
+
|
169
|
+
context 'aliases' do
|
170
|
+
it 'pass channels to channel' do
|
171
|
+
VCR.use_cassette('lib/events/subscribe-sync', record: :once) do
|
172
|
+
@pubnub = Pubnub::Client.new(
|
173
|
+
subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
|
174
|
+
publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
|
175
|
+
secret_key: 'sec-c-OWIyYmVlYWYtYWMxMS00OTcxLTlhZDAtZDBlYTM4ODE1MWUy',
|
176
|
+
auth_key: 'ruby-test-auth',
|
177
|
+
uuid: 'ruby-test-uuid'
|
178
|
+
)
|
179
|
+
|
180
|
+
@pubnub.subscribe(channels: :demo, http_sync: true)
|
181
|
+
envelopes = @pubnub.subscribe(channels: :demo, http_sync: true)
|
182
|
+
|
183
|
+
|
184
|
+
envelope = envelopes.first
|
185
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
|
186
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema
|
187
|
+
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'pass channel_groups to channel_group' do
|
192
|
+
VCR.use_cassette('lib/events/subscribe-channel-groups', record: :once) do
|
193
|
+
|
194
|
+
@pubnub = Pubnub::Client.new(
|
195
|
+
subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
|
196
|
+
publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
|
197
|
+
secret_key: 'sec-c-OWIyYmVlYWYtYWMxMS00OTcxLTlhZDAtZDBlYTM4ODE1MWUy',
|
198
|
+
auth_key: 'ruby-test-auth',
|
199
|
+
uuid: 'ruby-test-uuid'
|
200
|
+
)
|
201
|
+
|
202
|
+
@pubnub.subscribe(channel_groups: :demo, http_sync: true)
|
203
|
+
envelopes = @pubnub.subscribe(channel_groups: :demo, http_sync: true)
|
204
|
+
|
205
|
+
envelope = envelopes.first
|
206
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
|
207
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
context 'flags' do
|
213
|
+
it 'with with_presence' do
|
214
|
+
VCR.use_cassette('lib/events/subscribe-with-presence', record: :once) do
|
215
|
+
@pubnub = Pubnub::Client.new(
|
216
|
+
subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
|
217
|
+
publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
|
218
|
+
secret_key: 'sec-c-OWIyYmVlYWYtYWMxMS00OTcxLTlhZDAtZDBlYTM4ODE1MWUy',
|
219
|
+
auth_key: 'ruby-test-auth',
|
220
|
+
uuid: 'ruby-test-uuid'
|
221
|
+
)
|
222
|
+
|
223
|
+
@pubnub.subscribe(channels: [:demo, :demo1, 'demo.*'], with_presence: true, http_sync: true)
|
224
|
+
envelopes = @pubnub.subscribe(channels: [:demo, :demo1, 'demo.*'], with_presence: true, http_sync: true)
|
225
|
+
|
226
|
+
envelope = envelopes.first
|
227
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
|
228
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
168
232
|
end
|
169
233
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubnub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PubNub
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|
@@ -10453,10 +10453,12 @@ files:
|
|
10453
10453
|
- fixtures/vcr_cassettes/lib/events/state.yml
|
10454
10454
|
- fixtures/vcr_cassettes/lib/events/subscribe-async-error.yml
|
10455
10455
|
- fixtures/vcr_cassettes/lib/events/subscribe-async.yml
|
10456
|
+
- fixtures/vcr_cassettes/lib/events/subscribe-channel-groups.yml
|
10456
10457
|
- fixtures/vcr_cassettes/lib/events/subscribe-cipher-async.yml
|
10457
10458
|
- fixtures/vcr_cassettes/lib/events/subscribe-playing-async.yml
|
10458
10459
|
- fixtures/vcr_cassettes/lib/events/subscribe-sync-error.yml
|
10459
10460
|
- fixtures/vcr_cassettes/lib/events/subscribe-sync.yml
|
10461
|
+
- fixtures/vcr_cassettes/lib/events/subscribe-with-presence.yml
|
10460
10462
|
- fixtures/vcr_cassettes/lib/events/time-error.yml
|
10461
10463
|
- fixtures/vcr_cassettes/lib/events/time.yml
|
10462
10464
|
- fixtures/vcr_cassettes/lib/events/where-now-error.yml
|
@@ -10464,7 +10466,6 @@ files:
|
|
10464
10466
|
- fixtures/vcr_cassettes/test_examples/audit-158_http_sync_true_callback_block_channel_channel_auth-key_key.yml
|
10465
10467
|
- lib/pubnub.rb
|
10466
10468
|
- lib/pubnub/client.rb
|
10467
|
-
- lib/pubnub/client/connections.rb
|
10468
10469
|
- lib/pubnub/client/events.rb
|
10469
10470
|
- lib/pubnub/client/helpers.rb
|
10470
10471
|
- lib/pubnub/client/paged_history.rb
|
@@ -1,80 +0,0 @@
|
|
1
|
-
# Toplevel Pubnub module.
|
2
|
-
module Pubnub
|
3
|
-
# Pubnub client Class
|
4
|
-
class Client
|
5
|
-
# Module that holds methods that helps us with connections
|
6
|
-
# management. Must be plugged into Client class, uses @env
|
7
|
-
module Connections
|
8
|
-
def setup_conn_for(event)
|
9
|
-
if event.is_a? SingleEvent
|
10
|
-
setup_conn_for_single_event(event)
|
11
|
-
elsif event.is_a? SubscribeEvent
|
12
|
-
setup_conn_for_subscribe_event(event)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def setup_conn_for_single_event(event)
|
19
|
-
conn = Net::HTTP::Persistent.new "pn_client_v#{Pubnub::VERSION}"
|
20
|
-
conn.proxy_from_env
|
21
|
-
conn.read_timeout = event.read_timeout || @env[:read_timeout]
|
22
|
-
conn.open_timeout = event.open_timeout || @env[:open_timeout]
|
23
|
-
conn.idle_timeout = event.idle_timeout || @env[:idle_timeout]
|
24
|
-
@env[:single_event_conn_pool][event.origin] = conn
|
25
|
-
end
|
26
|
-
|
27
|
-
def setup_conn_for_subscribe_event(event)
|
28
|
-
conn = Net::HTTP::Persistent.new "pn_client_v#{Pubnub::VERSION}"
|
29
|
-
conn.proxy_from_env
|
30
|
-
conn.read_timeout = event.read_timeout || @env[:s_read_timeout]
|
31
|
-
conn.open_timeout = event.open_timeout || @env[:s_open_timeout]
|
32
|
-
conn.idle_timeout = event.idle_timeout || @env[:s_idle_timeout]
|
33
|
-
@env[:subscribe_event_conn_pool][event.origin] = conn
|
34
|
-
end
|
35
|
-
|
36
|
-
def setup_conn_for_heartbeat_event(event)
|
37
|
-
conn = Net::HTTP::Persistent.new "pn_client_v#{Pubnub::VERSION}"
|
38
|
-
conn.proxy_from_env
|
39
|
-
conn.read_timeout = event.read_timeout || @env[:h_read_timeout]
|
40
|
-
conn.open_timeout = event.open_timeout || @env[:h_open_timeout]
|
41
|
-
conn.idle_timeout = event.idle_timeout || @env[:h_idle_timeout]
|
42
|
-
@env[:heartbeat_event_conn_pool][event.origin] = conn
|
43
|
-
end
|
44
|
-
|
45
|
-
def connection_for(event)
|
46
|
-
case event.class
|
47
|
-
when SingleEvent then single_event_connection
|
48
|
-
when SubscribeEvent then subscribe_event_connection
|
49
|
-
when HeartbeatEvent then heartbeat_event_connection
|
50
|
-
else rise_connection_for_error
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def rise_connection_for_error
|
55
|
-
fail(Pubnub::Error.new(
|
56
|
-
env: @env,
|
57
|
-
operation: 'Pubnub.client#connection_for',
|
58
|
-
app: self,
|
59
|
-
error_type: 'Internal Error',
|
60
|
-
message: 'Can\'t recognize event'
|
61
|
-
), 'Can\'t recognize event')
|
62
|
-
end
|
63
|
-
|
64
|
-
def single_event_connection
|
65
|
-
@env[:single_event_conn_pool][event.origin] ||
|
66
|
-
setup_conn_for(event)
|
67
|
-
end
|
68
|
-
|
69
|
-
def subscribe_event_connection
|
70
|
-
@env[:subscribe_event_conn_pool][event.origin] ||
|
71
|
-
setup_conn_for(event)
|
72
|
-
end
|
73
|
-
|
74
|
-
def heartbeat_event_connection
|
75
|
-
@env[:heartbeat_event_conn_pool][event.origin] ||
|
76
|
-
setup_conn_for(event)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|