pubnub 4.0.19 → 4.0.20
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 +30 -1
- data/.rubocop.yml +4 -1
- data/.travis.yml +7 -8
- data/Gemfile +1 -1
- data/README.md +2 -1
- data/VERSION +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/1.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/101.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/103.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/105.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/107.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/109.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/11.yml +4 -4
- data/fixtures/vcr_cassettes/examples/subscribe/111.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/113.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/115.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/117.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/119.yml +2 -2
- data/fixtures/vcr_cassettes/examples/subscribe/121.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/123.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/125.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/127.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/129.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/13.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/131.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/133.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/135.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/137.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/139.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/141.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/143.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/145.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/147.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/149.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/15.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/151.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/153.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/155.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/157.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/159.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/161.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/163.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/165.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/167.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/169.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/17.yml +3 -3
- data/fixtures/vcr_cassettes/examples/subscribe/171.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/173.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/175.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/177.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/179.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/181.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/183.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/185.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/187.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/189.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/19.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/191.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/193.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/195.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/197.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/199.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/201.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/203.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/205.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/207.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/209.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/21.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/211.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/213.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/215.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/217.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/219.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/221.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/223.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/225.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/227.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/229.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/23.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/231.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/233.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/235.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/237.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/239.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/241.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/243.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/245.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/247.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/249.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/25.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/251.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/253.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/255.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/257.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/259.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/261.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/263.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/265.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/267.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/269.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/27.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/271.yml +2 -2
- data/fixtures/vcr_cassettes/examples/subscribe/273.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/275.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/277.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/279.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/281.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/283.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/285.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/287.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/289.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/29.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/291.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/293.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/295.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/297.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/299.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/3.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/301.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/303.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/305.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/307.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/309.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/31.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/311.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/313.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/315.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/317.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/319.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/321.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/323.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/325.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/327.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/329.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/33.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/331.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/333.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/335.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/337.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/339.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/341.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/343.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/345.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/347.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/349.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/35.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/351.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/353.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/355.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/357.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/359.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/361.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/363.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/365.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/367.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/369.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/37.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/371.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/379.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/381.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/383.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/385.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/387.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/389.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/39.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/397.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/399.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/401.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/403.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/405.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/407.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/41.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/415.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/417.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/419.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/421.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/423.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/425.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/43.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/433.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/435.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/437.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/439.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/441.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/443.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/45.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/47.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/49.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/5.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/51.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/53.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/55.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/57.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/59.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/61.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/63.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/65.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/67.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/69.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/7.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/71.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/73.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/75.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/77.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/79.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/81.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/83.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/85.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/87.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/89.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/9.yml +2 -2
- data/fixtures/vcr_cassettes/examples/subscribe/91.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/93.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/95.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/97.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/99.yml +1 -1
- data/fixtures/vcr_cassettes/lib/callable_cipher_key.yml +78 -0
- data/fixtures/vcr_cassettes/lib/events/heartbeat-sub.yml +46 -3
- data/fixtures/vcr_cassettes/lib/events/presence_delta.yml +193 -0
- data/fixtures/vcr_cassettes/lib/multiple_ciphers.yml +188 -0
- data/fixtures/vcr_cassettes/lib/multiple_ciphers_history.yml +163 -0
- data/lib/pubnub/client/getters_setters.rb +127 -0
- data/lib/pubnub/client.rb +3 -112
- data/lib/pubnub/configuration.rb +1 -1
- data/lib/pubnub/constants.rb +5 -2
- data/lib/pubnub/crypto.rb +5 -5
- data/lib/pubnub/event/formatter.rb +45 -0
- data/lib/pubnub/event/signature.rb +41 -0
- data/lib/pubnub/event.rb +41 -97
- data/lib/pubnub/events/history.rb +4 -3
- data/lib/pubnub/events/publish.rb +37 -37
- data/lib/pubnub/formatter.rb +1 -1
- data/lib/pubnub/pam.rb +9 -9
- data/lib/pubnub/single_event.rb +1 -1
- data/lib/pubnub/subscribe_event/formatter.rb +4 -4
- data/lib/pubnub/subscriber.rb +28 -28
- data/lib/pubnub/validators/client.rb +1 -1
- data/lib/pubnub/validators/common_validator.rb +2 -2
- data/lib/pubnub/version.rb +1 -1
- data/pubnub.gemspec +0 -2
- data/spec/examples/presence_examples_spec.rb +2 -1
- data/spec/examples/subscribe_examples_spec.rb +1080 -1080
- data/spec/lib/client_spec.rb +5 -5
- data/spec/lib/events/presence_delta_spec.rb +38 -0
- data/spec/lib/multiple_ciphers_spec.rb +145 -0
- data/spec/spec_helper.rb +2 -2
- metadata +15 -7
@@ -0,0 +1,188 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://ps.pndsn.com/v2/subscribe/demo/multiple_cipher_test/0?pnsdk=PubNub-Ruby/4.0.19&t=%7B%22r%22:0,%22t%22:0%7D&uuid=f14f63f0-fbbc-48eb-931e-cd8af0e0278c
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- HTTPClient/1.0 (2.8.3, ruby 2.4.1 (2017-03-22))
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
Date:
|
15
|
+
- Mon, 27 Mar 2017 14:27:13 GMT
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Mon, 27 Mar 2017 14:27:13 GMT
|
23
|
+
Content-Type:
|
24
|
+
- text/javascript; charset="UTF-8"
|
25
|
+
Content-Length:
|
26
|
+
- '45'
|
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":"14906248338299636","r":12},"m":[]}'
|
38
|
+
http_version:
|
39
|
+
recorded_at: Mon, 27 Mar 2017 14:27:13 GMT
|
40
|
+
- request:
|
41
|
+
method: get
|
42
|
+
uri: http://ps.pndsn.com/publish/demo/demo/0/multiple_cipher_test/0/%22SiyiTt6E/g36egfcDEavKiHNqBjq0sV4n1AIukd+QPg=%22?ortt=%7B%22t%22:14906248339973000%7D&pnsdk=PubNub-Ruby/4.0.19&seqn=1&uuid=f14f63f0-fbbc-48eb-931e-cd8af0e0278c
|
43
|
+
body:
|
44
|
+
encoding: UTF-8
|
45
|
+
string: ''
|
46
|
+
headers:
|
47
|
+
User-Agent:
|
48
|
+
- HTTPClient/1.0 (2.8.3, ruby 2.4.1 (2017-03-22))
|
49
|
+
Accept:
|
50
|
+
- "*/*"
|
51
|
+
Date:
|
52
|
+
- Mon, 27 Mar 2017 14:27:14 GMT
|
53
|
+
response:
|
54
|
+
status:
|
55
|
+
code: 200
|
56
|
+
message: OK
|
57
|
+
headers:
|
58
|
+
Date:
|
59
|
+
- Mon, 27 Mar 2017 14:27:14 GMT
|
60
|
+
Content-Type:
|
61
|
+
- text/javascript; charset="UTF-8"
|
62
|
+
Content-Length:
|
63
|
+
- '30'
|
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: '[1,"Sent","14906248340470284"]'
|
75
|
+
http_version:
|
76
|
+
recorded_at: Mon, 27 Mar 2017 14:27:14 GMT
|
77
|
+
- request:
|
78
|
+
method: get
|
79
|
+
uri: http://ps.pndsn.com/v2/subscribe/demo/multiple_cipher_test/0?pnsdk=PubNub-Ruby/4.0.19&t=%7B%22r%22:12,%22t%22:%2214906248338299636%22%7D&uuid=f14f63f0-fbbc-48eb-931e-cd8af0e0278c
|
80
|
+
body:
|
81
|
+
encoding: UTF-8
|
82
|
+
string: ''
|
83
|
+
headers:
|
84
|
+
User-Agent:
|
85
|
+
- HTTPClient/1.0 (2.8.3, ruby 2.4.1 (2017-03-22))
|
86
|
+
Accept:
|
87
|
+
- "*/*"
|
88
|
+
Date:
|
89
|
+
- Mon, 27 Mar 2017 14:27:14 GMT
|
90
|
+
response:
|
91
|
+
status:
|
92
|
+
code: 200
|
93
|
+
message: OK
|
94
|
+
headers:
|
95
|
+
Date:
|
96
|
+
- Mon, 27 Mar 2017 14:27:14 GMT
|
97
|
+
Content-Type:
|
98
|
+
- text/javascript; charset="UTF-8"
|
99
|
+
Content-Length:
|
100
|
+
- '267'
|
101
|
+
Connection:
|
102
|
+
- keep-alive
|
103
|
+
Cache-Control:
|
104
|
+
- no-cache
|
105
|
+
Access-Control-Allow-Origin:
|
106
|
+
- "*"
|
107
|
+
Access-Control-Allow-Methods:
|
108
|
+
- GET
|
109
|
+
body:
|
110
|
+
encoding: UTF-8
|
111
|
+
string: '{"t":{"t":"14906248340566552","r":12},"m":[{"a":"1","f":514,"i":"f14f63f0-fbbc-48eb-931e-cd8af0e0278c","s":1,"o":{"t":"14906248339973000"},"p":{"t":"14906248340470284","r":12},"k":"demo","c":"multiple_cipher_test","d":"SiyiTt6E/g36egfcDEavKiHNqBjq0sV4n1AIukd+QPg="}]}'
|
112
|
+
http_version:
|
113
|
+
recorded_at: Mon, 27 Mar 2017 14:27:14 GMT
|
114
|
+
- request:
|
115
|
+
method: get
|
116
|
+
uri: http://ps.pndsn.com/publish/demo/demo/0/multiple_cipher_test/0/%22MkZas2KYXTSswsWBK2v+TFREAnNoI72Fi+2yiANzxbI=%22?ortt=%7B%22t%22:14906248341698080%7D&pnsdk=PubNub-Ruby/4.0.19&seqn=2&uuid=f14f63f0-fbbc-48eb-931e-cd8af0e0278c
|
117
|
+
body:
|
118
|
+
encoding: UTF-8
|
119
|
+
string: ''
|
120
|
+
headers:
|
121
|
+
User-Agent:
|
122
|
+
- HTTPClient/1.0 (2.8.3, ruby 2.4.1 (2017-03-22))
|
123
|
+
Accept:
|
124
|
+
- "*/*"
|
125
|
+
Date:
|
126
|
+
- Mon, 27 Mar 2017 14:27:14 GMT
|
127
|
+
response:
|
128
|
+
status:
|
129
|
+
code: 200
|
130
|
+
message: OK
|
131
|
+
headers:
|
132
|
+
Date:
|
133
|
+
- Mon, 27 Mar 2017 14:27:14 GMT
|
134
|
+
Content-Type:
|
135
|
+
- text/javascript; charset="UTF-8"
|
136
|
+
Content-Length:
|
137
|
+
- '30'
|
138
|
+
Connection:
|
139
|
+
- keep-alive
|
140
|
+
Cache-Control:
|
141
|
+
- no-cache
|
142
|
+
Access-Control-Allow-Origin:
|
143
|
+
- "*"
|
144
|
+
Access-Control-Allow-Methods:
|
145
|
+
- GET
|
146
|
+
body:
|
147
|
+
encoding: UTF-8
|
148
|
+
string: '[1,"Sent","14906248341647937"]'
|
149
|
+
http_version:
|
150
|
+
recorded_at: Mon, 27 Mar 2017 14:27:14 GMT
|
151
|
+
- request:
|
152
|
+
method: get
|
153
|
+
uri: http://ps.pndsn.com/v2/subscribe/demo/multiple_cipher_test/0?pnsdk=PubNub-Ruby/4.0.19&t=%7B%22r%22:12,%22t%22:%2214906248340566552%22%7D&uuid=f14f63f0-fbbc-48eb-931e-cd8af0e0278c
|
154
|
+
body:
|
155
|
+
encoding: UTF-8
|
156
|
+
string: ''
|
157
|
+
headers:
|
158
|
+
User-Agent:
|
159
|
+
- HTTPClient/1.0 (2.8.3, ruby 2.4.1 (2017-03-22))
|
160
|
+
Accept:
|
161
|
+
- "*/*"
|
162
|
+
Date:
|
163
|
+
- Mon, 27 Mar 2017 14:27:14 GMT
|
164
|
+
response:
|
165
|
+
status:
|
166
|
+
code: 200
|
167
|
+
message: OK
|
168
|
+
headers:
|
169
|
+
Date:
|
170
|
+
- Mon, 27 Mar 2017 14:27:14 GMT
|
171
|
+
Content-Type:
|
172
|
+
- text/javascript; charset="UTF-8"
|
173
|
+
Content-Length:
|
174
|
+
- '267'
|
175
|
+
Connection:
|
176
|
+
- keep-alive
|
177
|
+
Cache-Control:
|
178
|
+
- no-cache
|
179
|
+
Access-Control-Allow-Origin:
|
180
|
+
- "*"
|
181
|
+
Access-Control-Allow-Methods:
|
182
|
+
- GET
|
183
|
+
body:
|
184
|
+
encoding: UTF-8
|
185
|
+
string: '{"t":{"t":"14906248341665599","r":12},"m":[{"a":"1","f":514,"i":"f14f63f0-fbbc-48eb-931e-cd8af0e0278c","s":2,"o":{"t":"14906248341698080"},"p":{"t":"14906248341647937","r":12},"k":"demo","c":"multiple_cipher_test","d":"MkZas2KYXTSswsWBK2v+TFREAnNoI72Fi+2yiANzxbI="}]}'
|
186
|
+
http_version:
|
187
|
+
recorded_at: Mon, 27 Mar 2017 14:27:14 GMT
|
188
|
+
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,163 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://ps.pndsn.com/publish/demo/demo/0/multiple_cipher_test/0/%22SiyiTt6E/g36egfcDEavKiHNqBjq0sV4n1AIukd+QPg=%22?ortt=%7B%22t%22:14906293412452538%7D&pnsdk=PubNub-Ruby/4.0.19&seqn=1&uuid=3c65b963-1f7f-4a7b-97d1-e71b684ece5d
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- HTTPClient/1.0 (2.8.3, ruby 2.4.1 (2017-03-22))
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
Date:
|
15
|
+
- Mon, 27 Mar 2017 15:42:21 GMT
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Mon, 27 Mar 2017 15:42:21 GMT
|
23
|
+
Content-Type:
|
24
|
+
- text/javascript; charset="UTF-8"
|
25
|
+
Content-Length:
|
26
|
+
- '30'
|
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: '[1,"Sent","14906293411842868"]'
|
38
|
+
http_version:
|
39
|
+
recorded_at: Mon, 27 Mar 2017 15:42:21 GMT
|
40
|
+
- request:
|
41
|
+
method: get
|
42
|
+
uri: http://ps.pndsn.com/v2/history/sub-key/demo/channel/multiple_cipher_test?count=1&pnsdk=PubNub-Ruby/4.0.19&uuid=3c65b963-1f7f-4a7b-97d1-e71b684ece5d
|
43
|
+
body:
|
44
|
+
encoding: UTF-8
|
45
|
+
string: ''
|
46
|
+
headers:
|
47
|
+
User-Agent:
|
48
|
+
- HTTPClient/1.0 (2.8.3, ruby 2.4.1 (2017-03-22))
|
49
|
+
Accept:
|
50
|
+
- "*/*"
|
51
|
+
Date:
|
52
|
+
- Mon, 27 Mar 2017 15:42:22 GMT
|
53
|
+
response:
|
54
|
+
status:
|
55
|
+
code: 200
|
56
|
+
message: OK
|
57
|
+
headers:
|
58
|
+
Date:
|
59
|
+
- Mon, 27 Mar 2017 15:42:22 GMT
|
60
|
+
Content-Type:
|
61
|
+
- text/javascript; charset="UTF-8"
|
62
|
+
Content-Length:
|
63
|
+
- '86'
|
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
|
+
Accept-Ranges:
|
73
|
+
- bytes
|
74
|
+
Age:
|
75
|
+
- '0'
|
76
|
+
Server:
|
77
|
+
- Pubnub
|
78
|
+
body:
|
79
|
+
encoding: UTF-8
|
80
|
+
string: '[["SiyiTt6E/g36egfcDEavKiHNqBjq0sV4n1AIukd+QPg="],14906293411842868,14906293411842868]'
|
81
|
+
http_version:
|
82
|
+
recorded_at: Mon, 27 Mar 2017 15:42:22 GMT
|
83
|
+
- request:
|
84
|
+
method: get
|
85
|
+
uri: http://ps.pndsn.com/publish/demo/demo/0/multiple_cipher_test/0/%22MkZas2KYXTSswsWBK2v+TFREAnNoI72Fi+2yiANzxbI=%22?ortt=%7B%22t%22:14906293424201470%7D&pnsdk=PubNub-Ruby/4.0.19&seqn=2&uuid=3c65b963-1f7f-4a7b-97d1-e71b684ece5d
|
86
|
+
body:
|
87
|
+
encoding: UTF-8
|
88
|
+
string: ''
|
89
|
+
headers:
|
90
|
+
User-Agent:
|
91
|
+
- HTTPClient/1.0 (2.8.3, ruby 2.4.1 (2017-03-22))
|
92
|
+
Accept:
|
93
|
+
- "*/*"
|
94
|
+
Date:
|
95
|
+
- Mon, 27 Mar 2017 15:42:22 GMT
|
96
|
+
response:
|
97
|
+
status:
|
98
|
+
code: 200
|
99
|
+
message: OK
|
100
|
+
headers:
|
101
|
+
Date:
|
102
|
+
- Mon, 27 Mar 2017 15:42:22 GMT
|
103
|
+
Content-Type:
|
104
|
+
- text/javascript; charset="UTF-8"
|
105
|
+
Content-Length:
|
106
|
+
- '30'
|
107
|
+
Connection:
|
108
|
+
- keep-alive
|
109
|
+
Cache-Control:
|
110
|
+
- no-cache
|
111
|
+
Access-Control-Allow-Origin:
|
112
|
+
- "*"
|
113
|
+
Access-Control-Allow-Methods:
|
114
|
+
- GET
|
115
|
+
body:
|
116
|
+
encoding: UTF-8
|
117
|
+
string: '[1,"Sent","14906293423103762"]'
|
118
|
+
http_version:
|
119
|
+
recorded_at: Mon, 27 Mar 2017 15:42:22 GMT
|
120
|
+
- request:
|
121
|
+
method: get
|
122
|
+
uri: http://ps.pndsn.com/v2/history/sub-key/demo/channel/multiple_cipher_test?count=1&pnsdk=PubNub-Ruby/4.0.19&uuid=3c65b963-1f7f-4a7b-97d1-e71b684ece5d
|
123
|
+
body:
|
124
|
+
encoding: UTF-8
|
125
|
+
string: ''
|
126
|
+
headers:
|
127
|
+
User-Agent:
|
128
|
+
- HTTPClient/1.0 (2.8.3, ruby 2.4.1 (2017-03-22))
|
129
|
+
Accept:
|
130
|
+
- "*/*"
|
131
|
+
Date:
|
132
|
+
- Mon, 27 Mar 2017 15:42:23 GMT
|
133
|
+
response:
|
134
|
+
status:
|
135
|
+
code: 200
|
136
|
+
message: OK
|
137
|
+
headers:
|
138
|
+
Date:
|
139
|
+
- Mon, 27 Mar 2017 15:42:23 GMT
|
140
|
+
Content-Type:
|
141
|
+
- text/javascript; charset="UTF-8"
|
142
|
+
Content-Length:
|
143
|
+
- '86'
|
144
|
+
Connection:
|
145
|
+
- keep-alive
|
146
|
+
Cache-Control:
|
147
|
+
- no-cache
|
148
|
+
Access-Control-Allow-Origin:
|
149
|
+
- "*"
|
150
|
+
Access-Control-Allow-Methods:
|
151
|
+
- GET
|
152
|
+
Accept-Ranges:
|
153
|
+
- bytes
|
154
|
+
Age:
|
155
|
+
- '0'
|
156
|
+
Server:
|
157
|
+
- Pubnub
|
158
|
+
body:
|
159
|
+
encoding: UTF-8
|
160
|
+
string: '[["MkZas2KYXTSswsWBK2v+TFREAnNoI72Fi+2yiANzxbI="],14906293423103762,14906293423103762]'
|
161
|
+
http_version:
|
162
|
+
recorded_at: Mon, 27 Mar 2017 15:42:23 GMT
|
163
|
+
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# Toplevel Pubnub module.
|
2
|
+
module Pubnub
|
3
|
+
# Pubnub client Class
|
4
|
+
class Client
|
5
|
+
# Module that holds some getters and setters
|
6
|
+
module GettersSetters
|
7
|
+
def sdk_version
|
8
|
+
"PubNub-Ruby/#{Pubnub::VERSION}"
|
9
|
+
end
|
10
|
+
|
11
|
+
# Parameters:
|
12
|
+
# ===========
|
13
|
+
# <dl>
|
14
|
+
# <dt>uuid</dt>
|
15
|
+
# <dd>New uuid to be set.</dd>
|
16
|
+
# </dl>
|
17
|
+
#
|
18
|
+
# Returns:
|
19
|
+
# ========
|
20
|
+
# New uuid.
|
21
|
+
#
|
22
|
+
# Functionality:
|
23
|
+
# ==============
|
24
|
+
# Can't change uuid while subscribed. You have to leave every subscribed channel.
|
25
|
+
def change_uuid(uuid)
|
26
|
+
Pubnub.logger.debug('Pubnub::Client') { 'Changing uuid' }
|
27
|
+
if subscribed?
|
28
|
+
fail('Cannot change UUID while subscribed.')
|
29
|
+
else
|
30
|
+
@env[:uuid] = uuid
|
31
|
+
end
|
32
|
+
end
|
33
|
+
alias_method :session_uuid=, :change_uuid
|
34
|
+
alias_method :uuid=, :change_uuid
|
35
|
+
alias_method :set_uuid=, :change_uuid
|
36
|
+
|
37
|
+
# Returns:
|
38
|
+
# ========
|
39
|
+
# Current origin.
|
40
|
+
def current_origin
|
41
|
+
@env[:origin]
|
42
|
+
end
|
43
|
+
alias_method :origin, :current_origin
|
44
|
+
|
45
|
+
# Returns:
|
46
|
+
# ========
|
47
|
+
# Origin that was set.
|
48
|
+
def origin=(origin)
|
49
|
+
@env[:origin] = origin
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns:
|
53
|
+
# ========
|
54
|
+
# Current client timetoken
|
55
|
+
def timetoken
|
56
|
+
@env[:timetoken]
|
57
|
+
end
|
58
|
+
|
59
|
+
# Retruns:
|
60
|
+
# ========
|
61
|
+
# Current region or default '0'
|
62
|
+
def region_code
|
63
|
+
@env[:region_code] || 0
|
64
|
+
end
|
65
|
+
|
66
|
+
# Parameters:
|
67
|
+
# ===========
|
68
|
+
# <dl>
|
69
|
+
# <dt>region</dt>
|
70
|
+
# <dd>New region.</dd>
|
71
|
+
# </dl>
|
72
|
+
# Returns:
|
73
|
+
# ========
|
74
|
+
# New region.
|
75
|
+
def region_code=(region)
|
76
|
+
@env[:region_code] = region
|
77
|
+
end
|
78
|
+
|
79
|
+
# Parameters:
|
80
|
+
# ===========
|
81
|
+
# <dl>
|
82
|
+
# <dt>timetoken</dt>
|
83
|
+
# <dd>New timetoken.</dd>
|
84
|
+
# </dl>
|
85
|
+
# Returns:
|
86
|
+
# ========
|
87
|
+
# New timetoken.
|
88
|
+
def timetoken=(timetoken)
|
89
|
+
@env[:timetoken] = timetoken
|
90
|
+
end
|
91
|
+
|
92
|
+
# Returns:
|
93
|
+
# ========
|
94
|
+
# Current uuid.
|
95
|
+
def uuid
|
96
|
+
@env[:uuid]
|
97
|
+
end
|
98
|
+
|
99
|
+
# Returns:
|
100
|
+
# ========
|
101
|
+
# Array of all current events.
|
102
|
+
# :nocov:
|
103
|
+
def events
|
104
|
+
@env[:events]
|
105
|
+
end
|
106
|
+
# :nocov:
|
107
|
+
|
108
|
+
def current_heartbeat
|
109
|
+
@env[:heartbeat].to_i
|
110
|
+
end
|
111
|
+
|
112
|
+
def heartbeat=(value)
|
113
|
+
@env[:heartbeat] = value
|
114
|
+
end
|
115
|
+
|
116
|
+
def subscribe_filter=(filter_expr)
|
117
|
+
@env[:subscribe_filter] = filter_expr
|
118
|
+
@subscriber.reset if subscribed?
|
119
|
+
filter_expr
|
120
|
+
end
|
121
|
+
|
122
|
+
def subscribe_filter
|
123
|
+
@env[:subscribe_filter]
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
data/lib/pubnub/client.rb
CHANGED
@@ -27,6 +27,7 @@ require 'pubnub/error_envelope'
|
|
27
27
|
require 'pubnub/client/events'
|
28
28
|
require 'pubnub/client/paged_history'
|
29
29
|
require 'pubnub/client/helpers'
|
30
|
+
require 'pubnub/client/getters_setters'
|
30
31
|
|
31
32
|
require 'pubnub/validators/common_validator'
|
32
33
|
require 'pubnub/validators/client'
|
@@ -70,6 +71,7 @@ module Pubnub
|
|
70
71
|
include Events
|
71
72
|
include PagedHistory
|
72
73
|
include Helpers
|
74
|
+
include GettersSetters
|
73
75
|
|
74
76
|
attr_reader :env, :subscriber, :heart
|
75
77
|
|
@@ -267,109 +269,11 @@ module Pubnub
|
|
267
269
|
Pubnub.logger.debug('Pubnub::Client') { 'There\'s no requester' }
|
268
270
|
end
|
269
271
|
|
270
|
-
# Parameters:
|
271
|
-
# ===========
|
272
|
-
# <dl>
|
273
|
-
# <dt>uuid</dt>
|
274
|
-
# <dd>New uuid to be set.</dd>
|
275
|
-
# </dl>
|
276
|
-
#
|
277
|
-
# Returns:
|
278
|
-
# ========
|
279
|
-
# New uuid.
|
280
|
-
#
|
281
|
-
# Functionality:
|
282
|
-
# ==============
|
283
|
-
# Can't change uuid while subscribed. You have to leave every subscribed channel.
|
284
|
-
def change_uuid(uuid)
|
285
|
-
Pubnub.logger.debug('Pubnub::Client') { 'Changing uuid' }
|
286
|
-
if subscribed?
|
287
|
-
fail('Cannot change UUID while subscribed.')
|
288
|
-
else
|
289
|
-
@env[:uuid] = uuid
|
290
|
-
end
|
291
|
-
end
|
292
|
-
alias_method :session_uuid=, :change_uuid
|
293
|
-
alias_method :uuid=, :change_uuid
|
294
|
-
alias_method :set_uuid=, :change_uuid
|
295
|
-
|
296
|
-
# Returns:
|
297
|
-
# ========
|
298
|
-
# Current origin.
|
299
|
-
def current_origin
|
300
|
-
@env[:origins_pool].first
|
301
|
-
end
|
302
|
-
alias_method :origin, :current_origin
|
303
|
-
|
304
|
-
# Returns:
|
305
|
-
# ========
|
306
|
-
# Current client timetoken
|
307
|
-
def timetoken
|
308
|
-
@env[:timetoken]
|
309
|
-
end
|
310
|
-
|
311
|
-
# Retruns:
|
312
|
-
# ========
|
313
|
-
# Current region or default '0'
|
314
|
-
def region_code
|
315
|
-
@env[:region_code] || 0
|
316
|
-
end
|
317
|
-
|
318
|
-
# Parameters:
|
319
|
-
# ===========
|
320
|
-
# <dl>
|
321
|
-
# <dt>region</dt>
|
322
|
-
# <dd>New region.</dd>
|
323
|
-
# </dl>
|
324
|
-
# Returns:
|
325
|
-
# ========
|
326
|
-
# New region.
|
327
|
-
def region_code=(region)
|
328
|
-
@env[:region_code] = region
|
329
|
-
end
|
330
|
-
|
331
|
-
# Parameters:
|
332
|
-
# ===========
|
333
|
-
# <dl>
|
334
|
-
# <dt>timetoken</dt>
|
335
|
-
# <dd>New timetoken.</dd>
|
336
|
-
# </dl>
|
337
|
-
# Returns:
|
338
|
-
# ========
|
339
|
-
# New timetoken.
|
340
|
-
def timetoken=(timetoken)
|
341
|
-
@env[:timetoken] = timetoken
|
342
|
-
end
|
343
|
-
|
344
|
-
# Returns:
|
345
|
-
# ========
|
346
|
-
# Current uuid.
|
347
|
-
def uuid
|
348
|
-
@env[:uuid]
|
349
|
-
end
|
350
|
-
|
351
|
-
# Returns:
|
352
|
-
# ========
|
353
|
-
# Array of all current events.
|
354
|
-
# :nocov:
|
355
|
-
def events
|
356
|
-
@env[:events]
|
357
|
-
end
|
358
|
-
# :nocov:
|
359
|
-
|
360
272
|
def sequence_number_for_publish!
|
361
273
|
@env[:sequence_number_for_publish] += 1
|
362
274
|
@env[:sequence_number_for_publish] % 2**32
|
363
275
|
end
|
364
276
|
|
365
|
-
def current_heartbeat
|
366
|
-
@env[:heartbeat].to_i
|
367
|
-
end
|
368
|
-
|
369
|
-
def heartbeat=(value)
|
370
|
-
@env[:heartbeat] = value
|
371
|
-
end
|
372
|
-
|
373
277
|
def apply_state(event)
|
374
278
|
Pubnub.logger.debug('Pubnub::Client') { 'Apply state' }
|
375
279
|
create_state_pools(event)
|
@@ -394,20 +298,6 @@ module Pubnub
|
|
394
298
|
(::Time.now.to_f * 10_000_000).to_i
|
395
299
|
end
|
396
300
|
|
397
|
-
def subscribe_filter=(filter_expr)
|
398
|
-
@env[:subscribe_filter] = filter_expr
|
399
|
-
@subscriber.reset if subscribed?
|
400
|
-
filter_expr
|
401
|
-
end
|
402
|
-
|
403
|
-
def subscribe_filter
|
404
|
-
@env[:subscribe_filter]
|
405
|
-
end
|
406
|
-
|
407
|
-
def sdk_version
|
408
|
-
"PubNub-Ruby/#{Pubnub::VERSION}"
|
409
|
-
end
|
410
|
-
|
411
301
|
private
|
412
302
|
|
413
303
|
def create_state_pools(event)
|
@@ -456,6 +346,7 @@ module Pubnub
|
|
456
346
|
end
|
457
347
|
|
458
348
|
def assign_defaults
|
349
|
+
@env[:origin] = @env[:origins_pool].first if @env[:origins_pool]
|
459
350
|
default_values.each do |k, v|
|
460
351
|
@env[k] = v unless @env[k]
|
461
352
|
end
|
data/lib/pubnub/configuration.rb
CHANGED
@@ -5,7 +5,7 @@ module Pubnub
|
|
5
5
|
private
|
6
6
|
|
7
7
|
def default_values
|
8
|
-
{
|
8
|
+
{ origin: Pubnub::Constants::DEFAULT_ORIGIN,
|
9
9
|
open_timeout: Pubnub::Constants::DEFAULT_OPEN_TIMEOUT,
|
10
10
|
read_timeout: Pubnub::Constants::DEFAULT_READ_TIMEOUT,
|
11
11
|
idle_timeout: Pubnub::Constants::DEFAULT_IDLE_TIMEOUT,
|
data/lib/pubnub/constants.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
# Toplevel Pubnub module.
|
1
2
|
module Pubnub
|
3
|
+
# Constants module holds all constants and default values.
|
2
4
|
module Constants
|
3
5
|
# Config constants
|
4
6
|
DEFAULT_READ_TIMEOUT = 10
|
@@ -12,7 +14,7 @@ module Pubnub
|
|
12
14
|
DEFAULT_H_IDLE_TIMEOUT = 10
|
13
15
|
DEFAULT_RECONNECT_ATTEMPTS = 10
|
14
16
|
DEFAULT_RECONNECT_INTERVAL = 10
|
15
|
-
|
17
|
+
DEFAULT_ORIGIN = 'ps.pndsn.com'
|
16
18
|
DEFAULT_PORT = 80
|
17
19
|
PERIODIC_TIMER_INTERVAL = 0.25
|
18
20
|
DEFAULT_TTL = 1440
|
@@ -33,7 +35,8 @@ module Pubnub
|
|
33
35
|
# Successes
|
34
36
|
STATUS_ACK = :ack
|
35
37
|
|
36
|
-
STATUS_CATEGORY_ERRORS = [STATUS_ACCESS_DENIED, STATUS_TIMEOUT, STATUS_NON_JSON_RESPONSE, STATUS_API_KEY_ERROR,
|
38
|
+
STATUS_CATEGORY_ERRORS = [STATUS_ACCESS_DENIED, STATUS_TIMEOUT, STATUS_NON_JSON_RESPONSE, STATUS_API_KEY_ERROR,
|
39
|
+
SSL_ERROR]
|
37
40
|
STATUS_CATEGORY_SUCCESSES = [STATUS_ACK]
|
38
41
|
|
39
42
|
# Operations
|
data/lib/pubnub/crypto.rb
CHANGED
@@ -11,7 +11,7 @@ module Pubnub
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def encrypt(message)
|
14
|
-
aes = OpenSSL::Cipher
|
14
|
+
aes = OpenSSL::Cipher.new(@alg)
|
15
15
|
aes.encrypt
|
16
16
|
aes.key = @key
|
17
17
|
aes.iv = @iv
|
@@ -24,7 +24,7 @@ module Pubnub
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def decrypt(cipher_text)
|
27
|
-
decode_cipher = OpenSSL::Cipher
|
27
|
+
decode_cipher = OpenSSL::Cipher.new(@alg).decrypt
|
28
28
|
decode_cipher.key = @key
|
29
29
|
decode_cipher.iv = @iv
|
30
30
|
|
@@ -47,10 +47,10 @@ module Pubnub
|
|
47
47
|
'"DECRYPTION ERROR"'
|
48
48
|
end
|
49
49
|
|
50
|
-
def load_json(
|
51
|
-
JSON.load(
|
50
|
+
def load_json(plain_text)
|
51
|
+
JSON.load(plain_text)
|
52
52
|
rescue JSON::ParserError
|
53
|
-
JSON.load("[#{
|
53
|
+
JSON.load("[#{plain_text}]")[0]
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|