pubnub 3.7.7 → 3.7.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e930123aa3744cc2502f5c149ff6d3ac84bb2b3
4
- data.tar.gz: f40e73b54f5d772900442f8f781e59cb86e3b0b5
3
+ metadata.gz: 62193ab10214d59518c9062bc59e8c3c8d2f1734
4
+ data.tar.gz: 853adb652e08e97ae375053f4c946820ee6af4f4
5
5
  SHA512:
6
- metadata.gz: b7f919110b50b429783472663fd4d66c6790dc61b2e0956f1b77d0190148cde22fa2d2d763817dbd9bdb106ace6bd5ec4fc3e3e0dc950e2f7982c2aafae04735
7
- data.tar.gz: b1a6b6020cc24a3a3c960a13f54084b3b4ee228e426b378a6df6215c0f8871e8a5b40adb7b0a504193681a88f9329fd221497380dea8cd2cc52cf3e567c70583
6
+ metadata.gz: 1fb7d4e826de2989190dc60ba0e04eba377ab46300cc13f1ab506e4eca0bb825fb06a04caa412384df76716a950429adadbe8480b10b336c51c2b7c6acca8eaa
7
+ data.tar.gz: 9b137577a94359da14c6e044e0cba58fe06300fc1938826ef5c2dc811ca8e55d394eb959a2d356d5b120e3cdd4a71b87cf47c30580a01a3bb117731f501abe21
data/CHANGELOG.txt CHANGED
@@ -1,3 +1,10 @@
1
+ 3.7.9 Release
2
+ . Secured calling callbacks
3
+ . Reestablishing subscription improved
4
+
5
+ 3.7.8 Release
6
+ . Connect callback is fired after subscription starts working
7
+
1
8
  3.7.7 Release
2
9
  . Small wildcard fix
3
10
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pubnub (3.7.6)
4
+ pubnub (3.7.9)
5
5
  eventmachine (~> 1.0)
6
6
  json (~> 1.8)
7
7
  net-http-persistent (~> 2.9)
@@ -57,4 +57,4 @@ DEPENDENCIES
57
57
  webmock
58
58
 
59
59
  BUNDLED WITH
60
- 1.10.3
60
+ 1.10.6
data/README.md CHANGED
@@ -6,7 +6,7 @@ Give it a try and share with us your thoughts!
6
6
 
7
7
  # Please direct all Support Questions and Concerns to Support@PubNub.com
8
8
 
9
- ## PubNub Gem version 3.7.6
9
+ ## PubNub Gem version 3.7.9
10
10
 
11
11
  ##### YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API.
12
12
  ##### http://www.pubnub.com/account
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.7.6
1
+ 3.7.9
data/lib/pubnub/client.rb CHANGED
@@ -211,6 +211,7 @@ module Pubnub
211
211
  end
212
212
 
213
213
  def update_timetoken(timetoken)
214
+ @env[:connect_callback].call "New connection to #{@origin}" if @env[:timetoken] == 0 && @env[:connect_callback]
214
215
  @env[:timetoken] = timetoken.to_i
215
216
  Pubnub.logger.debug(:pubnub){"Pubnub::Client#update_timetoken | Current timetoken is eq #{@env[:timetoken]}"}
216
217
  end
@@ -312,6 +313,7 @@ module Pubnub
312
313
  @env = symbolize_options_keys(options)
313
314
  @env = set_default_values(@env)
314
315
  @env.delete_if { |_,v| v.blank? } # nillify if blank
316
+ @env[:timetoken] = 0
315
317
  @async_events = Array.new
316
318
  Pubnub.logger.debug(:pubnub){"\n\nCreated new Pubnub::Client instance"}
317
319
  end
@@ -333,6 +335,7 @@ module Pubnub
333
335
  :subscribe_timeout => DEFAULT_SUBSCRIBE_TIMEOUT,
334
336
  :timeout => DEFAULT_NON_SUBSCRIBE_TIMEOUT,
335
337
  :max_retries => MAX_RETRIES,
338
+ :retries_interval => RETRIES_INTERVAL,
336
339
  :non_subscribe_timeout => DEFAULT_NON_SUBSCRIBE_TIMEOUT,
337
340
  :reconnect_max_attempts => DEFAULT_RECONNECT_ATTEMPTS,
338
341
  :reconnect_retry_interval => DEFAULT_RECONNECT_INTERVAL,
data/lib/pubnub/event.rb CHANGED
@@ -34,6 +34,14 @@ module Pubnub
34
34
  Pubnub.logger.debug(:pubnub){"Event#initialize | Initialized #{self.class.to_s}"}
35
35
  end
36
36
 
37
+ def secure_call(lambda, parameter)
38
+ begin
39
+ lambda.call parameter
40
+ rescue => e
41
+ Pubnub.logger.error(:pubnub){"Can't fire callback because: #{e}"}
42
+ end
43
+ end
44
+
37
45
  def fire(app)
38
46
  Pubnub.logger.debug(:pubnub){'Pubnub::Event#fire'}
39
47
  @fired = true
@@ -69,10 +77,13 @@ module Pubnub
69
77
  end
70
78
  rescue => e
71
79
  Pubnub.logger.error(:pubnub){e.inspect}
80
+ sleep app.env[:retries_interval]
72
81
  if count <= app.env[:max_retries]
73
82
  start_event(app, count + 1)
74
83
  else
75
84
  Pubnub.logger.error(:pubnub){"Aborting #{self.class} event due to network errors and reaching max retries"}
85
+ app.env[:subscribe_railgun].cancel if app.env[:subscribe_railgun]
86
+ app.env[:subscribe_railgun] = nil
76
87
  end
77
88
  false
78
89
  end
@@ -136,12 +147,12 @@ module Pubnub
136
147
  Pubnub.logger.debug(:pubnub){'Firing callbacks'}
137
148
  # EM.defer do
138
149
  envelopes.each do |envelope|
139
- @callback.call(envelope) if envelope && !envelope.error && @callback && !envelope.timetoken_update
150
+ secure_call(@callback, envelope) if envelope && !envelope.error && @callback && !envelope.timetoken_update
140
151
  #if envelope.timetoken_update || envelope.timetoken.to_i > app.env[:timetoken].to_i
141
152
  # update_timetoken(app, envelope.timetoken)
142
153
  #end
143
154
  end
144
- @error_callback.call(envelopes.first) if envelopes.first.error
155
+ secure_call(@error_callback, envelopes.first) if envelopes.first.error
145
156
  # end
146
157
  else
147
158
  Pubnub.logger.debug(:pubnub){'No envelopes for callback'}
@@ -523,18 +534,37 @@ module Pubnub
523
534
  Pubnub.logger.debug(:pubnub){'Event#fire_callbacks async'}
524
535
  envelopes.each do |envelope|
525
536
  if group_envelope?(envelope, app) # WITH GROUP
526
- app.env[:callbacks_pool][:channel_group][@origin][envelope.channel_group][:callback].call(envelope) if !envelope.error && !envelope.timetoken_update
537
+ secure_call(
538
+ app.env[:callbacks_pool][:channel_group][@origin][envelope.channel_group][:callback],
539
+ envelope
540
+ ) if !envelope.error && !envelope.timetoken_update
527
541
  elsif channel_envelope?(envelope, app) # CHANNEL SUBSCRIBE
528
- app.env[:callbacks_pool][:channel][@origin][encode_channel(envelope.channel)][:callback].call(envelope) if !envelope.error && !envelope.timetoken_update
542
+ secure_call(
543
+ app.env[:callbacks_pool][:channel][@origin][encode_channel(envelope.channel)][:callback],
544
+ envelope
545
+ ) if !envelope.error && !envelope.timetoken_update
529
546
  elsif wc_pnpres_envelope(envelope, app) # wildcard pnpres
530
- app.env[:callbacks_pool][:wildcard_channel][@origin][encode_channel(envelope.wildcard_channel)][:presence_callback].call(envelope) if !envelope.error && !envelope.timetoken_update
547
+ secure_call(
548
+ app.env[:callbacks_pool][:wildcard_channel][@origin][encode_channel(envelope.wildcard_channel)][:presence_callback],
549
+ envelope
550
+ ) if !envelope.error && !envelope.timetoken_update
531
551
  elsif wc_envelope?(envelope, app) # wildcard
532
- app.env[:callbacks_pool][:wildcard_channel][@origin][encode_channel(envelope.wildcard_channel)][:callback].call(envelope) if !envelope.error && !envelope.timetoken_update
552
+ secure_call(
553
+ app.env[:callbacks_pool][:wildcard_channel][@origin][encode_channel(envelope.wildcard_channel)][:callback],
554
+ envelope
555
+ ) if !envelope.error && !envelope.timetoken_update
533
556
  end
534
557
  end
535
558
  Pubnub.logger.debug(:pubnub){'We can send next request now'}
536
- app.env[:error_callbacks_pool][:channel][@origin].call(envelopes.first) if envelopes.first.error && !envelopes.first.channel_group
537
- app.env[:error_callbacks_pool][:channel_group][@origin].call(envelopes.first) if envelopes.first.error && envelopes.first.channel_group
559
+ secure_call(
560
+ app.env[:error_callbacks_pool][:channel][@origin],
561
+ envelopes.first
562
+ ) if envelopes.first.error && !envelopes.first.channel_group
563
+
564
+ secure_call(
565
+ app.env[:error_callbacks_pool][:channel_group][@origin],
566
+ envelopes.first
567
+ ) if envelopes.first.error && envelopes.first.channel_group
538
568
 
539
569
  rescue => error
540
570
  Pubnub.logger.error(:pubnub){error}
@@ -706,7 +736,6 @@ module Pubnub
706
736
  connection = Net::HTTP::Persistent.new "pubnub_ruby_client_v#{Pubnub::VERSION}"
707
737
  connection.idle_timeout = app.env[:subscribe_timeout]
708
738
  connection.read_timeout = app.env[:subscribe_timeout]
709
- @connect_callback.call "New connection to #{@origin}"
710
739
  connection.proxy_from_env
711
740
  connection
712
741
  end
@@ -44,7 +44,7 @@ module Pubnub
44
44
  message = pc.encrypt(message)
45
45
  URI.escape(message.to_json)
46
46
  rescue => error
47
- @error_callback.call 'bug'
47
+ @error_callback.call error
48
48
  end
49
49
  else
50
50
  URI.encode_www_form_component(message.to_json).gsub('+', '%20')
@@ -1,3 +1,3 @@
1
1
  module Pubnub
2
- VERSION = '3.7.7'
2
+ VERSION = '3.7.9'
3
3
  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: 3.7.7
4
+ version: 3.7.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - PubNub
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-29 00:00:00.000000000 Z
11
+ date: 2015-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine