pubnub 3.5.1 → 3.5.3
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 +6 -0
- data/README.md +11 -0
- data/VERSION +1 -1
- data/examples/demo_console.rb +0 -1
- data/fixtures/vcr_cassettes/auth_key_flow_auth_publish.yml +45 -0
- data/fixtures/vcr_cassettes/auth_key_flow_empty_auth_audit.yml +44 -0
- data/fixtures/vcr_cassettes/auth_key_flow_instead_auth_audit.yml +44 -0
- data/fixtures/vcr_cassettes/auth_key_flow_no_auth_publish.yml +45 -0
- data/fixtures/vcr_cassettes/auth_key_flow_non_auth_audit.yml +44 -0
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-many-channels-array.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-many-channels-hash.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-many-channels-integer.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-many-channels-mix.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-many-channels-multi-mix.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-many-channels-string.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-one-channel-array.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-one-channel-hash.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-one-channel-integer.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-one-channel-mix.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-one-channel-string.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-many-channels-array.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-many-channels-hash.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-many-channels-integer.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-many-channels-mix.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-many-channels-multi-mix.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-many-channels-string.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-one-channel-array.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-one-channel-hash.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-one-channel-integer.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-one-channel-mix.yml +2 -2
- data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-one-channel-string.yml +2 -2
- data/fixtures/vcr_cassettes/heartbeat-non200.yml +519 -0
- data/fixtures/vcr_cassettes/heartbeat-test.yml +91 -0
- data/fixtures/vcr_cassettes/heartbeated-subscribe.yml +136 -0
- data/fixtures/vcr_cassettes/here_now_global-nonssl-block-invalid-200-sync.yml +49 -0
- data/fixtures/vcr_cassettes/here_now_global-nonssl-block-invalid-non-200-sync.yml +49 -0
- data/fixtures/vcr_cassettes/here_now_global-nonssl-block-valid-200-sync.yml +49 -0
- data/fixtures/vcr_cassettes/here_now_global-nonssl-block-valid-non-200-sync.yml +49 -0
- data/fixtures/vcr_cassettes/here_now_global-nonssl-parameter-invalid-200-sync.yml +49 -0
- data/fixtures/vcr_cassettes/here_now_global-nonssl-parameter-invalid-non-200-sync.yml +49 -0
- data/fixtures/vcr_cassettes/here_now_global-nonssl-parameter-valid-200-sync.yml +49 -0
- data/fixtures/vcr_cassettes/here_now_global-nonssl-parameter-valid-non-200-sync.yml +49 -0
- data/fixtures/vcr_cassettes/here_now_global-ssl-block-invalid-200-sync.yml +49 -0
- data/fixtures/vcr_cassettes/here_now_global-ssl-block-invalid-non-200-sync.yml +49 -0
- data/fixtures/vcr_cassettes/here_now_global-ssl-block-valid-200-async.yml +49 -0
- data/fixtures/vcr_cassettes/here_now_global-ssl-block-valid-200-sync.yml +49 -0
- data/fixtures/vcr_cassettes/here_now_global-ssl-block-valid-non-200-sync.yml +49 -0
- data/fixtures/vcr_cassettes/here_now_global-ssl-parameter-invalid-200-sync.yml +49 -0
- data/fixtures/vcr_cassettes/here_now_global-ssl-parameter-invalid-non-200-sync.yml +49 -0
- data/fixtures/vcr_cassettes/here_now_global-ssl-parameter-valid-200-sync.yml +49 -0
- data/fixtures/vcr_cassettes/here_now_global-ssl-parameter-valid-non-200-sync.yml +49 -0
- data/fixtures/vcr_cassettes/new_ones/multiplexed_subscribe.yml +854 -0
- data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-array-of-hashes.yml +1 -1
- data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-http-200-invalid.yml +1 -1
- data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-http-200-valid.yml +1 -1
- data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-http-non200-invalid.yml +1 -1
- data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-http-non200-valid.yml +1 -1
- data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-https-200-invalid.yml +1 -1
- data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-https-200-valid.yml +1 -1
- data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-https-non200-invalid.yml +1 -1
- data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-https-non200-valid.yml +1 -1
- data/fixtures/vcr_cassettes/new_ones/publish/publish-http-200-invalid.yml +1 -1
- data/fixtures/vcr_cassettes/new_ones/publish/publish-http-200-valid.yml +1 -1
- data/fixtures/vcr_cassettes/new_ones/publish/publish-http-non200-invalid.yml +1 -1
- data/fixtures/vcr_cassettes/new_ones/publish/publish-http-non200-valid.yml +1 -1
- data/fixtures/vcr_cassettes/new_ones/publish/publish-https-200-invalid.yml +1 -1
- data/fixtures/vcr_cassettes/new_ones/publish/publish-https-200-valid.yml +1 -1
- data/fixtures/vcr_cassettes/new_ones/publish/publish-https-non200-invalid.yml +1 -1
- data/fixtures/vcr_cassettes/new_ones/publish/publish-https-non200-valid.yml +1 -1
- data/fixtures/vcr_cassettes/new_ones/publish/publish-plain-array-of-hashes.yml +1 -1
- data/fixtures/vcr_cassettes/non-heartbeated-subscribe.yml +44 -0
- data/fixtures/vcr_cassettes/pam20.yml +1 -1
- data/fixtures/vcr_cassettes/single-event-invalid-json.yml +15 -138
- data/fixtures/vcr_cassettes/v3-presence-nonssl-block-invalid-200-async.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-nonssl-block-invalid-200-sync.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-nonssl-block-invalid-non-200-async.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-nonssl-block-invalid-non-200-sync.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-nonssl-block-valid-200-async.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-nonssl-block-valid-200-sync.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-nonssl-block-valid-non-200-async.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-nonssl-block-valid-non-200-sync.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-nonssl-parameter-invalid-200-async.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-nonssl-parameter-invalid-200-sync.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-nonssl-parameter-invalid-non-200-async.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-nonssl-parameter-invalid-non-200-sync.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-nonssl-parameter-valid-200-async.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-nonssl-parameter-valid-200-sync.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-nonssl-parameter-valid-non-200-async.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-nonssl-parameter-valid-non-200-sync.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-ssl-block-invalid-200-async.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-ssl-block-invalid-200-sync.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-ssl-block-invalid-non-200-async.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-ssl-block-invalid-non-200-sync.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-ssl-block-valid-200-async.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-ssl-block-valid-200-sync.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-ssl-block-valid-non-200-async.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-ssl-block-valid-non-200-sync.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-ssl-parameter-invalid-200-async.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-ssl-parameter-invalid-200-sync.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-ssl-parameter-invalid-non-200-async.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-ssl-parameter-invalid-non-200-sync.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-ssl-parameter-valid-200-async.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-ssl-parameter-valid-200-sync.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-ssl-parameter-valid-non-200-async.yml +86 -0
- data/fixtures/vcr_cassettes/v3-presence-ssl-parameter-valid-non-200-sync.yml +86 -0
- data/lib/pubnub/client.rb +57 -31
- data/lib/pubnub/crypto.rb +6 -6
- data/lib/pubnub/event.rb +64 -45
- data/lib/pubnub/events/heartbeat.rb +59 -0
- data/lib/pubnub/events/here_now.rb +19 -10
- data/lib/pubnub/events/leave.rb +17 -9
- data/lib/pubnub/exceptions.rb +1 -1
- data/lib/pubnub/formatter.rb +1 -0
- data/lib/pubnub/pam.rb +5 -0
- data/lib/version.rb +1 -1
- data/pubnub.gemspec +2 -2
- data/spec/lib/auth_key_flow_spec.rb +60 -0
- data/spec/lib/heartbeat_spec.rb +110 -0
- data/spec/lib/integration/global_here_now_spec.rb +541 -0
- data/spec/lib/integration/multiplexed_subscribe_flow_spec.rb +44 -0
- data/spec/lib/integration/publish_spec.rb +1699 -373
- data/spec/lib/integration/publish_spec_old.rb +541 -0
- data/spec/lib/integration/v3_presence_spec.rb +557 -0
- metadata +68 -4
- data/examples/demo_console.rb~ +0 -307
- data/spec/lib/new_integration/publish_spec.rb +0 -1867
@@ -0,0 +1,86 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://pubsub.pubnub.com/subscribe/demo-36/demo-pnpres/0/0?auth=demoish_authkey&pnsdk=PubNub-Ruby/3.5.2&uuid=rubytests
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- '*/*'
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
Connection:
|
17
|
+
- keep-alive
|
18
|
+
Keep-Alive:
|
19
|
+
- 30
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Mon, 07 Apr 2014 17:25:47 GMT
|
27
|
+
Content-Type:
|
28
|
+
- text/javascript; charset="UTF-8"
|
29
|
+
Content-Length:
|
30
|
+
- '24'
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache
|
35
|
+
Access-Control-Allow-Origin:
|
36
|
+
- '*'
|
37
|
+
Access-Control-Allow-Methods:
|
38
|
+
- GET
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: '[[],"13968915474479311"]'
|
42
|
+
http_version:
|
43
|
+
recorded_at: Mon, 07 Apr 2014 17:25:48 GMT
|
44
|
+
- request:
|
45
|
+
method: get
|
46
|
+
uri: https://pubsub.pubnub.com/subscribe/demo-36/demo-pnpres/0/13968915474479311?auth=demoish_authkey&pnsdk=PubNub-Ruby/3.5.2&uuid=rubytests
|
47
|
+
body:
|
48
|
+
encoding: US-ASCII
|
49
|
+
string: ''
|
50
|
+
headers:
|
51
|
+
Accept-Encoding:
|
52
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
53
|
+
Accept:
|
54
|
+
- '*/*'
|
55
|
+
User-Agent:
|
56
|
+
- Ruby
|
57
|
+
Connection:
|
58
|
+
- keep-alive
|
59
|
+
Keep-Alive:
|
60
|
+
- 30
|
61
|
+
response:
|
62
|
+
status:
|
63
|
+
code: 500
|
64
|
+
message: OK
|
65
|
+
headers:
|
66
|
+
Date:
|
67
|
+
- Mon, 07 Apr 2014 17:25:54 GMT
|
68
|
+
Content-Type:
|
69
|
+
- text/javascript; charset="UTF-8"
|
70
|
+
Content-Length:
|
71
|
+
- '131'
|
72
|
+
Connection:
|
73
|
+
- keep-alive
|
74
|
+
Cache-Control:
|
75
|
+
- no-cache
|
76
|
+
Access-Control-Allow-Origin:
|
77
|
+
- '*'
|
78
|
+
Access-Control-Allow-Methods:
|
79
|
+
- GET
|
80
|
+
body:
|
81
|
+
encoding: UTF-8
|
82
|
+
string: '[[{"action": "join", "timestamp": 1396891554, "uuid": "a1259d2d-7a7c-485f-8076-028a327e976d",
|
83
|
+
"occupancy": 1}],"13968915543625014"]'
|
84
|
+
http_version:
|
85
|
+
recorded_at: Mon, 07 Apr 2014 17:25:55 GMT
|
86
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,86 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://pubsub.pubnub.com/subscribe/demo-36/demo-pnpres/0/0?auth=demoish_authkey&pnsdk=PubNub-Ruby/3.5.2&uuid=rubytests
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- '*/*'
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
Connection:
|
17
|
+
- keep-alive
|
18
|
+
Keep-Alive:
|
19
|
+
- 30
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Mon, 07 Apr 2014 17:25:47 GMT
|
27
|
+
Content-Type:
|
28
|
+
- text/javascript; charset="UTF-8"
|
29
|
+
Content-Length:
|
30
|
+
- '24'
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache
|
35
|
+
Access-Control-Allow-Origin:
|
36
|
+
- '*'
|
37
|
+
Access-Control-Allow-Methods:
|
38
|
+
- GET
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: '[[],"13968915474479311"]'
|
42
|
+
http_version:
|
43
|
+
recorded_at: Mon, 07 Apr 2014 17:25:48 GMT
|
44
|
+
- request:
|
45
|
+
method: get
|
46
|
+
uri: https://pubsub.pubnub.com/subscribe/demo-36/demo-pnpres/0/13968915474479311?auth=demoish_authkey&pnsdk=PubNub-Ruby/3.5.2&uuid=rubytests
|
47
|
+
body:
|
48
|
+
encoding: US-ASCII
|
49
|
+
string: ''
|
50
|
+
headers:
|
51
|
+
Accept-Encoding:
|
52
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
53
|
+
Accept:
|
54
|
+
- '*/*'
|
55
|
+
User-Agent:
|
56
|
+
- Ruby
|
57
|
+
Connection:
|
58
|
+
- keep-alive
|
59
|
+
Keep-Alive:
|
60
|
+
- 30
|
61
|
+
response:
|
62
|
+
status:
|
63
|
+
code: 500
|
64
|
+
message: OK
|
65
|
+
headers:
|
66
|
+
Date:
|
67
|
+
- Mon, 07 Apr 2014 17:25:54 GMT
|
68
|
+
Content-Type:
|
69
|
+
- text/javascript; charset="UTF-8"
|
70
|
+
Content-Length:
|
71
|
+
- '131'
|
72
|
+
Connection:
|
73
|
+
- keep-alive
|
74
|
+
Cache-Control:
|
75
|
+
- no-cache
|
76
|
+
Access-Control-Allow-Origin:
|
77
|
+
- '*'
|
78
|
+
Access-Control-Allow-Methods:
|
79
|
+
- GET
|
80
|
+
body:
|
81
|
+
encoding: UTF-8
|
82
|
+
string: '[[{"action": "join", "timestamp": 1396891554, "uuid": "a1259d2d-7a7c-485f-8076-028a327e976d",
|
83
|
+
"occupancy": 1}],"13968915543625014"]'
|
84
|
+
http_version:
|
85
|
+
recorded_at: Mon, 07 Apr 2014 17:25:55 GMT
|
86
|
+
recorded_with: VCR 2.8.0
|
data/lib/pubnub/client.rb
CHANGED
@@ -16,7 +16,7 @@ module Pubnub
|
|
16
16
|
attr_reader :env
|
17
17
|
attr_accessor :single_event_connections_pool, :subscribe_event_connections_pool, :uuid, :async_events
|
18
18
|
|
19
|
-
EVENTS = %w(publish subscribe presence leave history here_now audit grant revoke time)
|
19
|
+
EVENTS = %w(publish subscribe presence leave history here_now audit grant revoke time heartbeat)
|
20
20
|
VERSION = Pubnub::VERSION
|
21
21
|
|
22
22
|
EVENTS.each do |event_name|
|
@@ -27,18 +27,8 @@ module Pubnub
|
|
27
27
|
define_method event_name do |params, &block|
|
28
28
|
params[:callback] = block if params[:callback].nil?
|
29
29
|
event = Pubnub.const_get(classify_method(event_name)).new(params, self)
|
30
|
-
$logger.debug('Created event ' + event.class.to_s
|
31
|
-
|
32
|
-
event.fire(self)
|
33
|
-
#else
|
34
|
-
# EM.defer {
|
35
|
-
# begin
|
36
|
-
# event.fire(self)
|
37
|
-
# rescue => e
|
38
|
-
# puts e
|
39
|
-
# end
|
40
|
-
# }
|
41
|
-
#end
|
30
|
+
$logger.debug('Pubnub'){'Created event ' + event.class.to_s}
|
31
|
+
event.fire(self)
|
42
32
|
end
|
43
33
|
end
|
44
34
|
alias_method :unsubscribe, :leave
|
@@ -70,15 +60,38 @@ module Pubnub
|
|
70
60
|
|
71
61
|
EM.stop if stop_em
|
72
62
|
|
73
|
-
$logger.info('Bye!'
|
63
|
+
$logger.info('Pubnub'){'Bye!'}
|
64
|
+
end
|
65
|
+
|
66
|
+
def start_respirator
|
67
|
+
$logger.debug('Pubnub'){'Pubnub::Client#start_respirator | fired'}
|
68
|
+
if @env[:heartbeat]
|
69
|
+
$logger.debug('Pubnub'){'Pubnub::Client#start_respirator | starting'}
|
70
|
+
|
71
|
+
if @env[:heartbeat] != @env[:respirator].interval
|
72
|
+
$logger.debug('Pubnub'){'Pubnub::Client#start_respirator | destroy old respirator'}
|
73
|
+
@env[:respirator].cancel
|
74
|
+
@env[:respirator] = nil
|
75
|
+
end if @env[:respirator]
|
76
|
+
|
77
|
+
@env[:respirator] = EM.add_periodic_timer((@env[:heartbeat].to_i/2) - 1) do
|
78
|
+
@env[:subscriptions].each do |origin, subscribe|
|
79
|
+
$logger.debug('Pubnub'){'Pubnub::Client#start_respirator | BUM'}
|
80
|
+
EM.defer { heartbeat(:channel => subscribe.get_channels){ |e| $logger.debug('Pubnub::Client#start_respirator | bum') } }
|
81
|
+
end
|
82
|
+
end unless @env[:respirator]
|
83
|
+
|
84
|
+
$logger.debug('Pubnub'){'Pubnub::Client#start_respirator | started'}
|
85
|
+
end
|
74
86
|
end
|
75
87
|
|
76
88
|
def start_subscribe(override = false)
|
77
89
|
|
78
90
|
start_event_machine
|
91
|
+
start_respirator if @env[:heartbeat]
|
79
92
|
|
80
93
|
if override
|
81
|
-
$logger.debug('Pubnub::Client#start_subscribe | Override'
|
94
|
+
$logger.debug('Pubnub'){'Pubnub::Client#start_subscribe | Override'}
|
82
95
|
@env[:subscribe_railgun].cancel
|
83
96
|
@env[:subscribe_railgun] = nil
|
84
97
|
@env[:wait_for_response].each do |k,v|
|
@@ -93,9 +106,9 @@ module Pubnub
|
|
93
106
|
unless @env[:wait_for_response][origin]
|
94
107
|
@env[:wait_for_response][origin] = true
|
95
108
|
|
96
|
-
$logger.debug('Async subscription running'
|
97
|
-
$logger.debug("origin: #{origin}"
|
98
|
-
$logger.debug("timetoken: #{@env[:timetoken]}"
|
109
|
+
$logger.debug('Pubnub'){'Async subscription running'}
|
110
|
+
$logger.debug('Pubnub'){"origin: #{origin}"}
|
111
|
+
$logger.debug('Pubnub'){"timetoken: #{@env[:timetoken]}"}
|
99
112
|
|
100
113
|
EM.defer do
|
101
114
|
subscribe.start_event(self) if subscribe
|
@@ -105,8 +118,8 @@ module Pubnub
|
|
105
118
|
end
|
106
119
|
end
|
107
120
|
rescue => e
|
108
|
-
$logger.error(e
|
109
|
-
$logger.error(e.backtrace
|
121
|
+
$logger.error('Pubnub'){e}
|
122
|
+
$logger.error('Pubnub'){e.backtrace}
|
110
123
|
end
|
111
124
|
end unless @env[:subscribe_railgun]
|
112
125
|
end
|
@@ -123,7 +136,7 @@ module Pubnub
|
|
123
136
|
|
124
137
|
def update_timetoken(timetoken)
|
125
138
|
@env[:timetoken] = timetoken.to_i
|
126
|
-
$logger.debug("Pubnub::Client#update_timetoken | Current timetoken is eq #{@env[:timetoken]}"
|
139
|
+
$logger.debug('Pubnub'){"Pubnub::Client#update_timetoken | Current timetoken is eq #{@env[:timetoken]}"}
|
127
140
|
end
|
128
141
|
|
129
142
|
def set_uuid(uuid)
|
@@ -141,6 +154,18 @@ module Pubnub
|
|
141
154
|
end
|
142
155
|
alias_method :auth_key=, :set_auth_key
|
143
156
|
|
157
|
+
def set_heartbeat(heartbeat = nil)
|
158
|
+
if heartbeat
|
159
|
+
@env[:heartbeat] = heartbeat
|
160
|
+
end
|
161
|
+
@env[:heartbeat]
|
162
|
+
end
|
163
|
+
alias_method :heartbeat=, :set_heartbeat
|
164
|
+
|
165
|
+
def get_heartbeat
|
166
|
+
@env[:heartbeat]
|
167
|
+
end
|
168
|
+
|
144
169
|
def set_cipher_key(cipher_key)
|
145
170
|
@env[:cipher_key] = cipher_key
|
146
171
|
end
|
@@ -148,9 +173,9 @@ module Pubnub
|
|
148
173
|
|
149
174
|
def start_railgun
|
150
175
|
if @env[:railgun]
|
151
|
-
$logger.debug('Pubnub::Client#start_railgun | Railgun already initialized'
|
176
|
+
$logger.debug('Pubnub'){'Pubnub::Client#start_railgun | Railgun already initialized'}
|
152
177
|
else
|
153
|
-
$logger.debug('Pubnub::Client#start_railgun | Initializing railgun'
|
178
|
+
$logger.debug('Pubnub'){'Pubnub::Client#start_railgun | Initializing railgun'}
|
154
179
|
@env[:railgun] = EM.add_periodic_timer(0.01) do
|
155
180
|
@async_events.each do |event|
|
156
181
|
EM.defer do
|
@@ -178,17 +203,17 @@ module Pubnub
|
|
178
203
|
end
|
179
204
|
|
180
205
|
def start_event_machine(options = nil)
|
181
|
-
$logger.debug
|
206
|
+
$logger.debug('Pubnub'){'Pubnub::Client#start_event_machine | starting EM in new thread'}
|
182
207
|
if defined?(Thin)
|
183
|
-
$logger.debug('Pubnub::Client#start_event_machine | We\'re running on thin'
|
208
|
+
$logger.debug('Pubnub'){'Pubnub::Client#start_event_machine | We\'re running on thin'}
|
184
209
|
else
|
185
|
-
$logger.debug('Pubnub::Client#start_event_machine | We aren\'t running on thin'
|
210
|
+
$logger.debug('Pubnub'){'Pubnub::Client#start_event_machine | We aren\'t running on thin'}
|
186
211
|
end
|
187
212
|
if EM.reactor_running?
|
188
|
-
$logger.debug
|
213
|
+
$logger.debug('Pubnub'){'Pubnub::Client#start_event_machine | EM already running'}
|
189
214
|
else
|
190
215
|
Thread.new { EM.run {} }
|
191
|
-
$logger.debug
|
216
|
+
$logger.debug('Pubnub'){'Pubnub::Client#start_event_machine | EM started in new thread'}
|
192
217
|
end
|
193
218
|
end
|
194
219
|
|
@@ -196,8 +221,9 @@ module Pubnub
|
|
196
221
|
$logger = options[:logger] || Logger.new('pubnub.log')
|
197
222
|
@env = symbolize_options_keys(options)
|
198
223
|
@env = set_default_values(@env)
|
224
|
+
@env.delete_if { |k,v| v.blank? } # nillify if blank
|
199
225
|
@async_events = Array.new
|
200
|
-
$logger.debug("\n\nCreated new Pubnub::Client instance"
|
226
|
+
$logger.debug('Pubnub'){"\n\nCreated new Pubnub::Client instance"}
|
201
227
|
end
|
202
228
|
|
203
229
|
def create_connections_pools(options)
|
@@ -226,7 +252,7 @@ module Pubnub
|
|
226
252
|
}
|
227
253
|
|
228
254
|
# Let's fill missing keys with default values
|
229
|
-
$logger.debug('Setting default values'
|
255
|
+
$logger.debug('Pubnub'){'Setting default values'}
|
230
256
|
defaults.each do |key,default_value|
|
231
257
|
env[key] = default_value if @env[key].nil?
|
232
258
|
end
|
@@ -235,7 +261,7 @@ module Pubnub
|
|
235
261
|
end
|
236
262
|
|
237
263
|
def symbolize_options_keys(options)
|
238
|
-
$logger.debug('Symbolizing options keys'
|
264
|
+
$logger.debug('Pubnub'){'Symbolizing options keys'}
|
239
265
|
symbolized_options = {}
|
240
266
|
options.each_key { |k| symbolized_options.merge!({ k.to_sym => options[k] }) }
|
241
267
|
symbolized_options
|
data/lib/pubnub/crypto.rb
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
module Pubnub
|
3
3
|
class Crypto
|
4
4
|
def initialize(cipher_key)
|
5
|
-
$logger.debug('Initializing Crypto'
|
5
|
+
$logger.debug('Pubnub'){'Initializing Crypto'}
|
6
6
|
@alg = 'AES-256-CBC'
|
7
7
|
sha256_key = Digest::SHA256.hexdigest(cipher_key)
|
8
8
|
@key = sha256_key.slice(0,32)
|
9
9
|
|
10
10
|
@iv = '0123456789012345'
|
11
|
-
$logger.debug('Initialized Crypto'
|
11
|
+
$logger.debug('Pubnub'){'Initialized Crypto'}
|
12
12
|
end
|
13
13
|
|
14
14
|
|
@@ -28,7 +28,7 @@ module Pubnub
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def decrypt(cipher_text)
|
31
|
-
$logger.debug("Decrypting: #{cipher_text}"
|
31
|
+
$logger.debug('Pubnub'){"Decrypting: #{cipher_text}"}
|
32
32
|
decode_cipher = OpenSSL::Cipher::Cipher.new(@alg)
|
33
33
|
decode_cipher.decrypt
|
34
34
|
decode_cipher.key = @key
|
@@ -41,8 +41,8 @@ module Pubnub
|
|
41
41
|
plain_text = decode_cipher.update(undecoded_text)
|
42
42
|
plain_text << decode_cipher.final
|
43
43
|
rescue => e
|
44
|
-
$logger.error
|
45
|
-
plain_text =
|
44
|
+
$logger.error('Pubnub'){'DECRYPTION ERROR'}
|
45
|
+
plain_text = '"DECRYPTION ERROR"'
|
46
46
|
end
|
47
47
|
|
48
48
|
begin
|
@@ -51,7 +51,7 @@ module Pubnub
|
|
51
51
|
JSON.load("[#{plain_text}]")[0] # srsly ruby? srsly?
|
52
52
|
end
|
53
53
|
|
54
|
-
$logger.debug('Finished decrypting'
|
54
|
+
$logger.debug('Pubnub'){'Finished decrypting'}
|
55
55
|
|
56
56
|
plain_text
|
57
57
|
|
data/lib/pubnub/event.rb
CHANGED
@@ -25,20 +25,21 @@ module Pubnub
|
|
25
25
|
validate!
|
26
26
|
@original_channel = format_channels(@channel, false)
|
27
27
|
@channel = format_channels(@channel)
|
28
|
-
$logger.debug("Event#initialize | Initialized #{self.class.to_s}"
|
28
|
+
$logger.debug('Pubnub'){"Event#initialize | Initialized #{self.class.to_s}"}
|
29
29
|
end
|
30
30
|
|
31
31
|
def fire(app)
|
32
|
+
$logger.debug('Pubnub'){'Pubnub::Event#fire'}
|
32
33
|
@fired = true
|
33
|
-
$logger.debug('Event#fire'
|
34
|
+
$logger.debug('Pubnub'){'Event#fire'}
|
34
35
|
setup_connection(app) unless connection_exist?(app)
|
35
36
|
envelopes = start_event(app)
|
36
37
|
end
|
37
38
|
|
38
39
|
def start_event(app, count = 0)
|
39
40
|
if count <= app.env[:max_retries]
|
40
|
-
$logger.debug('Event#start_event | sending request'
|
41
|
-
$logger.debug("Event#start_event | tt: #{@timetoken}; ctt #{app.env[:timetoken]}"
|
41
|
+
$logger.debug('Pubnub'){'Event#start_event | sending request'}
|
42
|
+
$logger.debug('Pubnub'){"Event#start_event | tt: #{@timetoken}; ctt #{app.env[:timetoken]}"}
|
42
43
|
@response = get_connection(app).request(uri(app))
|
43
44
|
end
|
44
45
|
|
@@ -58,7 +59,9 @@ module Pubnub
|
|
58
59
|
raise ArgumentError.new(:object => self, :message => 'Invalid channel(s) format! Should be type of: String, Symbol') unless valid_channel?(false)
|
59
60
|
end
|
60
61
|
|
61
|
-
|
62
|
+
unless @doesnt_require_callback
|
63
|
+
raise ArgumentError.new(:object => self, :message => 'Callback parameter is required while using async') if (!@http_sync && @callback.blank?)
|
64
|
+
end
|
62
65
|
|
63
66
|
end
|
64
67
|
|
@@ -80,7 +83,7 @@ module Pubnub
|
|
80
83
|
|
81
84
|
def handle_response(response, app, error)
|
82
85
|
|
83
|
-
$logger.debug('Event#handle_response'
|
86
|
+
$logger.debug('Pubnub'){'Event#handle_response'}
|
84
87
|
envelopes = format_envelopes(response, app, error)
|
85
88
|
update_app_timetoken(envelopes, app)
|
86
89
|
fire_callbacks(envelopes,app)
|
@@ -94,7 +97,7 @@ module Pubnub
|
|
94
97
|
end
|
95
98
|
|
96
99
|
def fire_callbacks(envelopes, app)
|
97
|
-
$logger.debug('Firing callbacks'
|
100
|
+
$logger.debug('Pubnub'){'Firing callbacks'}
|
98
101
|
envelopes.each do |envelope|
|
99
102
|
@callback.call(envelope) if !envelope.error && @callback && !envelope.timetoken_update
|
100
103
|
#if envelope.timetoken_update || envelope.timetoken.to_i > app.env[:timetoken].to_i
|
@@ -108,11 +111,11 @@ module Pubnub
|
|
108
111
|
def update_timetoken(app, timetoken)
|
109
112
|
@timetoken = timetoken.to_i
|
110
113
|
app.update_timetoken(timetoken.to_i)
|
111
|
-
$logger.debug("Updated timetoken to #{timetoken}"
|
114
|
+
$logger.debug('Pubnub'){"Updated timetoken to #{timetoken}"}
|
112
115
|
end
|
113
116
|
|
114
117
|
def add_common_data_to_envelopes(envelopes, response, app, error)
|
115
|
-
$logger.debug('Event#add_common_data_to_envelopes'
|
118
|
+
$logger.debug('Pubnub'){'Event#add_common_data_to_envelopes'}
|
116
119
|
|
117
120
|
envelopes.each do |envelope|
|
118
121
|
envelope.response = response.body
|
@@ -176,7 +179,7 @@ module Pubnub
|
|
176
179
|
end
|
177
180
|
|
178
181
|
def uri(app)
|
179
|
-
$logger.debug("#{self.class}#uri #{[origin(app), path(app), '?', params_hash_to_url_params(parameters(app))].join}"
|
182
|
+
$logger.debug('Pubnub'){"#{self.class}#uri #{[origin(app), path(app), '?', params_hash_to_url_params(parameters(app))].join}"}
|
180
183
|
URI [origin(app), path(app), '?', params_hash_to_url_params(parameters(app))].join
|
181
184
|
end
|
182
185
|
|
@@ -187,15 +190,15 @@ module Pubnub
|
|
187
190
|
|
188
191
|
def parameters(app)
|
189
192
|
required = {
|
190
|
-
:auth => @auth_key,
|
191
193
|
:pnsdk => "PubNub-Ruby/#{Pubnub::VERSION}"
|
192
194
|
}
|
193
195
|
|
194
196
|
empty_if_blank = {
|
197
|
+
:auth => @auth_key,
|
195
198
|
:uuid => app.env[:uuid]
|
196
199
|
}
|
197
200
|
|
198
|
-
empty_if_blank.delete_if {|k, v| v.
|
201
|
+
empty_if_blank.delete_if {|k, v| v.blank? }
|
199
202
|
|
200
203
|
required.merge(empty_if_blank)
|
201
204
|
end
|
@@ -205,17 +208,17 @@ module Pubnub
|
|
205
208
|
module SingleEvent
|
206
209
|
|
207
210
|
def fire(app)
|
208
|
-
$logger.debug('Pubnub::SingleEvent#fire'
|
211
|
+
$logger.debug('Pubnub'){'Pubnub::SingleEvent#fire'}
|
209
212
|
if @http_sync
|
210
|
-
$logger.debug('Pubnub::SingleEvent#fire | Sync event!'
|
213
|
+
$logger.debug('Pubnub'){'Pubnub::SingleEvent#fire | Sync event!'}
|
211
214
|
super(app)
|
212
215
|
elsif app.async_events.include? self
|
213
|
-
$logger.debug('Pubnub::SingleEvent#fire | Event already on list!'
|
216
|
+
$logger.debug('Pubnub'){'Pubnub::SingleEvent#fire | Event already on list!'}
|
214
217
|
super(app)
|
215
218
|
else
|
216
|
-
$logger.debug('Pubnub::SingleEvent#fire | Adding event to async_events'
|
219
|
+
$logger.debug('Pubnub'){'Pubnub::SingleEvent#fire | Adding event to async_events'}
|
217
220
|
app.async_events << self
|
218
|
-
$logger.debug('Pubnub::SingleEvent#fire | Starting railgun'
|
221
|
+
$logger.debug('Pubnub'){'Pubnub::SingleEvent#fire | Starting railgun'}
|
219
222
|
app.start_railgun
|
220
223
|
end
|
221
224
|
end
|
@@ -238,32 +241,41 @@ module Pubnub
|
|
238
241
|
connection = Net::HTTP::Persistent.new "pubnub_ruby_client_v#{Pubnub::VERSION}"
|
239
242
|
connection.idle_timeout = app.env[:timeout]
|
240
243
|
connection.read_timeout = app.env[:timeout]
|
244
|
+
connection.proxy_from_env
|
241
245
|
connection
|
242
246
|
end
|
243
247
|
end
|
244
248
|
|
245
249
|
module SubscribeEvent
|
246
|
-
|
247
|
-
|
248
250
|
def fire(app)
|
249
251
|
begin
|
250
|
-
$logger.debug('SubscribeEvent#fire'
|
252
|
+
$logger.debug('Pubnub'){'SubscribeEvent#fire'}
|
251
253
|
if @http_sync
|
252
|
-
$logger.debug('SubscribeEvent#fire sync'
|
253
|
-
|
254
|
+
$logger.debug('Pubnub'){'SubscribeEvent#fire sync'}
|
255
|
+
if self.class == Pubnub::Subscribe && app.env[:heartbeat]
|
256
|
+
app.heartbeat(:channel => @channel, :http_sync => true)
|
257
|
+
envelopes = super
|
258
|
+
@channel.each do |channel|
|
259
|
+
app.leave(:channel => channel, :http_sync => true, :skip_remove => true, :force => true) unless (app.env[:subscriptions][@origin] && app.env[:subscriptions][@origin].get_channels.include(channel))
|
260
|
+
end
|
261
|
+
else
|
262
|
+
envelopes = super
|
263
|
+
end
|
264
|
+
envelopes
|
254
265
|
else
|
255
|
-
$logger.debug('SubscribeEvent#fire async'
|
256
|
-
$logger.debug("Channel: #{@channel}"
|
266
|
+
$logger.debug('Pubnub'){'SubscribeEvent#fire async'}
|
267
|
+
$logger.debug('Pubnub'){"Channel: #{@channel}"}
|
257
268
|
setup_connection(app) unless connection_exist?(app)
|
258
269
|
unless app.env[:subscriptions][@origin].blank?
|
259
270
|
@channel.each do |channel|
|
260
271
|
if app.env[:subscriptions][@origin].get_channels.include?(channel)
|
261
272
|
@channel.delete(channel)
|
262
|
-
$logger.error("Already subscribed to channel #{channel}, you have to leave that channel first"
|
273
|
+
$logger.error('Pubnub'){"Already subscribed to channel #{channel}, you have to leave that channel first"}
|
263
274
|
end
|
264
|
-
$logger.debug('SubscribeEvent#add_channel | Adding channel'
|
275
|
+
$logger.debug('Pubnub'){'SubscribeEvent#add_channel | Adding channel'}
|
265
276
|
app.env[:subscriptions][@origin].add_channel(channel, app)
|
266
277
|
end
|
278
|
+
app.start_respirator
|
267
279
|
end
|
268
280
|
|
269
281
|
if app.env[:subscriptions][@origin].nil?
|
@@ -291,7 +303,7 @@ module Pubnub
|
|
291
303
|
|
292
304
|
end
|
293
305
|
rescue => error
|
294
|
-
$logger.error(error
|
306
|
+
$logger.error('Pubnub'){error}
|
295
307
|
end
|
296
308
|
end
|
297
309
|
|
@@ -301,17 +313,17 @@ module Pubnub
|
|
301
313
|
|
302
314
|
def add_channel(channel, app)
|
303
315
|
@channel = @channel + format_channels(channel)
|
304
|
-
$logger.debug('SubscribeEvent#add_channel | Added channel'
|
316
|
+
$logger.debug('Pubnub'){'SubscribeEvent#add_channel | Added channel'}
|
305
317
|
end
|
306
318
|
|
307
319
|
def remove_channel(channel, app)
|
308
320
|
@channel = @channel - format_channels(channel)
|
309
|
-
$logger.debug('SubscribeEvent#remove_channel | Removed channel'
|
321
|
+
$logger.debug('Pubnub'){'SubscribeEvent#remove_channel | Removed channel'}
|
310
322
|
begin
|
311
323
|
shutdown_subscribe(app) if @channel.empty?
|
312
324
|
rescue => e
|
313
|
-
$logger.error(e.message
|
314
|
-
$logger.error(e.backtrace
|
325
|
+
$logger.error('Pubnub'){e.message}
|
326
|
+
$logger.error('Pubnub'){e.backtrace}
|
315
327
|
end
|
316
328
|
end
|
317
329
|
|
@@ -321,8 +333,14 @@ module Pubnub
|
|
321
333
|
|
322
334
|
private
|
323
335
|
|
336
|
+
def parameters(app)
|
337
|
+
parameters = super(app)
|
338
|
+
parameters.merge!({:heartbeat => app.env[:heartbeat]}) if app.env[:heartbeat]
|
339
|
+
parameters
|
340
|
+
end
|
341
|
+
|
324
342
|
def update_app_timetoken(envelopes, app)
|
325
|
-
$logger.debug('Event#update_app_timetoken'
|
343
|
+
$logger.debug('Pubnub'){'Event#update_app_timetoken'}
|
326
344
|
envelopes.each do |envelope|
|
327
345
|
if envelope.timetoken_update || envelope.timetoken.to_i > app.env[:timetoken].to_i
|
328
346
|
update_timetoken(app, envelope.timetoken)
|
@@ -346,15 +364,15 @@ module Pubnub
|
|
346
364
|
super
|
347
365
|
else
|
348
366
|
begin
|
349
|
-
$logger.debug('Event#fire_callbacks async'
|
367
|
+
$logger.debug('Pubnub'){'Event#fire_callbacks async'}
|
350
368
|
envelopes.each do |envelope|
|
351
369
|
app.env[:callbacks_pool][@origin][envelope.channel][:callback].call(envelope) if !envelope.error && !envelope.timetoken_update
|
352
370
|
end
|
353
|
-
$logger.debug('We can send next request now'
|
371
|
+
$logger.debug('Pubnub'){'We can send next request now'}
|
354
372
|
app.env[:error_callbacks_pool][@origin].call(envelopes.first) if envelopes.first.error
|
355
373
|
rescue => error
|
356
|
-
$logger.error(error
|
357
|
-
$logger.error(error.backtrace
|
374
|
+
$logger.error('Pubnub'){error}
|
375
|
+
$logger.error('Pubnub'){error.backtrace}
|
358
376
|
end
|
359
377
|
end unless envelopes.nil?
|
360
378
|
|
@@ -395,15 +413,15 @@ module Pubnub
|
|
395
413
|
|
396
414
|
def format_envelopes(response, app, error)
|
397
415
|
|
398
|
-
$logger.debug('Subscribe#format_envelopes'
|
416
|
+
$logger.debug('Pubnub'){'Subscribe#format_envelopes'}
|
399
417
|
|
400
418
|
parsed_response = Parser.parse_json(response.body) if Parser.valid_json?(response.body)
|
401
419
|
|
402
|
-
$logger.debug('Subscribe#format_envelopes | Response parsed'
|
420
|
+
$logger.debug('Pubnub'){'Subscribe#format_envelopes | Response parsed'}
|
403
421
|
|
404
422
|
envelopes = Array.new
|
405
423
|
if error
|
406
|
-
$logger.debug('Subscribe#format_envelopes | Error'
|
424
|
+
$logger.debug('Pubnub'){'Subscribe#format_envelopes | Error'}
|
407
425
|
envelopes << Envelope.new(
|
408
426
|
{
|
409
427
|
:channel => @channel,
|
@@ -412,7 +430,7 @@ module Pubnub
|
|
412
430
|
app
|
413
431
|
)
|
414
432
|
elsif parsed_response[0].empty?
|
415
|
-
$logger.debug('Subscribe#format_envelopes | Timetoken'
|
433
|
+
$logger.debug('Pubnub'){'Subscribe#format_envelopes | Timetoken'}
|
416
434
|
envelopes << Envelope.new(
|
417
435
|
{
|
418
436
|
:channel => @channel.first,
|
@@ -423,7 +441,7 @@ module Pubnub
|
|
423
441
|
app
|
424
442
|
)
|
425
443
|
else
|
426
|
-
$logger.debug('Subscribe#format_envelopes | Not timetoken update'
|
444
|
+
$logger.debug('Pubnub'){'Subscribe#format_envelopes | Not timetoken update'}
|
427
445
|
parsed_response[0].size.times do |i|
|
428
446
|
if parsed_response[2].is_a? Array
|
429
447
|
channel = parsed_response[2][i]
|
@@ -432,9 +450,9 @@ module Pubnub
|
|
432
450
|
else
|
433
451
|
channel = @channel.first
|
434
452
|
end
|
435
|
-
$logger.debug('Subscribe#format_envelopes | Channel created'
|
453
|
+
$logger.debug('Pubnub'){'Subscribe#format_envelopes | Channel created'}
|
436
454
|
|
437
|
-
$logger.debug("#{parsed_response}"
|
455
|
+
$logger.debug('Pubnub'){"#{parsed_response}"}
|
438
456
|
|
439
457
|
envelopes << Envelope.new(
|
440
458
|
{
|
@@ -446,12 +464,12 @@ module Pubnub
|
|
446
464
|
app
|
447
465
|
)
|
448
466
|
|
449
|
-
$logger.debug('Subscribe#format_envelopes | Envelopes created'
|
467
|
+
$logger.debug('Pubnub'){'Subscribe#format_envelopes | Envelopes created'}
|
450
468
|
|
451
469
|
end
|
452
470
|
end
|
453
471
|
|
454
|
-
$logger.debug('Subscribe#format_envelopes | envelopes created'
|
472
|
+
$logger.debug('Pubnub'){'Subscribe#format_envelopes | envelopes created'}
|
455
473
|
|
456
474
|
envelopes = add_common_data_to_envelopes(envelopes, response, app, error)
|
457
475
|
|
@@ -464,6 +482,7 @@ module Pubnub
|
|
464
482
|
connection.idle_timeout = app.env[:subscribe_timeout]
|
465
483
|
connection.read_timeout = app.env[:subscribe_timeout]
|
466
484
|
@connect_callback.call "New subscribe connection to #{@origin}"
|
485
|
+
connection.proxy_from_env
|
467
486
|
connection
|
468
487
|
end
|
469
488
|
end
|