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
@@ -1,879 +1,735 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Pubnub::Presence do
|
4
4
|
around :each do |example|
|
5
|
-
Celluloid.boot
|
6
|
-
|
7
5
|
@fired = false
|
8
6
|
|
9
|
-
@callback = ->(_envelope) do
|
7
|
+
@callback = -> (_envelope) do
|
10
8
|
@fired = true
|
11
9
|
end
|
12
10
|
|
13
11
|
@pubnub = Pubnub.new(
|
14
|
-
publish_key:
|
15
|
-
subscribe_key:
|
16
|
-
uuid:
|
17
|
-
auth_key:
|
18
|
-
reconnect_interval: 0
|
12
|
+
publish_key: "pub-c-b42cec2f-f468-4784-8833-dd2b074538c4",
|
13
|
+
subscribe_key: "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f",
|
14
|
+
uuid: "ruby-test-uuid-client-one",
|
15
|
+
auth_key: "ruby-test-auth-client-one",
|
16
|
+
reconnect_interval: 0,
|
19
17
|
)
|
20
18
|
|
21
|
-
example.
|
22
|
-
Celluloid.shutdown
|
19
|
+
example.run_with_retry retry: 10
|
23
20
|
end
|
24
21
|
|
25
|
-
it
|
26
|
-
VCR.use_cassette(
|
27
|
-
@pubnub.presence(channel:
|
28
|
-
envelopes = @pubnub.presence(channel:
|
29
|
-
envelopes.each do |envelope|
|
30
|
-
|
31
|
-
expect(envelope.
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
expect(envelopes[0].status[:
|
37
|
-
expect(envelopes[0].status[:
|
38
|
-
expect(envelopes[0].status[:
|
39
|
-
expect(envelopes[0].status[:
|
40
|
-
expect(envelopes[0].status[:
|
41
|
-
expect(envelopes[0].status[:
|
42
|
-
expect(envelopes[0].status[:
|
43
|
-
|
44
|
-
expect(envelopes[0].
|
45
|
-
|
46
|
-
expect(envelopes[0].result[:
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
it '__channel___demo____http_sync__true___callback___block_' do
|
55
|
-
VCR.use_cassette('examples/presence/6', record: :none) do
|
56
|
-
@pubnub.presence(channel: 'demo', http_sync: true)
|
57
|
-
envelopes = @pubnub.presence(channel: 'demo', http_sync: true, &@callback)
|
58
|
-
envelopes.each do |envelope|
|
59
|
-
|
60
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
61
|
-
expect(envelope.error?).to eq false
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
expect(envelopes[0].status[:code]).to eq(200)
|
66
|
-
expect(envelopes[0].status[:data]).to eq({:shard=>"5", :channel=>"demo-pnpres", :subscription_match=>nil, :payload=>{"action"=>"leave", "timestamp"=>1465403696, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>0}, :flags=>0, :issuing_client_id=>nil, :subscribe_key=>"sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number=>nil, :user_meta_data=>nil, :replication_map=>nil, :eat_after_reading=>nil, :waypoint_list=>nil, :origination_time_token=>nil, :publish_timetoken=>{:timetoken=>"14654036965065315", :region_code=>2}})
|
67
|
-
expect(envelopes[0].status[:category]).to eq(:ack)
|
68
|
-
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
69
|
-
expect(envelopes[0].status[:current_timetoken]).to eq(14654036965469160)
|
70
|
-
expect(envelopes[0].status[:last_timetoken]).to eq(14654036961931472)
|
71
|
-
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
72
|
-
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
73
|
-
expect(envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
74
|
-
|
75
|
-
expect(envelopes[0].result[:code]).to eq(200)
|
76
|
-
expect(envelopes[0].result[:operation]).to eq(:presence)
|
77
|
-
expect(envelopes[0].result[:data]).to eq({:message=>{"action"=>"leave", "timestamp"=>1465403696, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>0}, :subscribed_channel=>"demo-pnpres", :actual_channel=>"demo-pnpres", :publish_time_object=>{:timetoken=>"14654036965065315", :region_code=>2}, :message_meta_data=>nil, :presence_event=>"leave", :presence=>{:uuid=>"ruby-test-uuid-client-two", :timestamp=>1465403696, :state=>nil, :occupancy=>0}})
|
78
|
-
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
|
83
|
-
it '__channel___demo____http_sync__true___callback___lambda_' do
|
84
|
-
VCR.use_cassette('examples/presence/7', record: :none) do
|
85
|
-
@pubnub.presence(channel: 'demo', http_sync: true, callback: @callback)
|
86
|
-
envelopes = @pubnub.presence(channel: 'demo', http_sync: true, callback: @callback)
|
87
|
-
envelopes.each do |envelope|
|
88
|
-
|
89
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
90
|
-
expect(envelope.error?).to eq false
|
91
|
-
end
|
92
|
-
|
93
|
-
|
94
|
-
expect(envelopes[0].status[:code]).to eq(200)
|
95
|
-
expect(envelopes[0].status[:data]).to eq({:shard=>"5", :channel=>"demo-pnpres", :subscription_match=>nil, :payload=>{"action"=>"join", "timestamp"=>1465403698, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>1}, :flags=>0, :issuing_client_id=>nil, :subscribe_key=>"sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number=>nil, :user_meta_data=>nil, :replication_map=>nil, :eat_after_reading=>nil, :waypoint_list=>nil, :origination_time_token=>nil, :publish_timetoken=>{:timetoken=>"14654036986516448", :region_code=>2}})
|
96
|
-
expect(envelopes[0].status[:category]).to eq(:ack)
|
97
|
-
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
98
|
-
expect(envelopes[0].status[:current_timetoken]).to eq(14654036986900265)
|
99
|
-
expect(envelopes[0].status[:last_timetoken]).to eq(14654036965469160)
|
100
|
-
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
101
|
-
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
102
|
-
expect(envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
103
|
-
|
104
|
-
expect(envelopes[0].result[:code]).to eq(200)
|
105
|
-
expect(envelopes[0].result[:operation]).to eq(:presence)
|
106
|
-
expect(envelopes[0].result[:data]).to eq({:message=>{"action"=>"join", "timestamp"=>1465403698, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>1}, :subscribed_channel=>"demo-pnpres", :actual_channel=>"demo-pnpres", :publish_time_object=>{:timetoken=>"14654036986516448", :region_code=>2}, :message_meta_data=>nil, :presence_event=>"join", :presence=>{:uuid=>"ruby-test-uuid-client-two", :timestamp=>1465403698, :state=>nil, :occupancy=>1}})
|
107
|
-
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
|
112
|
-
it '__channel___demo____http_sync__false___callback__nil_' do
|
113
|
-
VCR.use_cassette('examples/presence/__channel___demo____http_sync__false___callback__nil_', record: :none) do
|
114
|
-
@msg_envelopes = []
|
115
|
-
@presence_envelopes = []
|
116
|
-
@status_envelopes = []
|
117
|
-
callbacks = Pubnub::SubscribeCallback.new(
|
118
|
-
message: ->(envelope) { @msg_envelopes << envelope },
|
119
|
-
presence: ->(envelope) { @presence_envelopes << envelope },
|
120
|
-
status: ->(envelope) { @status_envelopes << envelope }
|
121
|
-
)
|
122
|
-
|
123
|
-
@pubnub.add_listener(callback: callbacks)
|
124
|
-
@pubnub.presence(channel: 'demo', http_sync: false)
|
125
|
-
end
|
126
|
-
|
127
|
-
eventually do
|
128
|
-
|
129
|
-
|
130
|
-
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
131
|
-
expect(@status_envelopes[0].status[:error]).to eq(true)
|
132
|
-
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
133
|
-
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
134
|
-
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
135
|
-
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
136
|
-
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
137
|
-
expect(@status_envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
138
|
-
|
139
|
-
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
143
|
-
|
144
|
-
|
145
|
-
it '__channel___demo____http_sync__false___callback___block_' do
|
146
|
-
VCR.use_cassette('examples/presence/__channel___demo____http_sync__false___callback___block_', record: :none) do
|
147
|
-
@msg_envelopes = []
|
148
|
-
@presence_envelopes = []
|
149
|
-
@status_envelopes = []
|
150
|
-
callbacks = Pubnub::SubscribeCallback.new(
|
151
|
-
message: ->(envelope) { @msg_envelopes << envelope },
|
152
|
-
presence: ->(envelope) { @presence_envelopes << envelope },
|
153
|
-
status: ->(envelope) { @status_envelopes << envelope }
|
154
|
-
)
|
155
|
-
|
156
|
-
@pubnub.add_listener(callback: callbacks)
|
157
|
-
@pubnub.presence(channel: 'demo', http_sync: false)
|
158
|
-
end
|
159
|
-
|
160
|
-
eventually do
|
161
|
-
|
162
|
-
|
163
|
-
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
164
|
-
expect(@status_envelopes[0].status[:error]).to eq(true)
|
165
|
-
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
166
|
-
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
167
|
-
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
168
|
-
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
169
|
-
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
170
|
-
expect(@status_envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
expect(@status_envelopes[1].status[:category]).to eq(:timeout)
|
175
|
-
expect(@status_envelopes[1].status[:error]).to eq(true)
|
176
|
-
expect(@status_envelopes[1].status[:auto_retried]).to eq(true)
|
177
|
-
expect(@status_envelopes[1].status[:current_timetoken]).to eq(0)
|
178
|
-
expect(@status_envelopes[1].status[:last_timetoken]).to eq(0)
|
179
|
-
expect(@status_envelopes[1].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
180
|
-
expect(@status_envelopes[1].status[:subscribed_channel_groups]).to eq([])
|
181
|
-
expect(@status_envelopes[1].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
182
|
-
|
183
|
-
|
184
|
-
end
|
185
|
-
|
186
|
-
end
|
187
|
-
|
188
|
-
|
189
|
-
it '__channel___demo____http_sync__false___callback___lambda_' do
|
190
|
-
VCR.use_cassette('examples/presence/__channel___demo____http_sync__false___callback___lambda_', record: :none) do
|
191
|
-
@msg_envelopes = []
|
192
|
-
@presence_envelopes = []
|
193
|
-
@status_envelopes = []
|
194
|
-
callbacks = Pubnub::SubscribeCallback.new(
|
195
|
-
message: ->(envelope) { @msg_envelopes << envelope },
|
196
|
-
presence: ->(envelope) { @presence_envelopes << envelope },
|
197
|
-
status: ->(envelope) { @status_envelopes << envelope }
|
198
|
-
)
|
199
|
-
|
200
|
-
@pubnub.add_listener(callback: callbacks)
|
201
|
-
@pubnub.presence(channel: 'demo', http_sync: false, callback: @callback)
|
202
|
-
end
|
203
|
-
|
204
|
-
eventually do
|
205
|
-
|
206
|
-
|
207
|
-
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
208
|
-
expect(@status_envelopes[0].status[:error]).to eq(true)
|
209
|
-
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
210
|
-
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
211
|
-
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
212
|
-
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
213
|
-
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
214
|
-
expect(@status_envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
expect(@status_envelopes[1].status[:category]).to eq(:timeout)
|
219
|
-
expect(@status_envelopes[1].status[:error]).to eq(true)
|
220
|
-
expect(@status_envelopes[1].status[:auto_retried]).to eq(true)
|
221
|
-
expect(@status_envelopes[1].status[:current_timetoken]).to eq(0)
|
222
|
-
expect(@status_envelopes[1].status[:last_timetoken]).to eq(0)
|
223
|
-
expect(@status_envelopes[1].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
224
|
-
expect(@status_envelopes[1].status[:subscribed_channel_groups]).to eq([])
|
225
|
-
expect(@status_envelopes[1].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
226
|
-
|
227
|
-
|
228
|
-
end
|
229
|
-
|
230
|
-
end
|
231
|
-
|
232
|
-
|
233
|
-
it '__channel___demo______http_sync__true___callback__nil_' do
|
234
|
-
VCR.use_cassette('examples/presence/5', record: :none) do
|
235
|
-
@pubnub.presence(channel: 'demo.*', http_sync: true)
|
236
|
-
envelopes = @pubnub.presence(channel: 'demo.*', http_sync: true)
|
237
|
-
envelopes.each do |envelope|
|
238
|
-
|
239
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
240
|
-
expect(envelope.error?).to eq false
|
241
|
-
end
|
242
|
-
|
243
|
-
|
244
|
-
expect(envelopes[0].status[:code]).to eq(200)
|
245
|
-
expect(envelopes[0].status[:data]).to eq({:shard=>"5", :channel=>"demo.*-pnpres", :subscription_match=>nil, :payload=>{"action"=>"join", "timestamp"=>1465403699, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>1}, :flags=>0, :issuing_client_id=>nil, :subscribe_key=>"sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number=>nil, :user_meta_data=>nil, :replication_map=>nil, :eat_after_reading=>nil, :waypoint_list=>nil, :origination_time_token=>nil, :publish_timetoken=>{:timetoken=>"14654036996668692", :region_code=>1}})
|
246
|
-
expect(envelopes[0].status[:category]).to eq(:ack)
|
247
|
-
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
248
|
-
expect(envelopes[0].status[:current_timetoken]).to eq(14654036997432530)
|
249
|
-
expect(envelopes[0].status[:last_timetoken]).to eq(14654036987376596)
|
250
|
-
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
251
|
-
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
252
|
-
expect(envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
253
|
-
|
254
|
-
expect(envelopes[0].result[:code]).to eq(200)
|
255
|
-
expect(envelopes[0].result[:operation]).to eq(:presence)
|
256
|
-
expect(envelopes[0].result[:data]).to eq({:message=>{"action"=>"join", "timestamp"=>1465403699, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>1}, :subscribed_channel=>"demo.*-pnpres", :actual_channel=>"demo.*-pnpres", :publish_time_object=>{:timetoken=>"14654036996668692", :region_code=>1}, :message_meta_data=>nil, :presence_event=>"join", :presence=>{:uuid=>"ruby-test-uuid-client-two", :timestamp=>1465403699, :state=>nil, :occupancy=>1}})
|
257
|
-
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
|
262
|
-
it '__channel___demo______http_sync__true___callback___block_' do
|
263
|
-
VCR.use_cassette('examples/presence/3', record: :none) do
|
264
|
-
@pubnub.presence(channel: 'demo.*', http_sync: true)
|
265
|
-
envelopes = @pubnub.presence(channel: 'demo.*', http_sync: true, &@callback)
|
266
|
-
envelopes.each do |envelope|
|
267
|
-
|
268
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
269
|
-
expect(envelope.error?).to eq false
|
270
|
-
end
|
271
|
-
|
272
|
-
|
273
|
-
expect(envelopes[0].status[:code]).to eq(200)
|
274
|
-
expect(envelopes[0].status[:data]).to eq({:shard=>"5", :channel=>"demo.*-pnpres", :subscription_match=>nil, :payload=>{"action"=>"leave", "timestamp"=>1465403700, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>0}, :flags=>0, :issuing_client_id=>nil, :subscribe_key=>"sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number=>nil, :user_meta_data=>nil, :replication_map=>nil, :eat_after_reading=>nil, :waypoint_list=>nil, :origination_time_token=>nil, :publish_timetoken=>{:timetoken=>"14654037002398263", :region_code=>1}})
|
275
|
-
expect(envelopes[0].status[:category]).to eq(:ack)
|
276
|
-
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
277
|
-
expect(envelopes[0].status[:current_timetoken]).to eq(14654037003110327)
|
278
|
-
expect(envelopes[0].status[:last_timetoken]).to eq(14654036997432530)
|
279
|
-
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
280
|
-
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
281
|
-
expect(envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
282
|
-
|
283
|
-
expect(envelopes[0].result[:code]).to eq(200)
|
284
|
-
expect(envelopes[0].result[:operation]).to eq(:presence)
|
285
|
-
expect(envelopes[0].result[:data]).to eq({:message=>{"action"=>"leave", "timestamp"=>1465403700, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>0}, :subscribed_channel=>"demo.*-pnpres", :actual_channel=>"demo.*-pnpres", :publish_time_object=>{:timetoken=>"14654037002398263", :region_code=>1}, :message_meta_data=>nil, :presence_event=>"leave", :presence=>{:uuid=>"ruby-test-uuid-client-two", :timestamp=>1465403700, :state=>nil, :occupancy=>0}})
|
286
|
-
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
|
291
|
-
it '__channel___demo______http_sync__true___callback___lambda_' do
|
292
|
-
VCR.use_cassette('examples/presence/4', record: :none) do
|
293
|
-
@pubnub.presence(channel: 'demo.*', http_sync: true, callback: @callback)
|
294
|
-
envelopes = @pubnub.presence(channel: 'demo.*', http_sync: true, callback: @callback)
|
295
|
-
envelopes.each do |envelope|
|
296
|
-
|
297
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
298
|
-
expect(envelope.error?).to eq false
|
299
|
-
end
|
300
|
-
|
301
|
-
|
302
|
-
expect(envelopes[0].status[:code]).to eq(200)
|
303
|
-
expect(envelopes[0].status[:data]).to eq({:shard=>"5", :channel=>"demo.*-pnpres", :subscription_match=>nil, :payload=>{"action"=>"join", "timestamp"=>1465403702, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>1}, :flags=>0, :issuing_client_id=>nil, :subscribe_key=>"sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number=>nil, :user_meta_data=>nil, :replication_map=>nil, :eat_after_reading=>nil, :waypoint_list=>nil, :origination_time_token=>nil, :publish_timetoken=>{:timetoken=>"14654037023404890", :region_code=>1}})
|
304
|
-
expect(envelopes[0].status[:category]).to eq(:ack)
|
305
|
-
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
306
|
-
expect(envelopes[0].status[:current_timetoken]).to eq(14654037024165554)
|
307
|
-
expect(envelopes[0].status[:last_timetoken]).to eq(14654037003110327)
|
308
|
-
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
309
|
-
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
310
|
-
expect(envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
311
|
-
|
312
|
-
expect(envelopes[0].result[:code]).to eq(200)
|
313
|
-
expect(envelopes[0].result[:operation]).to eq(:presence)
|
314
|
-
expect(envelopes[0].result[:data]).to eq({:message=>{"action"=>"join", "timestamp"=>1465403702, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>1}, :subscribed_channel=>"demo.*-pnpres", :actual_channel=>"demo.*-pnpres", :publish_time_object=>{:timetoken=>"14654037023404890", :region_code=>1}, :message_meta_data=>nil, :presence_event=>"join", :presence=>{:uuid=>"ruby-test-uuid-client-two", :timestamp=>1465403702, :state=>nil, :occupancy=>1}})
|
315
|
-
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
|
320
|
-
it '__channel___demo______http_sync__false___callback__nil_' do
|
321
|
-
VCR.use_cassette('examples/presence/__channel___demo______http_sync__false___callback__nil_', record: :none) do
|
322
|
-
@msg_envelopes = []
|
323
|
-
@presence_envelopes = []
|
324
|
-
@status_envelopes = []
|
325
|
-
callbacks = Pubnub::SubscribeCallback.new(
|
326
|
-
message: ->(envelope) { @msg_envelopes << envelope },
|
327
|
-
presence: ->(envelope) { @presence_envelopes << envelope },
|
328
|
-
status: ->(envelope) { @status_envelopes << envelope }
|
329
|
-
)
|
330
|
-
|
331
|
-
@pubnub.add_listener(callback: callbacks)
|
332
|
-
@pubnub.presence(channel: 'demo.*', http_sync: false)
|
333
|
-
end
|
334
|
-
|
335
|
-
eventually do
|
336
|
-
|
337
|
-
|
338
|
-
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
339
|
-
expect(@status_envelopes[0].status[:error]).to eq(true)
|
340
|
-
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
341
|
-
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
342
|
-
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
343
|
-
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo.*-pnpres"])
|
344
|
-
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
345
|
-
expect(@status_envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
346
|
-
|
347
|
-
|
348
|
-
end
|
349
|
-
|
350
|
-
end
|
351
|
-
|
352
|
-
|
353
|
-
it '__channel___demo______http_sync__false___callback___block_' do
|
354
|
-
VCR.use_cassette('examples/presence/__channel___demo______http_sync__false___callback___block_', record: :none) do
|
355
|
-
@msg_envelopes = []
|
356
|
-
@presence_envelopes = []
|
357
|
-
@status_envelopes = []
|
358
|
-
callbacks = Pubnub::SubscribeCallback.new(
|
359
|
-
message: ->(envelope) { @msg_envelopes << envelope },
|
360
|
-
presence: ->(envelope) { @presence_envelopes << envelope },
|
361
|
-
status: ->(envelope) { @status_envelopes << envelope }
|
362
|
-
)
|
363
|
-
|
364
|
-
@pubnub.add_listener(callback: callbacks)
|
365
|
-
@pubnub.presence(channel: 'demo.*', http_sync: false)
|
366
|
-
end
|
367
|
-
|
368
|
-
eventually do
|
369
|
-
|
370
|
-
|
371
|
-
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
372
|
-
expect(@status_envelopes[0].status[:error]).to eq(true)
|
373
|
-
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
374
|
-
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
375
|
-
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
376
|
-
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo.*-pnpres"])
|
377
|
-
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
378
|
-
expect(@status_envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
expect(@status_envelopes[1].status[:category]).to eq(:timeout)
|
383
|
-
expect(@status_envelopes[1].status[:error]).to eq(true)
|
384
|
-
expect(@status_envelopes[1].status[:auto_retried]).to eq(true)
|
385
|
-
expect(@status_envelopes[1].status[:current_timetoken]).to eq(0)
|
386
|
-
expect(@status_envelopes[1].status[:last_timetoken]).to eq(0)
|
387
|
-
expect(@status_envelopes[1].status[:subscribed_channels]).to eq(["demo.*-pnpres"])
|
388
|
-
expect(@status_envelopes[1].status[:subscribed_channel_groups]).to eq([])
|
389
|
-
expect(@status_envelopes[1].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
390
|
-
|
391
|
-
|
392
|
-
end
|
393
|
-
|
394
|
-
end
|
395
|
-
|
396
|
-
|
397
|
-
it '__channel___demo______http_sync__false___callback___lambda_' do
|
398
|
-
VCR.use_cassette('examples/presence/__channel___demo______http_sync__false___callback___lambda_', record: :none) do
|
399
|
-
@msg_envelopes = []
|
400
|
-
@presence_envelopes = []
|
401
|
-
@status_envelopes = []
|
402
|
-
callbacks = Pubnub::SubscribeCallback.new(
|
403
|
-
message: ->(envelope) { @msg_envelopes << envelope },
|
404
|
-
presence: ->(envelope) { @presence_envelopes << envelope },
|
405
|
-
status: ->(envelope) { @status_envelopes << envelope }
|
406
|
-
)
|
407
|
-
|
408
|
-
@pubnub.add_listener(callback: callbacks)
|
409
|
-
@pubnub.presence(channel: 'demo.*', http_sync: false, callback: @callback)
|
410
|
-
end
|
411
|
-
|
412
|
-
eventually do
|
413
|
-
|
414
|
-
|
415
|
-
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
416
|
-
expect(@status_envelopes[0].status[:error]).to eq(true)
|
417
|
-
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
418
|
-
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
419
|
-
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
420
|
-
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo.*-pnpres"])
|
421
|
-
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
422
|
-
expect(@status_envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
expect(@status_envelopes[1].status[:category]).to eq(:timeout)
|
427
|
-
expect(@status_envelopes[1].status[:error]).to eq(true)
|
428
|
-
expect(@status_envelopes[1].status[:auto_retried]).to eq(true)
|
429
|
-
expect(@status_envelopes[1].status[:current_timetoken]).to eq(0)
|
430
|
-
expect(@status_envelopes[1].status[:last_timetoken]).to eq(0)
|
431
|
-
expect(@status_envelopes[1].status[:subscribed_channels]).to eq(["demo.*-pnpres"])
|
432
|
-
expect(@status_envelopes[1].status[:subscribed_channel_groups]).to eq([])
|
433
|
-
expect(@status_envelopes[1].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
434
|
-
|
435
|
-
|
436
|
-
end
|
437
|
-
|
438
|
-
end
|
439
|
-
|
440
|
-
|
441
|
-
it '__channel___demo___http_sync__true___callback__nil_' do
|
442
|
-
VCR.use_cassette('examples/presence/11', record: :none) do
|
443
|
-
@pubnub.presence(channel: :demo, http_sync: true)
|
444
|
-
envelopes = @pubnub.presence(channel: :demo, http_sync: true)
|
445
|
-
envelopes.each do |envelope|
|
446
|
-
|
447
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
448
|
-
expect(envelope.error?).to eq false
|
449
|
-
end
|
450
|
-
|
451
|
-
|
452
|
-
expect(envelopes[0].status[:code]).to eq(200)
|
453
|
-
expect(envelopes[0].status[:data]).to eq({:shard=>"5", :channel=>"demo-pnpres", :subscription_match=>nil, :payload=>{"action"=>"leave", "timestamp"=>1465403703, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>0}, :flags=>0, :issuing_client_id=>nil, :subscribe_key=>"sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number=>nil, :user_meta_data=>nil, :replication_map=>nil, :eat_after_reading=>nil, :waypoint_list=>nil, :origination_time_token=>nil, :publish_timetoken=>{:timetoken=>"14654037039766378", :region_code=>2}})
|
454
|
-
expect(envelopes[0].status[:category]).to eq(:ack)
|
455
|
-
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
456
|
-
expect(envelopes[0].status[:current_timetoken]).to eq(14654037040157428)
|
457
|
-
expect(envelopes[0].status[:last_timetoken]).to eq(14654036986900265)
|
458
|
-
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
459
|
-
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
460
|
-
expect(envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
461
|
-
|
462
|
-
expect(envelopes[0].result[:code]).to eq(200)
|
463
|
-
expect(envelopes[0].result[:operation]).to eq(:presence)
|
464
|
-
expect(envelopes[0].result[:data]).to eq({:message=>{"action"=>"leave", "timestamp"=>1465403703, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>0}, :subscribed_channel=>"demo-pnpres", :actual_channel=>"demo-pnpres", :publish_time_object=>{:timetoken=>"14654037039766378", :region_code=>2}, :message_meta_data=>nil, :presence_event=>"leave", :presence=>{:uuid=>"ruby-test-uuid-client-two", :timestamp=>1465403703, :state=>nil, :occupancy=>0}})
|
465
|
-
|
466
|
-
end
|
467
|
-
end
|
468
|
-
|
469
|
-
|
470
|
-
it '__channel___demo___http_sync__true___callback___block_' do
|
471
|
-
VCR.use_cassette('examples/presence/9', record: :none) do
|
472
|
-
@pubnub.presence(channel: :demo, http_sync: true)
|
473
|
-
envelopes = @pubnub.presence(channel: :demo, http_sync: true, &@callback)
|
474
|
-
envelopes.each do |envelope|
|
475
|
-
|
476
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
477
|
-
expect(envelope.error?).to eq false
|
478
|
-
end
|
479
|
-
|
480
|
-
|
481
|
-
expect(envelopes[0].status[:code]).to eq(200)
|
482
|
-
expect(envelopes[0].status[:data]).to eq({:shard=>"5", :channel=>"demo-pnpres", :subscription_match=>nil, :payload=>{"action"=>"join", "timestamp"=>1465405069, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>1}, :flags=>0, :issuing_client_id=>nil, :subscribe_key=>"sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number=>nil, :user_meta_data=>nil, :replication_map=>nil, :eat_after_reading=>nil, :waypoint_list=>nil, :origination_time_token=>nil, :publish_timetoken=>{:timetoken=>"14654050693824272", :region_code=>1}})
|
483
|
-
expect(envelopes[0].status[:category]).to eq(:ack)
|
484
|
-
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
485
|
-
expect(envelopes[0].status[:current_timetoken]).to eq(14654050694555754)
|
486
|
-
expect(envelopes[0].status[:last_timetoken]).to eq(14654042961245025)
|
487
|
-
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
488
|
-
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
489
|
-
expect(envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
490
|
-
|
491
|
-
expect(envelopes[0].result[:code]).to eq(200)
|
492
|
-
expect(envelopes[0].result[:operation]).to eq(:presence)
|
493
|
-
expect(envelopes[0].result[:data]).to eq({:message=>{"action"=>"join", "timestamp"=>1465405069, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>1}, :subscribed_channel=>"demo-pnpres", :actual_channel=>"demo-pnpres", :publish_time_object=>{:timetoken=>"14654050693824272", :region_code=>1}, :message_meta_data=>nil, :presence_event=>"join", :presence=>{:uuid=>"ruby-test-uuid-client-two", :timestamp=>1465405069, :state=>nil, :occupancy=>1}})
|
494
|
-
|
495
|
-
end
|
496
|
-
end
|
497
|
-
|
498
|
-
|
499
|
-
it '__channel___demo___http_sync__true___callback___lambda_' do
|
500
|
-
VCR.use_cassette('examples/presence/10', record: :none) do
|
501
|
-
@pubnub.presence(channel: :demo, http_sync: true, callback: @callback)
|
502
|
-
envelopes = @pubnub.presence(channel: :demo, http_sync: true, callback: @callback)
|
503
|
-
envelopes.each do |envelope|
|
504
|
-
|
505
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
506
|
-
expect(envelope.error?).to eq false
|
507
|
-
end
|
508
|
-
|
509
|
-
|
510
|
-
expect(envelopes[0].status[:code]).to eq(200)
|
511
|
-
expect(envelopes[0].status[:data]).to eq({:shard=>"5", :channel=>"demo-pnpres", :subscription_match=>nil, :payload=>{"action"=>"join", "timestamp"=>1465403890, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>1}, :flags=>0, :issuing_client_id=>nil, :subscribe_key=>"sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number=>nil, :user_meta_data=>nil, :replication_map=>nil, :eat_after_reading=>nil, :waypoint_list=>nil, :origination_time_token=>nil, :publish_timetoken=>{:timetoken=>"14654038904558577", :region_code=>2}})
|
512
|
-
expect(envelopes[0].status[:category]).to eq(:ack)
|
513
|
-
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
514
|
-
expect(envelopes[0].status[:current_timetoken]).to eq(14654038904954461)
|
515
|
-
expect(envelopes[0].status[:last_timetoken]).to eq(14654037040157428)
|
516
|
-
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
517
|
-
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
518
|
-
expect(envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
519
|
-
|
520
|
-
expect(envelopes[0].result[:code]).to eq(200)
|
521
|
-
expect(envelopes[0].result[:operation]).to eq(:presence)
|
522
|
-
expect(envelopes[0].result[:data]).to eq({:message=>{"action"=>"join", "timestamp"=>1465403890, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>1}, :subscribed_channel=>"demo-pnpres", :actual_channel=>"demo-pnpres", :publish_time_object=>{:timetoken=>"14654038904558577", :region_code=>2}, :message_meta_data=>nil, :presence_event=>"join", :presence=>{:uuid=>"ruby-test-uuid-client-two", :timestamp=>1465403890, :state=>nil, :occupancy=>1}})
|
523
|
-
|
524
|
-
end
|
525
|
-
end
|
526
|
-
|
527
|
-
|
528
|
-
it '__channel___demo___http_sync__false___callback__nil_' do
|
529
|
-
VCR.use_cassette('examples/presence/__channel___demo___http_sync__false___callback__nil_', record: :none) do
|
530
|
-
@msg_envelopes = []
|
531
|
-
@presence_envelopes = []
|
532
|
-
@status_envelopes = []
|
533
|
-
callbacks = Pubnub::SubscribeCallback.new(
|
534
|
-
message: ->(envelope) { @msg_envelopes << envelope },
|
535
|
-
presence: ->(envelope) { @presence_envelopes << envelope },
|
536
|
-
status: ->(envelope) { @status_envelopes << envelope }
|
537
|
-
)
|
538
|
-
|
539
|
-
@pubnub.add_listener(callback: callbacks)
|
540
|
-
@pubnub.presence(channel: :demo, http_sync: false)
|
541
|
-
end
|
542
|
-
|
543
|
-
eventually do
|
544
|
-
|
545
|
-
|
546
|
-
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
547
|
-
expect(@status_envelopes[0].status[:error]).to eq(true)
|
548
|
-
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
549
|
-
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
550
|
-
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
551
|
-
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
552
|
-
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
553
|
-
expect(@status_envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
554
|
-
|
555
|
-
|
556
|
-
end
|
557
|
-
|
558
|
-
end
|
559
|
-
|
560
|
-
|
561
|
-
it '__channel___demo___http_sync__false___callback___block_' do
|
562
|
-
VCR.use_cassette('examples/presence/__channel___demo___http_sync__false___callback___block_', record: :none) do
|
563
|
-
@msg_envelopes = []
|
564
|
-
@presence_envelopes = []
|
565
|
-
@status_envelopes = []
|
566
|
-
callbacks = Pubnub::SubscribeCallback.new(
|
567
|
-
message: ->(envelope) { @msg_envelopes << envelope },
|
568
|
-
presence: ->(envelope) { @presence_envelopes << envelope },
|
569
|
-
status: ->(envelope) { @status_envelopes << envelope }
|
570
|
-
)
|
571
|
-
|
572
|
-
@pubnub.add_listener(callback: callbacks)
|
573
|
-
@pubnub.presence(channel: :demo, http_sync: false)
|
574
|
-
end
|
575
|
-
|
576
|
-
eventually do
|
577
|
-
|
578
|
-
|
579
|
-
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
580
|
-
expect(@status_envelopes[0].status[:error]).to eq(true)
|
581
|
-
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
582
|
-
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
583
|
-
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
584
|
-
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
585
|
-
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
586
|
-
expect(@status_envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
expect(@status_envelopes[1].status[:category]).to eq(:timeout)
|
591
|
-
expect(@status_envelopes[1].status[:error]).to eq(true)
|
592
|
-
expect(@status_envelopes[1].status[:auto_retried]).to eq(true)
|
593
|
-
expect(@status_envelopes[1].status[:current_timetoken]).to eq(0)
|
594
|
-
expect(@status_envelopes[1].status[:last_timetoken]).to eq(0)
|
595
|
-
expect(@status_envelopes[1].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
596
|
-
expect(@status_envelopes[1].status[:subscribed_channel_groups]).to eq([])
|
597
|
-
expect(@status_envelopes[1].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
598
|
-
|
599
|
-
|
600
|
-
end
|
601
|
-
|
602
|
-
end
|
603
|
-
|
604
|
-
|
605
|
-
it '__channel___demo___http_sync__false___callback___lambda_' do
|
606
|
-
VCR.use_cassette('examples/presence/__channel___demo___http_sync__false___callback___lambda_', record: :none) do
|
607
|
-
@msg_envelopes = []
|
608
|
-
@presence_envelopes = []
|
609
|
-
@status_envelopes = []
|
610
|
-
callbacks = Pubnub::SubscribeCallback.new(
|
611
|
-
message: ->(envelope) { @msg_envelopes << envelope },
|
612
|
-
presence: ->(envelope) { @presence_envelopes << envelope },
|
613
|
-
status: ->(envelope) { @status_envelopes << envelope }
|
614
|
-
)
|
615
|
-
|
616
|
-
@pubnub.add_listener(callback: callbacks)
|
617
|
-
@pubnub.presence(channel: :demo, http_sync: false, callback: @callback)
|
618
|
-
end
|
619
|
-
|
620
|
-
eventually do
|
621
|
-
|
622
|
-
|
623
|
-
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
624
|
-
expect(@status_envelopes[0].status[:error]).to eq(true)
|
625
|
-
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
626
|
-
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
627
|
-
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
628
|
-
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
629
|
-
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
630
|
-
expect(@status_envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
expect(@status_envelopes[1].status[:category]).to eq(:timeout)
|
635
|
-
expect(@status_envelopes[1].status[:error]).to eq(true)
|
636
|
-
expect(@status_envelopes[1].status[:auto_retried]).to eq(true)
|
637
|
-
expect(@status_envelopes[1].status[:current_timetoken]).to eq(0)
|
638
|
-
expect(@status_envelopes[1].status[:last_timetoken]).to eq(0)
|
639
|
-
expect(@status_envelopes[1].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
640
|
-
expect(@status_envelopes[1].status[:subscribed_channel_groups]).to eq([])
|
641
|
-
expect(@status_envelopes[1].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
642
|
-
|
643
|
-
|
644
|
-
end
|
645
|
-
|
646
|
-
end
|
647
|
-
|
648
|
-
|
649
|
-
it '__channel____demo___demo____demo_______http_sync__true___callback__nil_' do
|
650
|
-
VCR.use_cassette('examples/presence/2', record: :none) do
|
651
|
-
@pubnub.presence(channel: [:demo, "demo", "demo.*"], http_sync: true)
|
652
|
-
envelopes = @pubnub.presence(channel: [:demo, "demo", "demo.*"], http_sync: true)
|
653
|
-
envelopes.each do |envelope|
|
654
|
-
|
655
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
656
|
-
expect(envelope.error?).to eq false
|
657
|
-
end
|
658
|
-
|
659
|
-
|
660
|
-
expect(envelopes[0].status[:code]).to eq(200)
|
661
|
-
expect(envelopes[0].status[:data]).to eq({:shard=>"5", :channel=>"demo-pnpres", :subscription_match=>"demo-pnpres", :payload=>{"action"=>"leave", "timestamp"=>1465403891, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>0}, :flags=>0, :issuing_client_id=>nil, :subscribe_key=>"sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number=>nil, :user_meta_data=>nil, :replication_map=>nil, :eat_after_reading=>nil, :waypoint_list=>nil, :origination_time_token=>nil, :publish_timetoken=>{:timetoken=>"14654038913084722", :region_code=>1}})
|
662
|
-
expect(envelopes[0].status[:category]).to eq(:ack)
|
663
|
-
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
664
|
-
expect(envelopes[0].status[:current_timetoken]).to eq(14654038913920232)
|
665
|
-
expect(envelopes[0].status[:last_timetoken]).to eq(14654038905501214)
|
666
|
-
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
667
|
-
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
668
|
-
expect(envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
669
|
-
|
670
|
-
expect(envelopes[0].result[:code]).to eq(200)
|
671
|
-
expect(envelopes[0].result[:operation]).to eq(:presence)
|
672
|
-
expect(envelopes[0].result[:data]).to eq({:message=>{"action"=>"leave", "timestamp"=>1465403891, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>0}, :subscribed_channel=>"demo-pnpres", :actual_channel=>"demo-pnpres", :publish_time_object=>{:timetoken=>"14654038913084722", :region_code=>1}, :message_meta_data=>nil, :presence_event=>"leave", :presence=>{:uuid=>"ruby-test-uuid-client-two", :timestamp=>1465403891, :state=>nil, :occupancy=>0}})
|
673
|
-
|
674
|
-
end
|
675
|
-
end
|
676
|
-
|
677
|
-
|
678
|
-
it '__channel____demo___demo____demo_______http_sync__true___callback___block_' do
|
679
|
-
VCR.use_cassette('examples/presence/0', record: :none) do
|
680
|
-
@pubnub.presence(channel: [:demo, "demo", "demo.*"], http_sync: true)
|
681
|
-
envelopes = @pubnub.presence(channel: [:demo, "demo", "demo.*"], http_sync: true, &@callback)
|
682
|
-
envelopes.each do |envelope|
|
683
|
-
|
684
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
685
|
-
expect(envelope.error?).to eq false
|
686
|
-
end
|
687
|
-
|
688
|
-
|
689
|
-
expect(envelopes[0].status[:code]).to eq(200)
|
690
|
-
expect(envelopes[0].status[:data]).to eq({:shard=>"5", :channel=>"demo.*-pnpres", :subscription_match=>"demo.*-pnpres", :payload=>{"action"=>"leave", "timestamp"=>1465403892, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>0}, :flags=>0, :issuing_client_id=>nil, :subscribe_key=>"sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number=>nil, :user_meta_data=>nil, :replication_map=>nil, :eat_after_reading=>nil, :waypoint_list=>nil, :origination_time_token=>nil, :publish_timetoken=>{:timetoken=>"14654038929920942", :region_code=>1}})
|
691
|
-
expect(envelopes[0].status[:category]).to eq(:ack)
|
692
|
-
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
693
|
-
expect(envelopes[0].status[:current_timetoken]).to eq(14654038931856126)
|
694
|
-
expect(envelopes[0].status[:last_timetoken]).to eq(14654038913920233)
|
695
|
-
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
696
|
-
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
697
|
-
expect(envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
698
|
-
|
699
|
-
expect(envelopes[0].result[:code]).to eq(200)
|
700
|
-
expect(envelopes[0].result[:operation]).to eq(:presence)
|
701
|
-
expect(envelopes[0].result[:data]).to eq({:message=>{"action"=>"leave", "timestamp"=>1465403892, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>0}, :subscribed_channel=>"demo.*-pnpres", :actual_channel=>"demo.*-pnpres", :publish_time_object=>{:timetoken=>"14654038929920942", :region_code=>1}, :message_meta_data=>nil, :presence_event=>"leave", :presence=>{:uuid=>"ruby-test-uuid-client-two", :timestamp=>1465403892, :state=>nil, :occupancy=>0}})
|
702
|
-
|
703
|
-
end
|
704
|
-
end
|
705
|
-
|
706
|
-
|
707
|
-
it '__channel____demo___demo____demo_______http_sync__true___callback___lambda_' do
|
708
|
-
VCR.use_cassette('examples/presence/1', record: :none) do
|
709
|
-
@pubnub.presence(channel: [:demo, "demo", "demo.*"], http_sync: true, callback: @callback)
|
710
|
-
envelopes = @pubnub.presence(channel: [:demo, "demo", "demo.*"], http_sync: true, callback: @callback)
|
711
|
-
envelopes.each do |envelope|
|
712
|
-
|
713
|
-
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
714
|
-
expect(envelope.error?).to eq false
|
715
|
-
end
|
716
|
-
|
717
|
-
|
718
|
-
expect(envelopes[0].status[:code]).to eq(200)
|
719
|
-
expect(envelopes[0].status[:data]).to eq({:shard=>"5", :channel=>"demo-pnpres", :subscription_match=>"demo-pnpres", :payload=>{"action"=>"join", "timestamp"=>1465403893, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>1}, :flags=>0, :issuing_client_id=>nil, :subscribe_key=>"sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number=>nil, :user_meta_data=>nil, :replication_map=>nil, :eat_after_reading=>nil, :waypoint_list=>nil, :origination_time_token=>nil, :publish_timetoken=>{:timetoken=>"14654038934962157", :region_code=>2}})
|
720
|
-
expect(envelopes[0].status[:category]).to eq(:ack)
|
721
|
-
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
722
|
-
expect(envelopes[0].status[:current_timetoken]).to eq(14654038935342617)
|
723
|
-
expect(envelopes[0].status[:last_timetoken]).to eq(14654038931856126)
|
724
|
-
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
725
|
-
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
726
|
-
expect(envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
727
|
-
|
728
|
-
expect(envelopes[0].result[:code]).to eq(200)
|
729
|
-
expect(envelopes[0].result[:operation]).to eq(:presence)
|
730
|
-
expect(envelopes[0].result[:data]).to eq({:message=>{"action"=>"join", "timestamp"=>1465403893, "uuid"=>"ruby-test-uuid-client-two", "occupancy"=>1}, :subscribed_channel=>"demo-pnpres", :actual_channel=>"demo-pnpres", :publish_time_object=>{:timetoken=>"14654038934962157", :region_code=>2}, :message_meta_data=>nil, :presence_event=>"join", :presence=>{:uuid=>"ruby-test-uuid-client-two", :timestamp=>1465403893, :state=>nil, :occupancy=>1}})
|
731
|
-
|
732
|
-
end
|
733
|
-
end
|
734
|
-
|
735
|
-
|
736
|
-
it '__channel____demo___demo____demo_______http_sync__false___callback__nil_' do
|
737
|
-
VCR.use_cassette('examples/presence/__channel____demo___demo____demo_______http_sync__false___callback__nil_', record: :none) do
|
738
|
-
@msg_envelopes = []
|
739
|
-
@presence_envelopes = []
|
740
|
-
@status_envelopes = []
|
741
|
-
callbacks = Pubnub::SubscribeCallback.new(
|
742
|
-
message: ->(envelope) { @msg_envelopes << envelope },
|
743
|
-
presence: ->(envelope) { @presence_envelopes << envelope },
|
744
|
-
status: ->(envelope) { @status_envelopes << envelope }
|
745
|
-
)
|
746
|
-
|
747
|
-
@pubnub.add_listener(callback: callbacks)
|
748
|
-
@pubnub.presence(channel: [:demo, "demo", "demo.*"], http_sync: false)
|
749
|
-
end
|
750
|
-
|
751
|
-
eventually do
|
752
|
-
|
753
|
-
|
754
|
-
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
755
|
-
expect(@status_envelopes[0].status[:error]).to eq(true)
|
756
|
-
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
757
|
-
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
758
|
-
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
759
|
-
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo-pnpres", "demo.*-pnpres"])
|
760
|
-
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
761
|
-
expect(@status_envelopes[0].status[:config]).to eq({:tls=>false, :uuid=>"ruby-test-uuid-client-one", :auth_key=>"ruby-test-auth-client-one", :origin=>"ps.pndsn.com"})
|
22
|
+
it "__channel___demo____http_sync__true___callback__nil_" do
|
23
|
+
VCR.use_cassette("examples/presence/8", record: :none) do
|
24
|
+
@pubnub.presence(channel: "demo", http_sync: true)
|
25
|
+
envelopes = @pubnub.presence(channel: "demo", http_sync: true)
|
26
|
+
envelopes.each do |envelope|
|
27
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
28
|
+
expect(envelope.error?).to eq false
|
29
|
+
end
|
30
|
+
|
31
|
+
expect(envelopes[0].status[:code]).to eq(200)
|
32
|
+
expect(envelopes[0].status[:data]).to eq({:shard => "5", :channel => "demo-pnpres", :subscription_match => nil, :payload => {"action" => "join", "timestamp" => 1465403696, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 1}, :flags => 0, :issuing_client_id => nil, :subscribe_key => "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number => nil, :user_meta_data => nil, :replication_map => nil, :eat_after_reading => nil, :waypoint_list => nil, :origination_time_token => nil, :publish_timetoken => {:timetoken => "14654036961172863", :region_code => 1}})
|
33
|
+
expect(envelopes[0].status[:category]).to eq(:ack)
|
34
|
+
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
35
|
+
expect(envelopes[0].status[:current_timetoken]).to eq(14654036961931472)
|
36
|
+
expect(envelopes[0].status[:last_timetoken]).to eq(14654036098003799)
|
37
|
+
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
38
|
+
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
39
|
+
expect(envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
40
|
+
|
41
|
+
expect(envelopes[0].result[:code]).to eq(200)
|
42
|
+
expect(envelopes[0].result[:operation]).to eq(:presence)
|
43
|
+
expect(envelopes[0].result[:data]).to eq({:message => {"action" => "join", "timestamp" => 1465403696, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 1}, :subscribed_channel => "demo-pnpres", :actual_channel => "demo-pnpres", :publish_time_object => {:timetoken => "14654036961172863", :region_code => 1}, :message_meta_data => nil, :presence_event => "join", :presence => {:uuid => "ruby-test-uuid-client-two", :timestamp => 1465403696, :state => nil, :occupancy => 1}})
|
44
|
+
end
|
45
|
+
end
|
762
46
|
|
47
|
+
it "__channel___demo____http_sync__true___callback___block_" do
|
48
|
+
VCR.use_cassette("examples/presence/6", record: :none) do
|
49
|
+
@pubnub.presence(channel: "demo", http_sync: true)
|
50
|
+
envelopes = @pubnub.presence(channel: "demo", http_sync: true, &@callback)
|
51
|
+
envelopes.each do |envelope|
|
52
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
53
|
+
expect(envelope.error?).to eq false
|
54
|
+
end
|
55
|
+
|
56
|
+
expect(envelopes[0].status[:code]).to eq(200)
|
57
|
+
expect(envelopes[0].status[:data]).to eq({:shard => "5", :channel => "demo-pnpres", :subscription_match => nil, :payload => {"action" => "leave", "timestamp" => 1465403696, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 0}, :flags => 0, :issuing_client_id => nil, :subscribe_key => "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number => nil, :user_meta_data => nil, :replication_map => nil, :eat_after_reading => nil, :waypoint_list => nil, :origination_time_token => nil, :publish_timetoken => {:timetoken => "14654036965065315", :region_code => 2}})
|
58
|
+
expect(envelopes[0].status[:category]).to eq(:ack)
|
59
|
+
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
60
|
+
expect(envelopes[0].status[:current_timetoken]).to eq(14654036965469160)
|
61
|
+
expect(envelopes[0].status[:last_timetoken]).to eq(14654036961931472)
|
62
|
+
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
63
|
+
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
64
|
+
expect(envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
65
|
+
|
66
|
+
expect(envelopes[0].result[:code]).to eq(200)
|
67
|
+
expect(envelopes[0].result[:operation]).to eq(:presence)
|
68
|
+
expect(envelopes[0].result[:data]).to eq({:message => {"action" => "leave", "timestamp" => 1465403696, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 0}, :subscribed_channel => "demo-pnpres", :actual_channel => "demo-pnpres", :publish_time_object => {:timetoken => "14654036965065315", :region_code => 2}, :message_meta_data => nil, :presence_event => "leave", :presence => {:uuid => "ruby-test-uuid-client-two", :timestamp => 1465403696, :state => nil, :occupancy => 0}})
|
69
|
+
end
|
70
|
+
end
|
763
71
|
|
764
|
-
|
72
|
+
it "__channel___demo____http_sync__true___callback___lambda_" do
|
73
|
+
VCR.use_cassette("examples/presence/7", record: :none) do
|
74
|
+
@pubnub.presence(channel: "demo", http_sync: true, callback: @callback)
|
75
|
+
envelopes = @pubnub.presence(channel: "demo", http_sync: true, callback: @callback)
|
76
|
+
envelopes.each do |envelope|
|
77
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
78
|
+
expect(envelope.error?).to eq false
|
79
|
+
end
|
80
|
+
|
81
|
+
expect(envelopes[0].status[:code]).to eq(200)
|
82
|
+
expect(envelopes[0].status[:data]).to eq({:shard => "5", :channel => "demo-pnpres", :subscription_match => nil, :payload => {"action" => "join", "timestamp" => 1465403698, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 1}, :flags => 0, :issuing_client_id => nil, :subscribe_key => "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number => nil, :user_meta_data => nil, :replication_map => nil, :eat_after_reading => nil, :waypoint_list => nil, :origination_time_token => nil, :publish_timetoken => {:timetoken => "14654036986516448", :region_code => 2}})
|
83
|
+
expect(envelopes[0].status[:category]).to eq(:ack)
|
84
|
+
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
85
|
+
expect(envelopes[0].status[:current_timetoken]).to eq(14654036986900265)
|
86
|
+
expect(envelopes[0].status[:last_timetoken]).to eq(14654036965469160)
|
87
|
+
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
88
|
+
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
89
|
+
expect(envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
90
|
+
|
91
|
+
expect(envelopes[0].result[:code]).to eq(200)
|
92
|
+
expect(envelopes[0].result[:operation]).to eq(:presence)
|
93
|
+
expect(envelopes[0].result[:data]).to eq({:message => {"action" => "join", "timestamp" => 1465403698, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 1}, :subscribed_channel => "demo-pnpres", :actual_channel => "demo-pnpres", :publish_time_object => {:timetoken => "14654036986516448", :region_code => 2}, :message_meta_data => nil, :presence_event => "join", :presence => {:uuid => "ruby-test-uuid-client-two", :timestamp => 1465403698, :state => nil, :occupancy => 1}})
|
94
|
+
end
|
95
|
+
end
|
765
96
|
|
766
|
-
|
97
|
+
it "__channel___demo____http_sync__false___callback__nil_" do
|
98
|
+
VCR.use_cassette("examples/presence/__channel___demo____http_sync__false___callback__nil_", record: :none) do
|
99
|
+
@msg_envelopes = []
|
100
|
+
@presence_envelopes = []
|
101
|
+
@status_envelopes = []
|
102
|
+
callbacks = Pubnub::SubscribeCallback.new(
|
103
|
+
message: -> (envelope) { @msg_envelopes << envelope },
|
104
|
+
presence: -> (envelope) { @presence_envelopes << envelope },
|
105
|
+
status: -> (envelope) { @status_envelopes << envelope },
|
106
|
+
)
|
107
|
+
|
108
|
+
@pubnub.add_listener(callback: callbacks)
|
109
|
+
@pubnub.presence(channel: "demo", http_sync: false)
|
110
|
+
end
|
767
111
|
|
112
|
+
eventually do
|
113
|
+
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
114
|
+
expect(@status_envelopes[0].status[:error]).to eq(true)
|
115
|
+
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
116
|
+
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
117
|
+
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
118
|
+
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
119
|
+
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
120
|
+
expect(@status_envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
121
|
+
end
|
122
|
+
end
|
768
123
|
|
769
|
-
it
|
770
|
-
VCR.use_cassette(
|
771
|
-
@msg_envelopes = []
|
772
|
-
@presence_envelopes = []
|
773
|
-
@status_envelopes = []
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
124
|
+
it "__channel___demo____http_sync__false___callback___block_" do
|
125
|
+
VCR.use_cassette("examples/presence/__channel___demo____http_sync__false___callback___block_", record: :none) do
|
126
|
+
@msg_envelopes = []
|
127
|
+
@presence_envelopes = []
|
128
|
+
@status_envelopes = []
|
129
|
+
callbacks = Pubnub::SubscribeCallback.new(
|
130
|
+
message: -> (envelope) { @msg_envelopes << envelope },
|
131
|
+
presence: -> (envelope) { @presence_envelopes << envelope },
|
132
|
+
status: -> (envelope) { @status_envelopes << envelope },
|
133
|
+
)
|
134
|
+
|
135
|
+
@pubnub.add_listener(callback: callbacks)
|
136
|
+
@pubnub.presence(channel: "demo", http_sync: false)
|
137
|
+
end
|
779
138
|
|
780
|
-
|
781
|
-
@
|
782
|
-
|
139
|
+
eventually do
|
140
|
+
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
141
|
+
expect(@status_envelopes[0].status[:error]).to eq(true)
|
142
|
+
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
143
|
+
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
144
|
+
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
145
|
+
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
146
|
+
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
147
|
+
expect(@status_envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
148
|
+
|
149
|
+
expect(@status_envelopes[1].status[:category]).to eq(:timeout)
|
150
|
+
expect(@status_envelopes[1].status[:error]).to eq(true)
|
151
|
+
expect(@status_envelopes[1].status[:auto_retried]).to eq(true)
|
152
|
+
expect(@status_envelopes[1].status[:current_timetoken]).to eq(0)
|
153
|
+
expect(@status_envelopes[1].status[:last_timetoken]).to eq(0)
|
154
|
+
expect(@status_envelopes[1].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
155
|
+
expect(@status_envelopes[1].status[:subscribed_channel_groups]).to eq([])
|
156
|
+
expect(@status_envelopes[1].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
157
|
+
end
|
158
|
+
end
|
783
159
|
|
784
|
-
|
160
|
+
it "__channel___demo____http_sync__false___callback___lambda_" do
|
161
|
+
VCR.use_cassette("examples/presence/__channel___demo____http_sync__false___callback___lambda_", record: :none) do
|
162
|
+
@msg_envelopes = []
|
163
|
+
@presence_envelopes = []
|
164
|
+
@status_envelopes = []
|
165
|
+
callbacks = Pubnub::SubscribeCallback.new(
|
166
|
+
message: -> (envelope) { @msg_envelopes << envelope },
|
167
|
+
presence: -> (envelope) { @presence_envelopes << envelope },
|
168
|
+
status: -> (envelope) { @status_envelopes << envelope },
|
169
|
+
)
|
170
|
+
|
171
|
+
@pubnub.add_listener(callback: callbacks)
|
172
|
+
@pubnub.presence(channel: "demo", http_sync: false, callback: @callback)
|
173
|
+
end
|
785
174
|
|
175
|
+
eventually do
|
176
|
+
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
177
|
+
expect(@status_envelopes[0].status[:error]).to eq(true)
|
178
|
+
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
179
|
+
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
180
|
+
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
181
|
+
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
182
|
+
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
183
|
+
expect(@status_envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
184
|
+
|
185
|
+
expect(@status_envelopes[1].status[:category]).to eq(:timeout)
|
186
|
+
expect(@status_envelopes[1].status[:error]).to eq(true)
|
187
|
+
expect(@status_envelopes[1].status[:auto_retried]).to eq(true)
|
188
|
+
expect(@status_envelopes[1].status[:current_timetoken]).to eq(0)
|
189
|
+
expect(@status_envelopes[1].status[:last_timetoken]).to eq(0)
|
190
|
+
expect(@status_envelopes[1].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
191
|
+
expect(@status_envelopes[1].status[:subscribed_channel_groups]).to eq([])
|
192
|
+
expect(@status_envelopes[1].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
193
|
+
end
|
194
|
+
end
|
786
195
|
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
expect(
|
793
|
-
expect(
|
794
|
-
|
196
|
+
it "__channel___demo______http_sync__true___callback__nil_" do
|
197
|
+
VCR.use_cassette("examples/presence/5", record: :none) do
|
198
|
+
@pubnub.presence(channel: "demo.*", http_sync: true)
|
199
|
+
envelopes = @pubnub.presence(channel: "demo.*", http_sync: true)
|
200
|
+
envelopes.each do |envelope|
|
201
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
202
|
+
expect(envelope.error?).to eq false
|
203
|
+
end
|
204
|
+
|
205
|
+
expect(envelopes[0].status[:code]).to eq(200)
|
206
|
+
expect(envelopes[0].status[:data]).to eq({:shard => "5", :channel => "demo.*-pnpres", :subscription_match => nil, :payload => {"action" => "join", "timestamp" => 1465403699, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 1}, :flags => 0, :issuing_client_id => nil, :subscribe_key => "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number => nil, :user_meta_data => nil, :replication_map => nil, :eat_after_reading => nil, :waypoint_list => nil, :origination_time_token => nil, :publish_timetoken => {:timetoken => "14654036996668692", :region_code => 1}})
|
207
|
+
expect(envelopes[0].status[:category]).to eq(:ack)
|
208
|
+
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
209
|
+
expect(envelopes[0].status[:current_timetoken]).to eq(14654036997432530)
|
210
|
+
expect(envelopes[0].status[:last_timetoken]).to eq(14654036987376596)
|
211
|
+
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
212
|
+
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
213
|
+
expect(envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
214
|
+
|
215
|
+
expect(envelopes[0].result[:code]).to eq(200)
|
216
|
+
expect(envelopes[0].result[:operation]).to eq(:presence)
|
217
|
+
expect(envelopes[0].result[:data]).to eq({:message => {"action" => "join", "timestamp" => 1465403699, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 1}, :subscribed_channel => "demo.*-pnpres", :actual_channel => "demo.*-pnpres", :publish_time_object => {:timetoken => "14654036996668692", :region_code => 1}, :message_meta_data => nil, :presence_event => "join", :presence => {:uuid => "ruby-test-uuid-client-two", :timestamp => 1465403699, :state => nil, :occupancy => 1}})
|
218
|
+
end
|
219
|
+
end
|
795
220
|
|
221
|
+
it "__channel___demo______http_sync__true___callback___block_" do
|
222
|
+
VCR.use_cassette("examples/presence/3", record: :none) do
|
223
|
+
@pubnub.presence(channel: "demo.*", http_sync: true)
|
224
|
+
envelopes = @pubnub.presence(channel: "demo.*", http_sync: true, &@callback)
|
225
|
+
envelopes.each do |envelope|
|
226
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
227
|
+
expect(envelope.error?).to eq false
|
228
|
+
end
|
229
|
+
|
230
|
+
expect(envelopes[0].status[:code]).to eq(200)
|
231
|
+
expect(envelopes[0].status[:data]).to eq({:shard => "5", :channel => "demo.*-pnpres", :subscription_match => nil, :payload => {"action" => "leave", "timestamp" => 1465403700, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 0}, :flags => 0, :issuing_client_id => nil, :subscribe_key => "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number => nil, :user_meta_data => nil, :replication_map => nil, :eat_after_reading => nil, :waypoint_list => nil, :origination_time_token => nil, :publish_timetoken => {:timetoken => "14654037002398263", :region_code => 1}})
|
232
|
+
expect(envelopes[0].status[:category]).to eq(:ack)
|
233
|
+
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
234
|
+
expect(envelopes[0].status[:current_timetoken]).to eq(14654037003110327)
|
235
|
+
expect(envelopes[0].status[:last_timetoken]).to eq(14654036997432530)
|
236
|
+
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
237
|
+
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
238
|
+
expect(envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
239
|
+
|
240
|
+
expect(envelopes[0].result[:code]).to eq(200)
|
241
|
+
expect(envelopes[0].result[:operation]).to eq(:presence)
|
242
|
+
expect(envelopes[0].result[:data]).to eq({:message => {"action" => "leave", "timestamp" => 1465403700, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 0}, :subscribed_channel => "demo.*-pnpres", :actual_channel => "demo.*-pnpres", :publish_time_object => {:timetoken => "14654037002398263", :region_code => 1}, :message_meta_data => nil, :presence_event => "leave", :presence => {:uuid => "ruby-test-uuid-client-two", :timestamp => 1465403700, :state => nil, :occupancy => 0}})
|
243
|
+
end
|
244
|
+
end
|
796
245
|
|
246
|
+
it "__channel___demo______http_sync__true___callback___lambda_" do
|
247
|
+
VCR.use_cassette("examples/presence/4", record: :none) do
|
248
|
+
@pubnub.presence(channel: "demo.*", http_sync: true, callback: @callback)
|
249
|
+
envelopes = @pubnub.presence(channel: "demo.*", http_sync: true, callback: @callback)
|
250
|
+
envelopes.each do |envelope|
|
251
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
252
|
+
expect(envelope.error?).to eq false
|
253
|
+
end
|
254
|
+
|
255
|
+
expect(envelopes[0].status[:code]).to eq(200)
|
256
|
+
expect(envelopes[0].status[:data]).to eq({:shard => "5", :channel => "demo.*-pnpres", :subscription_match => nil, :payload => {"action" => "join", "timestamp" => 1465403702, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 1}, :flags => 0, :issuing_client_id => nil, :subscribe_key => "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number => nil, :user_meta_data => nil, :replication_map => nil, :eat_after_reading => nil, :waypoint_list => nil, :origination_time_token => nil, :publish_timetoken => {:timetoken => "14654037023404890", :region_code => 1}})
|
257
|
+
expect(envelopes[0].status[:category]).to eq(:ack)
|
258
|
+
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
259
|
+
expect(envelopes[0].status[:current_timetoken]).to eq(14654037024165554)
|
260
|
+
expect(envelopes[0].status[:last_timetoken]).to eq(14654037003110327)
|
261
|
+
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
262
|
+
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
263
|
+
expect(envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
264
|
+
|
265
|
+
expect(envelopes[0].result[:code]).to eq(200)
|
266
|
+
expect(envelopes[0].result[:operation]).to eq(:presence)
|
267
|
+
expect(envelopes[0].result[:data]).to eq({:message => {"action" => "join", "timestamp" => 1465403702, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 1}, :subscribed_channel => "demo.*-pnpres", :actual_channel => "demo.*-pnpres", :publish_time_object => {:timetoken => "14654037023404890", :region_code => 1}, :message_meta_data => nil, :presence_event => "join", :presence => {:uuid => "ruby-test-uuid-client-two", :timestamp => 1465403702, :state => nil, :occupancy => 1}})
|
268
|
+
end
|
269
|
+
end
|
797
270
|
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
271
|
+
it "__channel___demo______http_sync__false___callback__nil_" do
|
272
|
+
VCR.use_cassette("examples/presence/__channel___demo______http_sync__false___callback__nil_", record: :none) do
|
273
|
+
@msg_envelopes = []
|
274
|
+
@presence_envelopes = []
|
275
|
+
@status_envelopes = []
|
276
|
+
callbacks = Pubnub::SubscribeCallback.new(
|
277
|
+
message: -> (envelope) { @msg_envelopes << envelope },
|
278
|
+
presence: -> (envelope) { @presence_envelopes << envelope },
|
279
|
+
status: -> (envelope) { @status_envelopes << envelope },
|
280
|
+
)
|
281
|
+
|
282
|
+
@pubnub.add_listener(callback: callbacks)
|
283
|
+
@pubnub.presence(channel: "demo.*", http_sync: false)
|
284
|
+
end
|
806
285
|
|
286
|
+
eventually do
|
287
|
+
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
288
|
+
expect(@status_envelopes[0].status[:error]).to eq(true)
|
289
|
+
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
290
|
+
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
291
|
+
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
292
|
+
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo.*-pnpres"])
|
293
|
+
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
294
|
+
expect(@status_envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
295
|
+
end
|
296
|
+
end
|
807
297
|
|
298
|
+
it "__channel___demo______http_sync__false___callback___block_" do
|
299
|
+
VCR.use_cassette("examples/presence/__channel___demo______http_sync__false___callback___block_", record: :none) do
|
300
|
+
@msg_envelopes = []
|
301
|
+
@presence_envelopes = []
|
302
|
+
@status_envelopes = []
|
303
|
+
callbacks = Pubnub::SubscribeCallback.new(
|
304
|
+
message: -> (envelope) { @msg_envelopes << envelope },
|
305
|
+
presence: -> (envelope) { @presence_envelopes << envelope },
|
306
|
+
status: -> (envelope) { @status_envelopes << envelope },
|
307
|
+
)
|
308
|
+
|
309
|
+
@pubnub.add_listener(callback: callbacks)
|
310
|
+
@pubnub.presence(channel: "demo.*", http_sync: false)
|
311
|
+
end
|
808
312
|
|
809
|
-
|
810
|
-
expect(@status_envelopes[
|
811
|
-
expect(@status_envelopes[
|
812
|
-
expect(@status_envelopes[
|
813
|
-
expect(@status_envelopes[
|
814
|
-
expect(@status_envelopes[
|
815
|
-
expect(@status_envelopes[
|
816
|
-
expect(@status_envelopes[
|
313
|
+
eventually do
|
314
|
+
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
315
|
+
expect(@status_envelopes[0].status[:error]).to eq(true)
|
316
|
+
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
317
|
+
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
318
|
+
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
319
|
+
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo.*-pnpres"])
|
320
|
+
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
321
|
+
expect(@status_envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
322
|
+
|
323
|
+
expect(@status_envelopes[1].status[:category]).to eq(:timeout)
|
324
|
+
expect(@status_envelopes[1].status[:error]).to eq(true)
|
325
|
+
expect(@status_envelopes[1].status[:auto_retried]).to eq(true)
|
326
|
+
expect(@status_envelopes[1].status[:current_timetoken]).to eq(0)
|
327
|
+
expect(@status_envelopes[1].status[:last_timetoken]).to eq(0)
|
328
|
+
expect(@status_envelopes[1].status[:subscribed_channels]).to eq(["demo.*-pnpres"])
|
329
|
+
expect(@status_envelopes[1].status[:subscribed_channel_groups]).to eq([])
|
330
|
+
expect(@status_envelopes[1].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
331
|
+
end
|
332
|
+
end
|
817
333
|
|
334
|
+
it "__channel___demo______http_sync__false___callback___lambda_" do
|
335
|
+
VCR.use_cassette("examples/presence/__channel___demo______http_sync__false___callback___lambda_", record: :none) do
|
336
|
+
@msg_envelopes = []
|
337
|
+
@presence_envelopes = []
|
338
|
+
@status_envelopes = []
|
339
|
+
callbacks = Pubnub::SubscribeCallback.new(
|
340
|
+
message: -> (envelope) { @msg_envelopes << envelope },
|
341
|
+
presence: -> (envelope) { @presence_envelopes << envelope },
|
342
|
+
status: -> (envelope) { @status_envelopes << envelope },
|
343
|
+
)
|
344
|
+
|
345
|
+
@pubnub.add_listener(callback: callbacks)
|
346
|
+
@pubnub.presence(channel: "demo.*", http_sync: false, callback: @callback)
|
347
|
+
end
|
818
348
|
|
819
|
-
|
349
|
+
eventually do
|
350
|
+
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
351
|
+
expect(@status_envelopes[0].status[:error]).to eq(true)
|
352
|
+
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
353
|
+
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
354
|
+
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
355
|
+
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo.*-pnpres"])
|
356
|
+
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
357
|
+
expect(@status_envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
358
|
+
|
359
|
+
expect(@status_envelopes[1].status[:category]).to eq(:timeout)
|
360
|
+
expect(@status_envelopes[1].status[:error]).to eq(true)
|
361
|
+
expect(@status_envelopes[1].status[:auto_retried]).to eq(true)
|
362
|
+
expect(@status_envelopes[1].status[:current_timetoken]).to eq(0)
|
363
|
+
expect(@status_envelopes[1].status[:last_timetoken]).to eq(0)
|
364
|
+
expect(@status_envelopes[1].status[:subscribed_channels]).to eq(["demo.*-pnpres"])
|
365
|
+
expect(@status_envelopes[1].status[:subscribed_channel_groups]).to eq([])
|
366
|
+
expect(@status_envelopes[1].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
367
|
+
end
|
368
|
+
end
|
820
369
|
|
821
|
-
|
370
|
+
it "__channel___demo___http_sync__true___callback__nil_" do
|
371
|
+
VCR.use_cassette("examples/presence/11", record: :none) do
|
372
|
+
@pubnub.presence(channel: :demo, http_sync: true)
|
373
|
+
envelopes = @pubnub.presence(channel: :demo, http_sync: true)
|
374
|
+
envelopes.each do |envelope|
|
375
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
376
|
+
expect(envelope.error?).to eq false
|
377
|
+
end
|
378
|
+
|
379
|
+
expect(envelopes[0].status[:code]).to eq(200)
|
380
|
+
expect(envelopes[0].status[:data]).to eq({:shard => "5", :channel => "demo-pnpres", :subscription_match => nil, :payload => {"action" => "leave", "timestamp" => 1465403703, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 0}, :flags => 0, :issuing_client_id => nil, :subscribe_key => "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number => nil, :user_meta_data => nil, :replication_map => nil, :eat_after_reading => nil, :waypoint_list => nil, :origination_time_token => nil, :publish_timetoken => {:timetoken => "14654037039766378", :region_code => 2}})
|
381
|
+
expect(envelopes[0].status[:category]).to eq(:ack)
|
382
|
+
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
383
|
+
expect(envelopes[0].status[:current_timetoken]).to eq(14654037040157428)
|
384
|
+
expect(envelopes[0].status[:last_timetoken]).to eq(14654036986900265)
|
385
|
+
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
386
|
+
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
387
|
+
expect(envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
388
|
+
|
389
|
+
expect(envelopes[0].result[:code]).to eq(200)
|
390
|
+
expect(envelopes[0].result[:operation]).to eq(:presence)
|
391
|
+
expect(envelopes[0].result[:data]).to eq({:message => {"action" => "leave", "timestamp" => 1465403703, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 0}, :subscribed_channel => "demo-pnpres", :actual_channel => "demo-pnpres", :publish_time_object => {:timetoken => "14654037039766378", :region_code => 2}, :message_meta_data => nil, :presence_event => "leave", :presence => {:uuid => "ruby-test-uuid-client-two", :timestamp => 1465403703, :state => nil, :occupancy => 0}})
|
392
|
+
end
|
393
|
+
end
|
822
394
|
|
395
|
+
it "__channel___demo___http_sync__true___callback___block_" do
|
396
|
+
VCR.use_cassette("examples/presence/9", record: :none) do
|
397
|
+
@pubnub.presence(channel: :demo, http_sync: true)
|
398
|
+
envelopes = @pubnub.presence(channel: :demo, http_sync: true, &@callback)
|
399
|
+
envelopes.each do |envelope|
|
400
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
401
|
+
expect(envelope.error?).to eq false
|
402
|
+
end
|
403
|
+
|
404
|
+
expect(envelopes[0].status[:code]).to eq(200)
|
405
|
+
expect(envelopes[0].status[:data]).to eq({:shard => "5", :channel => "demo-pnpres", :subscription_match => nil, :payload => {"action" => "join", "timestamp" => 1465405069, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 1}, :flags => 0, :issuing_client_id => nil, :subscribe_key => "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number => nil, :user_meta_data => nil, :replication_map => nil, :eat_after_reading => nil, :waypoint_list => nil, :origination_time_token => nil, :publish_timetoken => {:timetoken => "14654050693824272", :region_code => 1}})
|
406
|
+
expect(envelopes[0].status[:category]).to eq(:ack)
|
407
|
+
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
408
|
+
expect(envelopes[0].status[:current_timetoken]).to eq(14654050694555754)
|
409
|
+
expect(envelopes[0].status[:last_timetoken]).to eq(14654042961245025)
|
410
|
+
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
411
|
+
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
412
|
+
expect(envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
413
|
+
|
414
|
+
expect(envelopes[0].result[:code]).to eq(200)
|
415
|
+
expect(envelopes[0].result[:operation]).to eq(:presence)
|
416
|
+
expect(envelopes[0].result[:data]).to eq({:message => {"action" => "join", "timestamp" => 1465405069, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 1}, :subscribed_channel => "demo-pnpres", :actual_channel => "demo-pnpres", :publish_time_object => {:timetoken => "14654050693824272", :region_code => 1}, :message_meta_data => nil, :presence_event => "join", :presence => {:uuid => "ruby-test-uuid-client-two", :timestamp => 1465405069, :state => nil, :occupancy => 1}})
|
417
|
+
end
|
418
|
+
end
|
823
419
|
|
824
|
-
it
|
825
|
-
VCR.use_cassette(
|
826
|
-
@
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
420
|
+
it "__channel___demo___http_sync__true___callback___lambda_" do
|
421
|
+
VCR.use_cassette("examples/presence/10", record: :none) do
|
422
|
+
@pubnub.presence(channel: :demo, http_sync: true, callback: @callback)
|
423
|
+
envelopes = @pubnub.presence(channel: :demo, http_sync: true, callback: @callback)
|
424
|
+
envelopes.each do |envelope|
|
425
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
426
|
+
expect(envelope.error?).to eq false
|
427
|
+
end
|
428
|
+
|
429
|
+
expect(envelopes[0].status[:code]).to eq(200)
|
430
|
+
expect(envelopes[0].status[:data]).to eq({:shard => "5", :channel => "demo-pnpres", :subscription_match => nil, :payload => {"action" => "join", "timestamp" => 1465403890, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 1}, :flags => 0, :issuing_client_id => nil, :subscribe_key => "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number => nil, :user_meta_data => nil, :replication_map => nil, :eat_after_reading => nil, :waypoint_list => nil, :origination_time_token => nil, :publish_timetoken => {:timetoken => "14654038904558577", :region_code => 2}})
|
431
|
+
expect(envelopes[0].status[:category]).to eq(:ack)
|
432
|
+
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
433
|
+
expect(envelopes[0].status[:current_timetoken]).to eq(14654038904954461)
|
434
|
+
expect(envelopes[0].status[:last_timetoken]).to eq(14654037040157428)
|
435
|
+
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
436
|
+
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
437
|
+
expect(envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
438
|
+
|
439
|
+
expect(envelopes[0].result[:code]).to eq(200)
|
440
|
+
expect(envelopes[0].result[:operation]).to eq(:presence)
|
441
|
+
expect(envelopes[0].result[:data]).to eq({:message => {"action" => "join", "timestamp" => 1465403890, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 1}, :subscribed_channel => "demo-pnpres", :actual_channel => "demo-pnpres", :publish_time_object => {:timetoken => "14654038904558577", :region_code => 2}, :message_meta_data => nil, :presence_event => "join", :presence => {:uuid => "ruby-test-uuid-client-two", :timestamp => 1465403890, :state => nil, :occupancy => 1}})
|
442
|
+
end
|
443
|
+
end
|
834
444
|
|
835
|
-
|
836
|
-
|
837
|
-
|
445
|
+
it "__channel___demo___http_sync__false___callback__nil_" do
|
446
|
+
VCR.use_cassette("examples/presence/__channel___demo___http_sync__false___callback__nil_", record: :none) do
|
447
|
+
@msg_envelopes = []
|
448
|
+
@presence_envelopes = []
|
449
|
+
@status_envelopes = []
|
450
|
+
callbacks = Pubnub::SubscribeCallback.new(
|
451
|
+
message: -> (envelope) { @msg_envelopes << envelope },
|
452
|
+
presence: -> (envelope) { @presence_envelopes << envelope },
|
453
|
+
status: -> (envelope) { @status_envelopes << envelope },
|
454
|
+
)
|
455
|
+
|
456
|
+
@pubnub.add_listener(callback: callbacks)
|
457
|
+
@pubnub.presence(channel: :demo, http_sync: false)
|
458
|
+
end
|
838
459
|
|
839
|
-
eventually do
|
460
|
+
eventually do
|
461
|
+
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
462
|
+
expect(@status_envelopes[0].status[:error]).to eq(true)
|
463
|
+
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
464
|
+
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
465
|
+
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
466
|
+
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
467
|
+
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
468
|
+
expect(@status_envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
469
|
+
end
|
470
|
+
end
|
840
471
|
|
472
|
+
it "__channel___demo___http_sync__false___callback___block_" do
|
473
|
+
VCR.use_cassette("examples/presence/__channel___demo___http_sync__false___callback___block_", record: :none) do
|
474
|
+
@msg_envelopes = []
|
475
|
+
@presence_envelopes = []
|
476
|
+
@status_envelopes = []
|
477
|
+
callbacks = Pubnub::SubscribeCallback.new(
|
478
|
+
message: -> (envelope) { @msg_envelopes << envelope },
|
479
|
+
presence: -> (envelope) { @presence_envelopes << envelope },
|
480
|
+
status: -> (envelope) { @status_envelopes << envelope },
|
481
|
+
)
|
482
|
+
|
483
|
+
@pubnub.add_listener(callback: callbacks)
|
484
|
+
@pubnub.presence(channel: :demo, http_sync: false)
|
485
|
+
end
|
841
486
|
|
842
|
-
|
843
|
-
expect(@status_envelopes[0].status[:
|
844
|
-
expect(@status_envelopes[0].status[:
|
845
|
-
expect(@status_envelopes[0].status[:
|
846
|
-
expect(@status_envelopes[0].status[:
|
847
|
-
expect(@status_envelopes[0].status[:
|
848
|
-
expect(@status_envelopes[0].status[:
|
849
|
-
expect(@status_envelopes[0].status[:
|
487
|
+
eventually do
|
488
|
+
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
489
|
+
expect(@status_envelopes[0].status[:error]).to eq(true)
|
490
|
+
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
491
|
+
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
492
|
+
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
493
|
+
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
494
|
+
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
495
|
+
expect(@status_envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
496
|
+
|
497
|
+
expect(@status_envelopes[1].status[:category]).to eq(:timeout)
|
498
|
+
expect(@status_envelopes[1].status[:error]).to eq(true)
|
499
|
+
expect(@status_envelopes[1].status[:auto_retried]).to eq(true)
|
500
|
+
expect(@status_envelopes[1].status[:current_timetoken]).to eq(0)
|
501
|
+
expect(@status_envelopes[1].status[:last_timetoken]).to eq(0)
|
502
|
+
expect(@status_envelopes[1].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
503
|
+
expect(@status_envelopes[1].status[:subscribed_channel_groups]).to eq([])
|
504
|
+
expect(@status_envelopes[1].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
505
|
+
end
|
506
|
+
end
|
850
507
|
|
508
|
+
it "__channel___demo___http_sync__false___callback___lambda_" do
|
509
|
+
VCR.use_cassette("examples/presence/__channel___demo___http_sync__false___callback___lambda_", record: :none) do
|
510
|
+
@msg_envelopes = []
|
511
|
+
@presence_envelopes = []
|
512
|
+
@status_envelopes = []
|
513
|
+
callbacks = Pubnub::SubscribeCallback.new(
|
514
|
+
message: -> (envelope) { @msg_envelopes << envelope },
|
515
|
+
presence: -> (envelope) { @presence_envelopes << envelope },
|
516
|
+
status: -> (envelope) { @status_envelopes << envelope },
|
517
|
+
)
|
518
|
+
|
519
|
+
@pubnub.add_listener(callback: callbacks)
|
520
|
+
@pubnub.presence(channel: :demo, http_sync: false, callback: @callback)
|
521
|
+
end
|
851
522
|
|
523
|
+
eventually do
|
524
|
+
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
525
|
+
expect(@status_envelopes[0].status[:error]).to eq(true)
|
526
|
+
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
527
|
+
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
528
|
+
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
529
|
+
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
530
|
+
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
531
|
+
expect(@status_envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
532
|
+
|
533
|
+
expect(@status_envelopes[1].status[:category]).to eq(:timeout)
|
534
|
+
expect(@status_envelopes[1].status[:error]).to eq(true)
|
535
|
+
expect(@status_envelopes[1].status[:auto_retried]).to eq(true)
|
536
|
+
expect(@status_envelopes[1].status[:current_timetoken]).to eq(0)
|
537
|
+
expect(@status_envelopes[1].status[:last_timetoken]).to eq(0)
|
538
|
+
expect(@status_envelopes[1].status[:subscribed_channels]).to eq(["demo-pnpres"])
|
539
|
+
expect(@status_envelopes[1].status[:subscribed_channel_groups]).to eq([])
|
540
|
+
expect(@status_envelopes[1].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
541
|
+
end
|
542
|
+
end
|
852
543
|
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
expect(
|
859
|
-
expect(
|
860
|
-
|
544
|
+
it "__channel____demo___demo____demo_______http_sync__true___callback__nil_" do
|
545
|
+
VCR.use_cassette("examples/presence/2", record: :none) do
|
546
|
+
@pubnub.presence(channel: [:demo, "demo", "demo.*"], http_sync: true)
|
547
|
+
envelopes = @pubnub.presence(channel: [:demo, "demo", "demo.*"], http_sync: true)
|
548
|
+
envelopes.each do |envelope|
|
549
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
550
|
+
expect(envelope.error?).to eq false
|
551
|
+
end
|
552
|
+
|
553
|
+
expect(envelopes[0].status[:code]).to eq(200)
|
554
|
+
expect(envelopes[0].status[:data]).to eq({:shard => "5", :channel => "demo-pnpres", :subscription_match => "demo-pnpres", :payload => {"action" => "leave", "timestamp" => 1465403891, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 0}, :flags => 0, :issuing_client_id => nil, :subscribe_key => "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number => nil, :user_meta_data => nil, :replication_map => nil, :eat_after_reading => nil, :waypoint_list => nil, :origination_time_token => nil, :publish_timetoken => {:timetoken => "14654038913084722", :region_code => 1}})
|
555
|
+
expect(envelopes[0].status[:category]).to eq(:ack)
|
556
|
+
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
557
|
+
expect(envelopes[0].status[:current_timetoken]).to eq(14654038913920232)
|
558
|
+
expect(envelopes[0].status[:last_timetoken]).to eq(14654038905501214)
|
559
|
+
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
560
|
+
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
561
|
+
expect(envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
562
|
+
|
563
|
+
expect(envelopes[0].result[:code]).to eq(200)
|
564
|
+
expect(envelopes[0].result[:operation]).to eq(:presence)
|
565
|
+
expect(envelopes[0].result[:data]).to eq({:message => {"action" => "leave", "timestamp" => 1465403891, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 0}, :subscribed_channel => "demo-pnpres", :actual_channel => "demo-pnpres", :publish_time_object => {:timetoken => "14654038913084722", :region_code => 1}, :message_meta_data => nil, :presence_event => "leave", :presence => {:uuid => "ruby-test-uuid-client-two", :timestamp => 1465403891, :state => nil, :occupancy => 0}})
|
566
|
+
end
|
567
|
+
end
|
861
568
|
|
569
|
+
it "__channel____demo___demo____demo_______http_sync__true___callback___block_" do
|
570
|
+
VCR.use_cassette("examples/presence/0", record: :none) do
|
571
|
+
@pubnub.presence(channel: [:demo, "demo", "demo.*"], http_sync: true)
|
572
|
+
envelopes = @pubnub.presence(channel: [:demo, "demo", "demo.*"], http_sync: true, &@callback)
|
573
|
+
envelopes.each do |envelope|
|
574
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
575
|
+
expect(envelope.error?).to eq false
|
576
|
+
end
|
577
|
+
|
578
|
+
expect(envelopes[0].status[:code]).to eq(200)
|
579
|
+
expect(envelopes[0].status[:data]).to eq({:shard => "5", :channel => "demo.*-pnpres", :subscription_match => "demo.*-pnpres", :payload => {"action" => "leave", "timestamp" => 1465403892, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 0}, :flags => 0, :issuing_client_id => nil, :subscribe_key => "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number => nil, :user_meta_data => nil, :replication_map => nil, :eat_after_reading => nil, :waypoint_list => nil, :origination_time_token => nil, :publish_timetoken => {:timetoken => "14654038929920942", :region_code => 1}})
|
580
|
+
expect(envelopes[0].status[:category]).to eq(:ack)
|
581
|
+
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
582
|
+
expect(envelopes[0].status[:current_timetoken]).to eq(14654038931856126)
|
583
|
+
expect(envelopes[0].status[:last_timetoken]).to eq(14654038913920233)
|
584
|
+
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
585
|
+
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
586
|
+
expect(envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
587
|
+
|
588
|
+
expect(envelopes[0].result[:code]).to eq(200)
|
589
|
+
expect(envelopes[0].result[:operation]).to eq(:presence)
|
590
|
+
expect(envelopes[0].result[:data]).to eq({:message => {"action" => "leave", "timestamp" => 1465403892, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 0}, :subscribed_channel => "demo.*-pnpres", :actual_channel => "demo.*-pnpres", :publish_time_object => {:timetoken => "14654038929920942", :region_code => 1}, :message_meta_data => nil, :presence_event => "leave", :presence => {:uuid => "ruby-test-uuid-client-two", :timestamp => 1465403892, :state => nil, :occupancy => 0}})
|
591
|
+
end
|
592
|
+
end
|
862
593
|
|
594
|
+
it "__channel____demo___demo____demo_______http_sync__true___callback___lambda_" do
|
595
|
+
VCR.use_cassette("examples/presence/1", record: :none) do
|
596
|
+
@pubnub.presence(channel: [:demo, "demo", "demo.*"], http_sync: true, callback: @callback)
|
597
|
+
envelopes = @pubnub.presence(channel: [:demo, "demo", "demo.*"], http_sync: true, callback: @callback)
|
598
|
+
envelopes.each do |envelope|
|
599
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
600
|
+
expect(envelope.error?).to eq false
|
601
|
+
end
|
602
|
+
|
603
|
+
expect(envelopes[0].status[:code]).to eq(200)
|
604
|
+
expect(envelopes[0].status[:data]).to eq({:shard => "5", :channel => "demo-pnpres", :subscription_match => "demo-pnpres", :payload => {"action" => "join", "timestamp" => 1465403893, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 1}, :flags => 0, :issuing_client_id => nil, :subscribe_key => "sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f", :sequence_number => nil, :user_meta_data => nil, :replication_map => nil, :eat_after_reading => nil, :waypoint_list => nil, :origination_time_token => nil, :publish_timetoken => {:timetoken => "14654038934962157", :region_code => 2}})
|
605
|
+
expect(envelopes[0].status[:category]).to eq(:ack)
|
606
|
+
expect(envelopes[0].status[:auto_retried]).to eq(true)
|
607
|
+
expect(envelopes[0].status[:current_timetoken]).to eq(14654038935342617)
|
608
|
+
expect(envelopes[0].status[:last_timetoken]).to eq(14654038931856126)
|
609
|
+
expect(envelopes[0].status[:subscribed_channels]).to eq([])
|
610
|
+
expect(envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
611
|
+
expect(envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
612
|
+
|
613
|
+
expect(envelopes[0].result[:code]).to eq(200)
|
614
|
+
expect(envelopes[0].result[:operation]).to eq(:presence)
|
615
|
+
expect(envelopes[0].result[:data]).to eq({:message => {"action" => "join", "timestamp" => 1465403893, "uuid" => "ruby-test-uuid-client-two", "occupancy" => 1}, :subscribed_channel => "demo-pnpres", :actual_channel => "demo-pnpres", :publish_time_object => {:timetoken => "14654038934962157", :region_code => 2}, :message_meta_data => nil, :presence_event => "join", :presence => {:uuid => "ruby-test-uuid-client-two", :timestamp => 1465403893, :state => nil, :occupancy => 1}})
|
616
|
+
end
|
617
|
+
end
|
863
618
|
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
619
|
+
it "__channel____demo___demo____demo_______http_sync__false___callback__nil_" do
|
620
|
+
VCR.use_cassette("examples/presence/__channel____demo___demo____demo_______http_sync__false___callback__nil_", record: :none) do
|
621
|
+
@msg_envelopes = []
|
622
|
+
@presence_envelopes = []
|
623
|
+
@status_envelopes = []
|
624
|
+
callbacks = Pubnub::SubscribeCallback.new(
|
625
|
+
message: -> (envelope) { @msg_envelopes << envelope },
|
626
|
+
presence: -> (envelope) { @presence_envelopes << envelope },
|
627
|
+
status: -> (envelope) { @status_envelopes << envelope },
|
628
|
+
)
|
629
|
+
|
630
|
+
@pubnub.add_listener(callback: callbacks)
|
631
|
+
@pubnub.presence(channel: [:demo, "demo", "demo.*"], http_sync: false)
|
632
|
+
end
|
872
633
|
|
634
|
+
eventually do
|
635
|
+
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
636
|
+
expect(@status_envelopes[0].status[:error]).to eq(true)
|
637
|
+
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
638
|
+
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
639
|
+
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
640
|
+
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo-pnpres", "demo.*-pnpres"])
|
641
|
+
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
642
|
+
expect(@status_envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
643
|
+
end
|
644
|
+
end
|
873
645
|
|
874
|
-
|
646
|
+
it "__channel____demo___demo____demo_______http_sync__false___callback___block_" do
|
647
|
+
VCR.use_cassette("examples/presence/__channel____demo___demo____demo_______http_sync__false___callback___block_", record: :none) do
|
648
|
+
@msg_envelopes = []
|
649
|
+
@presence_envelopes = []
|
650
|
+
@status_envelopes = []
|
651
|
+
callbacks = Pubnub::SubscribeCallback.new(
|
652
|
+
message: -> (envelope) { @msg_envelopes << envelope },
|
653
|
+
presence: -> (envelope) { @presence_envelopes << envelope },
|
654
|
+
status: -> (envelope) { @status_envelopes << envelope },
|
655
|
+
)
|
656
|
+
|
657
|
+
@pubnub.add_listener(callback: callbacks)
|
658
|
+
@pubnub.presence(channel: [:demo, "demo", "demo.*"], http_sync: false)
|
659
|
+
end
|
875
660
|
|
876
|
-
|
661
|
+
eventually do
|
662
|
+
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
663
|
+
expect(@status_envelopes[0].status[:error]).to eq(true)
|
664
|
+
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
665
|
+
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
666
|
+
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
667
|
+
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo-pnpres", "demo.*-pnpres"])
|
668
|
+
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
669
|
+
expect(@status_envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
670
|
+
|
671
|
+
expect(@status_envelopes[1].status[:category]).to eq(:timeout)
|
672
|
+
expect(@status_envelopes[1].status[:error]).to eq(true)
|
673
|
+
expect(@status_envelopes[1].status[:auto_retried]).to eq(true)
|
674
|
+
expect(@status_envelopes[1].status[:current_timetoken]).to eq(0)
|
675
|
+
expect(@status_envelopes[1].status[:last_timetoken]).to eq(0)
|
676
|
+
expect(@status_envelopes[1].status[:subscribed_channels]).to eq(["demo-pnpres", "demo.*-pnpres"])
|
677
|
+
expect(@status_envelopes[1].status[:subscribed_channel_groups]).to eq([])
|
678
|
+
expect(@status_envelopes[1].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
679
|
+
|
680
|
+
expect(@status_envelopes[2].status[:category]).to eq(:timeout)
|
681
|
+
expect(@status_envelopes[2].status[:error]).to eq(true)
|
682
|
+
expect(@status_envelopes[2].status[:auto_retried]).to eq(true)
|
683
|
+
expect(@status_envelopes[2].status[:current_timetoken]).to eq(0)
|
684
|
+
expect(@status_envelopes[2].status[:last_timetoken]).to eq(0)
|
685
|
+
expect(@status_envelopes[2].status[:subscribed_channels]).to eq(["demo-pnpres", "demo.*-pnpres"])
|
686
|
+
expect(@status_envelopes[2].status[:subscribed_channel_groups]).to eq([])
|
687
|
+
expect(@status_envelopes[2].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
688
|
+
end
|
689
|
+
end
|
877
690
|
|
691
|
+
it "__channel____demo___demo____demo_______http_sync__false___callback___lambda_" do
|
692
|
+
VCR.use_cassette("examples/presence/__channel____demo___demo____demo_______http_sync__false___callback___lambda_", record: :none) do
|
693
|
+
@msg_envelopes = []
|
694
|
+
@presence_envelopes = []
|
695
|
+
@status_envelopes = []
|
696
|
+
callbacks = Pubnub::SubscribeCallback.new(
|
697
|
+
message: -> (envelope) { @msg_envelopes << envelope },
|
698
|
+
presence: -> (envelope) { @presence_envelopes << envelope },
|
699
|
+
status: -> (envelope) { @status_envelopes << envelope },
|
700
|
+
)
|
701
|
+
|
702
|
+
@pubnub.add_listener(callback: callbacks)
|
703
|
+
@pubnub.presence(channel: [:demo, "demo", "demo.*"], http_sync: false, callback: @callback)
|
704
|
+
end
|
878
705
|
|
706
|
+
eventually do
|
707
|
+
expect(@status_envelopes[0].status[:category]).to eq(:timeout)
|
708
|
+
expect(@status_envelopes[0].status[:error]).to eq(true)
|
709
|
+
expect(@status_envelopes[0].status[:auto_retried]).to eq(true)
|
710
|
+
expect(@status_envelopes[0].status[:current_timetoken]).to eq(0)
|
711
|
+
expect(@status_envelopes[0].status[:last_timetoken]).to eq(0)
|
712
|
+
expect(@status_envelopes[0].status[:subscribed_channels]).to eq(["demo-pnpres", "demo.*-pnpres"])
|
713
|
+
expect(@status_envelopes[0].status[:subscribed_channel_groups]).to eq([])
|
714
|
+
expect(@status_envelopes[0].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
715
|
+
|
716
|
+
expect(@status_envelopes[1].status[:category]).to eq(:timeout)
|
717
|
+
expect(@status_envelopes[1].status[:error]).to eq(true)
|
718
|
+
expect(@status_envelopes[1].status[:auto_retried]).to eq(true)
|
719
|
+
expect(@status_envelopes[1].status[:current_timetoken]).to eq(0)
|
720
|
+
expect(@status_envelopes[1].status[:last_timetoken]).to eq(0)
|
721
|
+
expect(@status_envelopes[1].status[:subscribed_channels]).to eq(["demo-pnpres", "demo.*-pnpres"])
|
722
|
+
expect(@status_envelopes[1].status[:subscribed_channel_groups]).to eq([])
|
723
|
+
expect(@status_envelopes[1].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
724
|
+
|
725
|
+
expect(@status_envelopes[2].status[:category]).to eq(:timeout)
|
726
|
+
expect(@status_envelopes[2].status[:error]).to eq(true)
|
727
|
+
expect(@status_envelopes[2].status[:auto_retried]).to eq(true)
|
728
|
+
expect(@status_envelopes[2].status[:current_timetoken]).to eq(0)
|
729
|
+
expect(@status_envelopes[2].status[:last_timetoken]).to eq(0)
|
730
|
+
expect(@status_envelopes[2].status[:subscribed_channels]).to eq(["demo-pnpres", "demo.*-pnpres"])
|
731
|
+
expect(@status_envelopes[2].status[:subscribed_channel_groups]).to eq([])
|
732
|
+
expect(@status_envelopes[2].status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", :auth_key => "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
|
733
|
+
end
|
734
|
+
end
|
879
735
|
end
|