pubnub 4.0.27 → 4.0.28
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/.pubnub.yml +8 -1
- data/.rubocop.yml +9 -3
- data/.travis.yml +6 -19
- data/CHANGELOG.md +86 -82
- data/Gemfile +7 -5
- data/Gemfile.lock +155 -157
- data/README.md +34 -34
- data/VERSION +1 -1
- data/gemfiles/celluloid_017.gemfile +4 -4
- data/gemfiles/celluloid_018.gemfile +4 -4
- data/gemfiles/celluloid_master.gemfile +4 -4
- data/gemfiles/concurrent-ruby-1.0.5.gem +0 -0
- data/gemfiles/concurrent-ruby-edge-0.3.1.gem +0 -0
- data/lib/pubnub.rb +3 -3
- data/lib/pubnub/client.rb +19 -16
- data/lib/pubnub/client/events.rb +5 -5
- data/lib/pubnub/client/getters_setters.rb +11 -12
- data/lib/pubnub/client/paged_history.rb +11 -9
- data/lib/pubnub/configuration.rb +1 -2
- data/lib/pubnub/constants.rb +47 -47
- data/lib/pubnub/crypto.rb +2 -2
- data/lib/pubnub/envelope.rb +7 -5
- data/lib/pubnub/error.rb +22 -15
- data/lib/pubnub/event.rb +24 -25
- data/lib/pubnub/event/formatter.rb +8 -5
- data/lib/pubnub/event/signature.rb +3 -3
- data/lib/pubnub/events/audit.rb +1 -1
- data/lib/pubnub/events/channel_registration.rb +10 -15
- data/lib/pubnub/events/delete_messages.rb +9 -9
- data/lib/pubnub/events/grant.rb +3 -3
- data/lib/pubnub/events/heartbeat.rb +4 -8
- data/lib/pubnub/events/here_now.rb +4 -8
- data/lib/pubnub/events/history.rb +10 -10
- data/lib/pubnub/events/leave.rb +2 -2
- data/lib/pubnub/events/presence.rb +1 -1
- data/lib/pubnub/events/publish.rb +3 -5
- data/lib/pubnub/events/revoke.rb +3 -3
- data/lib/pubnub/events/set_state.rb +3 -3
- data/lib/pubnub/events/state.rb +4 -6
- data/lib/pubnub/events/subscribe.rb +1 -1
- data/lib/pubnub/events/time.rb +2 -2
- data/lib/pubnub/events/where_now.rb +6 -6
- data/lib/pubnub/format.rb +73 -0
- data/lib/pubnub/formatter.rb +23 -21
- data/lib/pubnub/heart.rb +4 -4
- data/lib/pubnub/origin_manager.rb +3 -5
- data/lib/pubnub/pam.rb +5 -5
- data/lib/pubnub/schemas/envelope_schema.rb +1 -1
- data/lib/pubnub/subscribe_callback.rb +3 -3
- data/lib/pubnub/subscribe_event.rb +6 -10
- data/lib/pubnub/subscribe_event/formatter.rb +82 -80
- data/lib/pubnub/subscribe_event/heartbeat.rb +1 -1
- data/lib/pubnub/subscriber.rb +31 -32
- data/lib/pubnub/telemetry.rb +26 -27
- data/lib/pubnub/validators/audit.rb +3 -2
- data/lib/pubnub/validators/channel_registration.rb +6 -4
- data/lib/pubnub/validators/client.rb +1 -0
- data/lib/pubnub/validators/common_validator.rb +37 -31
- data/lib/pubnub/validators/delete.rb +5 -4
- data/lib/pubnub/validators/grant.rb +3 -2
- data/lib/pubnub/validators/history.rb +3 -2
- data/lib/pubnub/validators/leave.rb +3 -2
- data/lib/pubnub/validators/presence.rb +3 -2
- data/lib/pubnub/validators/publish.rb +15 -10
- data/lib/pubnub/validators/set_state.rb +0 -2
- data/lib/pubnub/validators/state.rb +3 -2
- data/lib/pubnub/version.rb +1 -1
- data/pubnub.gemspec +19 -18
- data/spec/examples/audit_examples_spec.rb +1268 -1418
- data/spec/examples/channel_registration_examples_spec.rb +655 -757
- data/spec/examples/delete_messages_examples_spec.rb +19 -21
- data/spec/examples/grant_examples_spec.rb +34028 -37920
- data/spec/examples/heartbeat_examples_spec.rb +583 -731
- data/spec/examples/here_now_examples_spec.rb +493 -569
- data/spec/examples/history_examples_spec.rb +979 -1127
- data/spec/examples/leave_examples_spec.rb +439 -551
- data/spec/examples/presence_examples_spec.rb +686 -830
- data/spec/examples/publish_examples_spec.rb +27223 -31547
- data/spec/examples/publish_with_ttl_spec.rb +11 -14
- data/spec/examples/revoke_examples_spec.rb +68048 -75828
- data/spec/examples/set_state_examples_spec.rb +295 -371
- data/spec/examples/state_examples_spec.rb +169 -197
- data/spec/examples/status_request_message_count_exceeded_spec.rb +16 -19
- data/spec/examples/subscribe_examples_spec.rb +43843 -52035
- data/spec/examples/time_examples_spec.rb +82 -98
- data/spec/examples/where_now_examples_spec.rb +88 -104
- data/spec/lib/client_spec.rb +99 -117
- data/spec/lib/connection_callback_spec.rb +27 -33
- data/spec/lib/custom_retries_examples_spec.rb +8 -11
- data/spec/lib/event_spec.rb +35 -42
- data/spec/lib/events/audit_spec.rb +19 -25
- data/spec/lib/events/channel_registration_spec.rb +17 -23
- data/spec/lib/events/delete_messages_spec.rb +14 -20
- data/spec/lib/events/grant_spec.rb +15 -21
- data/spec/lib/events/heartbeat_spec.rb +21 -27
- data/spec/lib/events/here_now_spec.rb +14 -20
- data/spec/lib/events/history_spec.rb +14 -20
- data/spec/lib/events/leave_spec.rb +14 -20
- data/spec/lib/events/presence_delta_spec.rb +15 -16
- data/spec/lib/events/presence_spec.rb +36 -45
- data/spec/lib/events/publish_spec.rb +33 -40
- data/spec/lib/events/revoke_spec.rb +16 -22
- data/spec/lib/events/state_spec.rb +16 -22
- data/spec/lib/events/subscribe_spec.rb +75 -85
- data/spec/lib/events/time_spec.rb +12 -18
- data/spec/lib/events/timeout_handling_spec.rb +8 -14
- data/spec/lib/events/where_now_spec.rb +14 -20
- data/spec/lib/keep_alive_spec.rb +4 -8
- data/spec/lib/multiple_ciphers_spec.rb +56 -60
- data/spec/lib/pubnub_spec.rb +10 -13
- data/spec/lib/signatures_spec.rb +118 -120
- data/spec/lib/ssl_error_spec.rb +14 -18
- data/spec/lib/super_admin_spec.rb +58 -66
- data/spec/lib/uuid_spec.rb +3 -4
- data/spec/spec_expectations.rb +3 -3
- data/spec/spec_helper.rb +29 -46
- metadata +52 -22
- data/lib/pubnub/message.rb +0 -43
data/README.md
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/b744287bb0324e2883f95525b12cf19f)](https://www.codacy.com/app/blazeroot/ruby?utm_source=github.com&utm_medium=referral&utm_content=pubnub/ruby&utm_campaign=badger)
|
2
|
-
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/b744287bb0324e2883f95525b12cf19f)](https://www.codacy.com/app/blazeroot/ruby?utm_source=github.com&utm_medium=referral&utm_content=pubnub/ruby&utm_campaign=Badge_Coverage)
|
3
|
-
[![Build Status](https://travis-ci.org/pubnub/ruby.svg?branch=master)](https://travis-ci.org/pubnub/ruby)
|
4
|
-
|
5
|
-
# Please direct all Support Questions and Concerns to Support@PubNub.com
|
6
|
-
|
7
|
-
# Complete Documentation
|
8
|
-
Available at https://www.pubnub.com/docs/ruby/pubnub-ruby-sdk-v4 **v4.x**
|
9
|
-
|
10
|
-
## PubNub Gem version 4.0.27
|
11
|
-
|
12
|
-
##### YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API.
|
13
|
-
##### http://www.pubnub.com/account
|
14
|
-
|
15
|
-
www.pubnub.com - PubNub Real-time Push Service in the Cloud.
|
16
|
-
|
17
|
-
|
18
|
-
The PubNub Network is a blazingly fast Global Messaging Service for building real-time web and mobile apps. Thousands of apps and developers rely on PubNub for delivering human-perceptive real-time experiences that scale to millions of users worldwide. PubNub delivers the infrastructure needed to build amazing Mobile, MMO games, social apps, business collaborative solutions, and more.
|
19
|
-
|
20
|
-
### Upgrading from PubNub 3.6.x / 3.7.x
|
21
|
-
|
22
|
-
Main change is that we're no longer using EventMachine. Right now Celluloid is used. Public API remain unchanged.
|
23
|
-
If you encounter any issues while upgrading from EventMachine version, please contact us at support@pubnub.com you can also find eventmachine version in "eventmachine" branch of this repo.
|
24
|
-
|
25
|
-
### Upgrading from PubNub 3.5.x
|
26
|
-
|
27
|
-
We've made the response format compatible across all operations. This may break existing parsing of where_now, leave, state, and PAM responses. So if you are monitoring these operation responses, please be sure to modify your code accordingly.
|
28
|
-
|
29
|
-
Examples of affected operations can be found [here](3.5_to_3.6_upgrade_notes.md).
|
30
|
-
|
31
|
-
### Upgrading from PubNub 3.3.x and Earlier
|
32
|
-
PubNub 3.7.3 is NOT compatible with earlier than 3.4 versions of Pubnub Ruby Client.
|
33
|
-
|
34
|
-
# Please direct all Support Questions and Concerns to Support@PubNub.com
|
1
|
+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/b744287bb0324e2883f95525b12cf19f)](https://www.codacy.com/app/blazeroot/ruby?utm_source=github.com&utm_medium=referral&utm_content=pubnub/ruby&utm_campaign=badger)
|
2
|
+
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/b744287bb0324e2883f95525b12cf19f)](https://www.codacy.com/app/blazeroot/ruby?utm_source=github.com&utm_medium=referral&utm_content=pubnub/ruby&utm_campaign=Badge_Coverage)
|
3
|
+
[![Build Status](https://travis-ci.org/pubnub/ruby.svg?branch=master)](https://travis-ci.org/pubnub/ruby)
|
4
|
+
|
5
|
+
# Please direct all Support Questions and Concerns to Support@PubNub.com
|
6
|
+
|
7
|
+
# Complete Documentation
|
8
|
+
Available at https://www.pubnub.com/docs/ruby/pubnub-ruby-sdk-v4 **v4.x**
|
9
|
+
|
10
|
+
## PubNub Gem version 4.0.27
|
11
|
+
|
12
|
+
##### YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API.
|
13
|
+
##### http://www.pubnub.com/account
|
14
|
+
|
15
|
+
www.pubnub.com - PubNub Real-time Push Service in the Cloud.
|
16
|
+
|
17
|
+
|
18
|
+
The PubNub Network is a blazingly fast Global Messaging Service for building real-time web and mobile apps. Thousands of apps and developers rely on PubNub for delivering human-perceptive real-time experiences that scale to millions of users worldwide. PubNub delivers the infrastructure needed to build amazing Mobile, MMO games, social apps, business collaborative solutions, and more.
|
19
|
+
|
20
|
+
### Upgrading from PubNub 3.6.x / 3.7.x
|
21
|
+
|
22
|
+
Main change is that we're no longer using EventMachine. Right now Celluloid is used. Public API remain unchanged.
|
23
|
+
If you encounter any issues while upgrading from EventMachine version, please contact us at support@pubnub.com you can also find eventmachine version in "eventmachine" branch of this repo.
|
24
|
+
|
25
|
+
### Upgrading from PubNub 3.5.x
|
26
|
+
|
27
|
+
We've made the response format compatible across all operations. This may break existing parsing of where_now, leave, state, and PAM responses. So if you are monitoring these operation responses, please be sure to modify your code accordingly.
|
28
|
+
|
29
|
+
Examples of affected operations can be found [here](3.5_to_3.6_upgrade_notes.md).
|
30
|
+
|
31
|
+
### Upgrading from PubNub 3.3.x and Earlier
|
32
|
+
PubNub 3.7.3 is NOT compatible with earlier than 3.4 versions of Pubnub Ruby Client.
|
33
|
+
|
34
|
+
# Please direct all Support Questions and Concerns to Support@PubNub.com
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.0.
|
1
|
+
4.0.28
|
@@ -9,17 +9,17 @@ gem 'celluloid', '>= 0.17', '< 0.18'
|
|
9
9
|
gem 'dry-validation', '>= 0.10', '< 0.11'
|
10
10
|
|
11
11
|
group :test do
|
12
|
-
gem 'rubocop'
|
13
|
-
gem 'simplecov', '>= 0.12', require: false
|
14
12
|
gem 'codacy-coverage', require: false
|
13
|
+
gem 'rr'
|
15
14
|
gem 'rspec'
|
16
15
|
gem 'rspec-wait'
|
16
|
+
gem 'rubocop'
|
17
|
+
gem 'simplecov', '>= 0.12', require: false
|
17
18
|
gem 'vcr'
|
18
|
-
gem 'rr'
|
19
19
|
gem 'webmock'
|
20
20
|
end
|
21
21
|
|
22
22
|
group :development, :test do
|
23
|
-
gem 'pry'
|
24
23
|
gem 'awesome_print'
|
24
|
+
gem 'pry'
|
25
25
|
end
|
@@ -9,17 +9,17 @@ gem 'celluloid', '>= 0.18.0.pre', '< 0.19'
|
|
9
9
|
gem 'dry-validation', '>= 0.10', '< 0.11'
|
10
10
|
|
11
11
|
group :test do
|
12
|
-
gem 'rubocop'
|
13
|
-
gem 'simplecov', '>= 0.12', require: false
|
14
12
|
gem 'codacy-coverage', require: false
|
13
|
+
gem 'rr'
|
15
14
|
gem 'rspec'
|
16
15
|
gem 'rspec-wait'
|
16
|
+
gem 'rubocop'
|
17
|
+
gem 'simplecov', '>= 0.12', require: false
|
17
18
|
gem 'vcr'
|
18
|
-
gem 'rr'
|
19
19
|
gem 'webmock'
|
20
20
|
end
|
21
21
|
|
22
22
|
group :development, :test do
|
23
|
-
gem 'pry'
|
24
23
|
gem 'awesome_print'
|
24
|
+
gem 'pry'
|
25
25
|
end
|
@@ -9,17 +9,17 @@ gem 'celluloid', git: 'https://github.com/celluloid/celluloid.git'
|
|
9
9
|
gem 'dry-validation', '>= 0.10', '< 0.11'
|
10
10
|
|
11
11
|
group :test do
|
12
|
-
gem 'rubocop'
|
13
|
-
gem 'simplecov', '>= 0.12', require: false
|
14
12
|
gem 'codacy-coverage', require: false
|
13
|
+
gem 'rr'
|
15
14
|
gem 'rspec'
|
16
15
|
gem 'rspec-wait'
|
16
|
+
gem 'rubocop'
|
17
|
+
gem 'simplecov', '>= 0.12', require: false
|
17
18
|
gem 'vcr'
|
18
|
-
gem 'rr'
|
19
19
|
gem 'webmock'
|
20
20
|
end
|
21
21
|
|
22
22
|
group :development, :test do
|
23
|
-
gem 'pry'
|
24
23
|
gem 'awesome_print'
|
24
|
+
gem 'pry'
|
25
25
|
end
|
Binary file
|
Binary file
|
data/lib/pubnub.rb
CHANGED
@@ -3,9 +3,6 @@ require 'base64'
|
|
3
3
|
require 'zlib'
|
4
4
|
require 'open-uri'
|
5
5
|
require 'openssl'
|
6
|
-
require 'celluloid/current'
|
7
|
-
|
8
|
-
Celluloid.boot
|
9
6
|
|
10
7
|
require 'timers'
|
11
8
|
require 'httpclient'
|
@@ -13,6 +10,9 @@ require 'logger'
|
|
13
10
|
require 'dry-validation'
|
14
11
|
require 'cgi'
|
15
12
|
|
13
|
+
require 'concurrent'
|
14
|
+
require 'concurrent-edge'
|
15
|
+
|
16
16
|
require 'pubnub/version'
|
17
17
|
require 'pubnub/client'
|
18
18
|
|
data/lib/pubnub/client.rb
CHANGED
@@ -4,7 +4,6 @@ require 'pubnub/formatter'
|
|
4
4
|
require 'pubnub/crypto'
|
5
5
|
require 'pubnub/constants'
|
6
6
|
require 'pubnub/configuration'
|
7
|
-
require 'pubnub/message'
|
8
7
|
require 'pubnub/subscribe_callback'
|
9
8
|
|
10
9
|
require 'pubnub/schemas/envelope_schema'
|
@@ -243,11 +242,11 @@ module Pubnub
|
|
243
242
|
if sync
|
244
243
|
@env[:req_dispatchers_pool][:sync][origin] ||= {}
|
245
244
|
@env[:req_dispatchers_pool][:sync][origin][event_type] ||=
|
246
|
-
|
245
|
+
setup_httpclient(event_type)
|
247
246
|
else
|
248
247
|
@env[:req_dispatchers_pool][:async][origin] ||= {}
|
249
248
|
@env[:req_dispatchers_pool][:async][origin][event_type] ||=
|
250
|
-
|
249
|
+
setup_httpclient(event_type)
|
251
250
|
end
|
252
251
|
end
|
253
252
|
|
@@ -269,7 +268,7 @@ module Pubnub
|
|
269
268
|
# @env[:req_dispatchers_pool][origin][event_type].async.terminate
|
270
269
|
@env[:req_dispatchers_pool][:async][origin][event_type].reset_all
|
271
270
|
@env[:req_dispatchers_pool][:async][origin][event_type] = nil
|
272
|
-
rescue
|
271
|
+
rescue StandardError
|
273
272
|
Pubnub.logger.debug('Pubnub::Client') { 'There\'s no requester' }
|
274
273
|
end
|
275
274
|
|
@@ -303,11 +302,11 @@ module Pubnub
|
|
303
302
|
end
|
304
303
|
|
305
304
|
def record_telemetry(telemetry_type, time_start, time_end)
|
306
|
-
@telemetry.record_request(telemetry_type, time_start, time_end)
|
305
|
+
@telemetry.async.record_request(telemetry_type, time_start, time_end)
|
307
306
|
end
|
308
307
|
|
309
308
|
def telemetry_for(event)
|
310
|
-
@telemetry.fetch_average(event)
|
309
|
+
@telemetry.await.fetch_average(event).value
|
311
310
|
end
|
312
311
|
|
313
312
|
private
|
@@ -320,23 +319,27 @@ module Pubnub
|
|
320
319
|
end
|
321
320
|
|
322
321
|
def setup_httpclient(event_type)
|
323
|
-
if ENV['HTTP_PROXY']
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
322
|
+
hc = if ENV['HTTP_PROXY']
|
323
|
+
HTTPClient.new(ENV['HTTP_PROXY'])
|
324
|
+
else
|
325
|
+
HTTPClient.new
|
326
|
+
end
|
328
327
|
|
329
328
|
case event_type
|
330
329
|
when :subscribe_event
|
331
|
-
hc.
|
330
|
+
hc.connect_timeout = @env[:s_open_timeout]
|
331
|
+
hc.send_timeout = @env[:s_send_timeout]
|
332
|
+
hc.receive_timeout = @env[:s_read_timeout]
|
332
333
|
unless @env[:disable_keepalive] || @env[:disable_subscribe_keepalive]
|
333
|
-
hc.keep_alive_timeout =
|
334
|
+
hc.keep_alive_timeout = @env[:idle_timeout]
|
334
335
|
hc.tcp_keepalive = true
|
335
336
|
end
|
336
337
|
when :single_event
|
337
|
-
hc.
|
338
|
+
hc.connect_timeout = @env[:open_timeout]
|
339
|
+
hc.send_timeout = @env[:send_timeout]
|
340
|
+
hc.receive_timeout = @env[:read_timeout]
|
338
341
|
unless @env[:disable_keepalive] || @env[:disable_non_subscribe_keepalive]
|
339
|
-
hc.keep_alive_timeout =
|
342
|
+
hc.keep_alive_timeout = @env[:idle_timeout]
|
340
343
|
hc.tcp_keepalive = true
|
341
344
|
end
|
342
345
|
end
|
@@ -350,7 +353,7 @@ module Pubnub
|
|
350
353
|
|
351
354
|
def setup_app(options)
|
352
355
|
Pubnub.logger = options[:logger] || Logger.new('pubnub.log')
|
353
|
-
|
356
|
+
Concurrent.global_logger = Pubnub.logger
|
354
357
|
@subscriber = Subscriber.new(self)
|
355
358
|
@env = options
|
356
359
|
end
|
data/lib/pubnub/client/events.rb
CHANGED
@@ -4,8 +4,8 @@ module Pubnub
|
|
4
4
|
class Client
|
5
5
|
# Module that holds generator for all events
|
6
6
|
module Events
|
7
|
-
EVENTS = %w
|
8
|
-
revoke time heartbeat where_now set_state state channel_registration
|
7
|
+
EVENTS = %w[publish subscribe presence leave history here_now audit grant delete_messages
|
8
|
+
revoke time heartbeat where_now set_state state channel_registration].freeze
|
9
9
|
|
10
10
|
EVENTS.each do |event_name|
|
11
11
|
define_method event_name do |options = {}, &block|
|
@@ -20,13 +20,13 @@ module Pubnub
|
|
20
20
|
@subscriber.add_subscription(event)
|
21
21
|
@subscriber.reset
|
22
22
|
else
|
23
|
-
event.
|
23
|
+
Concurrent::Future.execute { event.fire }
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
alias unsubscribe leave
|
29
|
+
alias get_state state
|
30
30
|
|
31
31
|
def fire(options, &block)
|
32
32
|
publish(options.merge(store: false, replicate: false), &block)
|
@@ -24,15 +24,13 @@ module Pubnub
|
|
24
24
|
# Can't change uuid while subscribed. You have to leave every subscribed channel.
|
25
25
|
def change_uuid(uuid)
|
26
26
|
Pubnub.logger.debug('Pubnub::Client') { 'Changing uuid' }
|
27
|
-
if subscribed?
|
28
|
-
|
29
|
-
else
|
30
|
-
@env[:uuid] = uuid
|
31
|
-
end
|
27
|
+
raise('Cannot change UUID while subscribed.') if subscribed?
|
28
|
+
@env[:uuid] = uuid
|
32
29
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
|
31
|
+
alias session_uuid= change_uuid
|
32
|
+
alias uuid= change_uuid
|
33
|
+
alias set_uuid= change_uuid
|
36
34
|
|
37
35
|
# Returns:
|
38
36
|
# ========
|
@@ -40,7 +38,8 @@ module Pubnub
|
|
40
38
|
def current_origin
|
41
39
|
@env[:origin]
|
42
40
|
end
|
43
|
-
|
41
|
+
|
42
|
+
alias origin current_origin
|
44
43
|
|
45
44
|
# Returns:
|
46
45
|
# ========
|
@@ -103,6 +102,7 @@ module Pubnub
|
|
103
102
|
def events
|
104
103
|
@env[:events]
|
105
104
|
end
|
105
|
+
|
106
106
|
# :nocov:
|
107
107
|
|
108
108
|
def current_heartbeat
|
@@ -113,10 +113,9 @@ module Pubnub
|
|
113
113
|
@env[:heartbeat] = value
|
114
114
|
end
|
115
115
|
|
116
|
-
def subscribe_filter=(
|
117
|
-
@env[:subscribe_filter] = filter_expr
|
116
|
+
def subscribe_filter=(filter_exp)
|
118
117
|
@subscriber.reset if subscribed?
|
119
|
-
|
118
|
+
@env[:subscribe_filter] = filter_exp
|
120
119
|
end
|
121
120
|
|
122
121
|
def subscribe_filter
|
@@ -5,13 +5,13 @@ module Pubnub
|
|
5
5
|
# Module that holds paged_history event logic
|
6
6
|
module PagedHistory
|
7
7
|
def paged_history(options = {}, &block)
|
8
|
-
channel
|
9
|
-
page
|
10
|
-
limit
|
8
|
+
channel = options.fetch(:channel)
|
9
|
+
page = options.fetch(:page, 1)
|
10
|
+
limit = options.fetch(:limit, 100)
|
11
11
|
callback = options.fetch(:callback, block)
|
12
|
-
sync
|
12
|
+
sync = options[:http_sync]
|
13
13
|
start_tt = options.fetch(:start)
|
14
|
-
end_tt
|
14
|
+
end_tt = options.fetch(:end)
|
15
15
|
if sync
|
16
16
|
sync_paged_history(channel, page, limit, callback, start: start_tt, end: end_tt)
|
17
17
|
else
|
@@ -40,7 +40,7 @@ module Pubnub
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def async_paged_history(options)
|
43
|
-
|
43
|
+
Concurrent::Future.new do
|
44
44
|
sync_options = options.dup
|
45
45
|
sync_options[:http_sync] = true
|
46
46
|
paged_history(sync_options, &block)
|
@@ -49,9 +49,11 @@ module Pubnub
|
|
49
49
|
|
50
50
|
def call_callback(envelopes, callback)
|
51
51
|
envelopes.flatten!
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
if callback
|
53
|
+
envelopes.each do |envelope|
|
54
|
+
secure_call callback, envelope
|
55
|
+
end
|
56
|
+
end
|
55
57
|
envelopes
|
56
58
|
end
|
57
59
|
end
|
data/lib/pubnub/configuration.rb
CHANGED
@@ -16,8 +16,7 @@ module Pubnub
|
|
16
16
|
reconnect_interval: Pubnub::Constants::DEFAULT_RECONNECT_INTERVAL,
|
17
17
|
region: Pubnub::Constants::DEFAULT_REGION,
|
18
18
|
ssl: Pubnub::Constants::DEFAULT_SSL,
|
19
|
-
request_message_count_threshold: Pubnub::Constants::REQUEST_MESSAGE_COUNT_THRESHOLD
|
20
|
-
}
|
19
|
+
request_message_count_threshold: Pubnub::Constants::REQUEST_MESSAGE_COUNT_THRESHOLD }
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
data/lib/pubnub/constants.rb
CHANGED
@@ -3,62 +3,62 @@ module Pubnub
|
|
3
3
|
# Constants module holds all constants and default values.
|
4
4
|
module Constants
|
5
5
|
# Config constants
|
6
|
-
DEFAULT_READ_TIMEOUT
|
7
|
-
DEFAULT_OPEN_TIMEOUT
|
8
|
-
DEFAULT_IDLE_TIMEOUT
|
9
|
-
DEFAULT_S_READ_TIMEOUT
|
10
|
-
DEFAULT_S_OPEN_TIMEOUT
|
11
|
-
DEFAULT_S_IDLE_TIMEOUT
|
12
|
-
DEFAULT_H_READ_TIMEOUT
|
13
|
-
DEFAULT_H_OPEN_TIMEOUT
|
14
|
-
DEFAULT_H_IDLE_TIMEOUT
|
15
|
-
DEFAULT_RECONNECT_ATTEMPTS
|
16
|
-
DEFAULT_RECONNECT_INTERVAL
|
17
|
-
DEFAULT_ORIGIN
|
18
|
-
DEFAULT_PORT
|
19
|
-
PERIODIC_TIMER_INTERVAL
|
20
|
-
DEFAULT_TTL
|
21
|
-
DEFAULT_REGION
|
22
|
-
DEFAULT_SSL
|
23
|
-
REQUEST_MESSAGE_COUNT_THRESHOLD
|
6
|
+
DEFAULT_READ_TIMEOUT = 10
|
7
|
+
DEFAULT_OPEN_TIMEOUT = 10
|
8
|
+
DEFAULT_IDLE_TIMEOUT = 10
|
9
|
+
DEFAULT_S_READ_TIMEOUT = 310
|
10
|
+
DEFAULT_S_OPEN_TIMEOUT = 310
|
11
|
+
DEFAULT_S_IDLE_TIMEOUT = 310
|
12
|
+
DEFAULT_H_READ_TIMEOUT = 10
|
13
|
+
DEFAULT_H_OPEN_TIMEOUT = 10
|
14
|
+
DEFAULT_H_IDLE_TIMEOUT = 10
|
15
|
+
DEFAULT_RECONNECT_ATTEMPTS = 10
|
16
|
+
DEFAULT_RECONNECT_INTERVAL = 10
|
17
|
+
DEFAULT_ORIGIN = 'ps.pndsn.com'.freeze
|
18
|
+
DEFAULT_PORT = 80
|
19
|
+
PERIODIC_TIMER_INTERVAL = 0.25
|
20
|
+
DEFAULT_TTL = 1440
|
21
|
+
DEFAULT_REGION = '0'.freeze
|
22
|
+
DEFAULT_SSL = false
|
23
|
+
REQUEST_MESSAGE_COUNT_THRESHOLD = 0
|
24
24
|
|
25
25
|
# Envelope values
|
26
26
|
# Errors
|
27
|
-
STATUS_ACCESS_DENIED
|
28
|
-
STATUS_TIMEOUT
|
27
|
+
STATUS_ACCESS_DENIED = :access_denied
|
28
|
+
STATUS_TIMEOUT = :timeout
|
29
29
|
STATUS_NON_JSON_RESPONSE = :non_json_response
|
30
|
-
STATUS_ERROR
|
31
|
-
SSL_ERROR
|
32
|
-
STATUS_API_KEY_ERROR
|
30
|
+
STATUS_ERROR = :error
|
31
|
+
SSL_ERROR = :ssl_error
|
32
|
+
STATUS_API_KEY_ERROR = :api_key_error
|
33
33
|
STATUS_REQUEST_MESSAGE_COUNT_EXCEEDED = :request_message_count_exceeded
|
34
34
|
|
35
35
|
# Successes
|
36
36
|
STATUS_ACK = :ack
|
37
37
|
|
38
|
-
STATUS_CATEGORY_ERRORS
|
39
|
-
|
40
|
-
STATUS_CATEGORY_SUCCESSES = [STATUS_ACK]
|
38
|
+
STATUS_CATEGORY_ERRORS = [STATUS_ACCESS_DENIED, STATUS_TIMEOUT, STATUS_NON_JSON_RESPONSE, STATUS_API_KEY_ERROR,
|
39
|
+
SSL_ERROR].freeze
|
40
|
+
STATUS_CATEGORY_SUCCESSES = [STATUS_ACK].freeze
|
41
41
|
|
42
42
|
# Operations
|
43
|
-
OPERATION_SUBSCRIBE
|
44
|
-
OPERATION_PUBLISH
|
45
|
-
OPERATION_HEARTBEAT
|
46
|
-
OPERATION_PRESENCE
|
47
|
-
OPERATION_PRESENCE_LEAVE
|
48
|
-
OPERATION_TIME
|
49
|
-
OPERATION_HISTORY
|
50
|
-
OPERATION_HERE_NOW
|
51
|
-
OPERATION_WHERE_NOW
|
52
|
-
OPERATION_GLOBAL_HERE_NOW
|
53
|
-
OPERATION_GET_STATE
|
54
|
-
OPERATION_SET_STATE
|
55
|
-
OPERATION_CHANNEL_GROUP_ADD
|
56
|
-
OPERATION_CHANNEL_GROUP_REMOVE
|
57
|
-
OPERATION_AUDIT
|
58
|
-
OPERATION_GRANT
|
59
|
-
OPERATION_REVOKE
|
60
|
-
OPERATION_DELETE
|
61
|
-
OPERATION_LIST_ALL_CHANNEL_GROUPS
|
43
|
+
OPERATION_SUBSCRIBE = :subscribe
|
44
|
+
OPERATION_PUBLISH = :publish
|
45
|
+
OPERATION_HEARTBEAT = :heartbeat
|
46
|
+
OPERATION_PRESENCE = :presence
|
47
|
+
OPERATION_PRESENCE_LEAVE = :leave
|
48
|
+
OPERATION_TIME = :time
|
49
|
+
OPERATION_HISTORY = :history
|
50
|
+
OPERATION_HERE_NOW = :here_now
|
51
|
+
OPERATION_WHERE_NOW = :where_now
|
52
|
+
OPERATION_GLOBAL_HERE_NOW = :global_here_now
|
53
|
+
OPERATION_GET_STATE = :get_state
|
54
|
+
OPERATION_SET_STATE = :set_state
|
55
|
+
OPERATION_CHANNEL_GROUP_ADD = :channel_group_add
|
56
|
+
OPERATION_CHANNEL_GROUP_REMOVE = :channel_group_remove
|
57
|
+
OPERATION_AUDIT = :audit
|
58
|
+
OPERATION_GRANT = :grant
|
59
|
+
OPERATION_REVOKE = :revoke
|
60
|
+
OPERATION_DELETE = :delete
|
61
|
+
OPERATION_LIST_ALL_CHANNEL_GROUPS = :list_all_channel_groups
|
62
62
|
OPERATION_LIST_ALL_CHANNELS_IN_CHANNEL_GROUP = :list_all_channels_in_channel_group
|
63
63
|
|
64
64
|
OPERATIONS = [
|
@@ -66,10 +66,10 @@ module Pubnub
|
|
66
66
|
OPERATION_HERE_NOW, OPERATION_GLOBAL_HERE_NOW, OPERATION_GET_STATE, OPERATION_LIST_ALL_CHANNEL_GROUPS,
|
67
67
|
OPERATION_LIST_ALL_CHANNELS_IN_CHANNEL_GROUP, OPERATION_CHANNEL_GROUP_ADD, OPERATION_CHANNEL_GROUP_REMOVE,
|
68
68
|
OPERATION_AUDIT, OPERATION_GRANT, OPERATION_REVOKE, OPERATION_WHERE_NOW
|
69
|
-
]
|
69
|
+
].freeze
|
70
70
|
|
71
71
|
# Announcements
|
72
|
-
TIMEOUT_ANNOUNCEMENT
|
72
|
+
TIMEOUT_ANNOUNCEMENT = :disconnect
|
73
73
|
RECONNECTED_ANNOUNCEMENT = :reconnected
|
74
74
|
end
|
75
75
|
end
|