pubnub 4.0.9 → 4.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pubnub might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.pubnub.yml +49 -3
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +2 -2
- data/VERSION +1 -1
- data/fixtures/vcr_cassettes/examples/status_request_message_count_exceeded.yml +1484 -0
- data/fixtures/vcr_cassettes/lib/super_admin/cg.yml +47 -0
- data/fixtures/vcr_cassettes/lib/super_admin/here_now.yml +47 -0
- data/fixtures/vcr_cassettes/lib/super_admin/history.yml +46 -0
- data/fixtures/vcr_cassettes/lib/super_admin/leave.yml +46 -0
- data/fixtures/vcr_cassettes/lib/super_admin/presence.yml +79 -0
- data/fixtures/vcr_cassettes/lib/super_admin/publish.yml +40 -0
- data/fixtures/vcr_cassettes/lib/super_admin/state.yml +47 -0
- data/fixtures/vcr_cassettes/lib/super_admin/subscribe.yml +77 -0
- data/fixtures/vcr_cassettes/lib/super_admin/time.yml +40 -0
- data/fixtures/vcr_cassettes/lib/super_admin/where_now.yml +47 -0
- data/lib/pubnub/client.rb +4 -0
- data/lib/pubnub/configuration.rb +2 -1
- data/lib/pubnub/constants.rb +2 -0
- data/lib/pubnub/event.rb +78 -20
- data/lib/pubnub/events/audit.rb +4 -0
- data/lib/pubnub/events/channel_registration.rb +3 -36
- data/lib/pubnub/events/grant.rb +4 -0
- data/lib/pubnub/events/heartbeat.rb +5 -38
- data/lib/pubnub/events/here_now.rb +5 -38
- data/lib/pubnub/events/history.rb +5 -38
- data/lib/pubnub/events/leave.rb +4 -39
- data/lib/pubnub/events/presence.rb +6 -0
- data/lib/pubnub/events/publish.rb +12 -45
- data/lib/pubnub/events/revoke.rb +4 -0
- data/lib/pubnub/events/set_state.rb +5 -33
- data/lib/pubnub/events/state.rb +5 -38
- data/lib/pubnub/events/subscribe.rb +6 -0
- data/lib/pubnub/events/time.rb +4 -37
- data/lib/pubnub/events/where_now.rb +4 -37
- data/lib/pubnub/formatter.rb +7 -5
- data/lib/pubnub/pam.rb +0 -18
- data/lib/pubnub/single_event.rb +0 -4
- data/lib/pubnub/subscribe_event.rb +3 -1
- data/lib/pubnub/subscribe_event/callbacks.rb +11 -0
- data/lib/pubnub/subscriber.rb +31 -0
- data/lib/pubnub/version.rb +1 -1
- data/spec/examples/channel_registration_examples_spec.rb +0 -1
- data/spec/examples/heartbeat_examples_spec.rb +0 -1
- data/spec/examples/here_now_examples_spec.rb +0 -1
- data/spec/examples/history_examples_spec.rb +0 -1
- data/spec/examples/leave_examples_spec.rb +0 -1
- data/spec/examples/presence_examples_spec.rb +0 -1
- data/spec/examples/publish_examples_spec.rb +0 -865
- data/spec/examples/revoke_examples_spec.rb +3888 -3888
- data/spec/examples/set_state_examples_spec.rb +0 -1
- data/spec/examples/state_examples_spec.rb +0 -1
- data/spec/examples/status_request_message_count_exceeded_spec.rb +41 -0
- data/spec/examples/subscribe_examples_spec.rb +0 -445
- data/spec/examples/time_examples_spec.rb +0 -1
- data/spec/examples/where_now_examples_spec.rb +0 -1
- data/spec/lib/events/channel_registration_spec.rb +0 -1
- data/spec/lib/events/heartbeat_spec.rb +0 -1
- data/spec/lib/events/here_now_spec.rb +0 -1
- data/spec/lib/events/history_spec.rb +0 -1
- data/spec/lib/events/leave_spec.rb +0 -1
- data/spec/lib/events/presence_spec.rb +0 -4
- data/spec/lib/events/publish_spec.rb +0 -3
- data/spec/lib/events/state_spec.rb +0 -1
- data/spec/lib/events/subscribe_spec.rb +0 -7
- data/spec/lib/events/time_spec.rb +0 -1
- data/spec/lib/events/timeout_handling_spec.rb +30 -0
- data/spec/lib/events/where_now_spec.rb +0 -1
- data/spec/lib/super_admin_spec.rb +166 -0
- data/spec/spec_helper.rb +5 -3
- metadata +33 -16
@@ -12,6 +12,10 @@ module Pubnub
|
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
|
+
def current_operation
|
16
|
+
Pubnub::Constants::OPERATION_HISTORY
|
17
|
+
end
|
18
|
+
|
15
19
|
def timetoken(message)
|
16
20
|
message['timetoken'] if @include_token
|
17
21
|
end
|
@@ -41,7 +45,7 @@ module Pubnub
|
|
41
45
|
].join('/')
|
42
46
|
end
|
43
47
|
|
44
|
-
def parameters
|
48
|
+
def parameters(*_args)
|
45
49
|
params = super
|
46
50
|
params.merge!(start: @start) if @start
|
47
51
|
params.merge!(end: @end) if @end
|
@@ -51,18 +55,6 @@ module Pubnub
|
|
51
55
|
params
|
52
56
|
end
|
53
57
|
|
54
|
-
def format_envelopes(response, request)
|
55
|
-
parsed_response, error = Formatter.parse_json(response.body)
|
56
|
-
|
57
|
-
error = response if parsed_response && response.code.to_i != 200
|
58
|
-
|
59
|
-
if error
|
60
|
-
error_envelope(parsed_response, error, request: uri, response: response)
|
61
|
-
else
|
62
|
-
valid_envelope(parsed_response, request: request, response: response)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
58
|
def valid_envelope(parsed_response, req_res_objects)
|
67
59
|
messages = parsed_response[0]
|
68
60
|
|
@@ -110,30 +102,5 @@ module Pubnub
|
|
110
102
|
}
|
111
103
|
)
|
112
104
|
end
|
113
|
-
|
114
|
-
def error_envelope(_parsed_response, error, req_res_objects)
|
115
|
-
Pubnub::ErrorEnvelope.new(
|
116
|
-
event: @event,
|
117
|
-
event_options: @given_options,
|
118
|
-
timetoken: nil,
|
119
|
-
status: {
|
120
|
-
code: req_res_objects[:response].code,
|
121
|
-
operation: Pubnub::Constants::OPERATION_HEARTBEAT,
|
122
|
-
client_request: req_res_objects[:request],
|
123
|
-
server_response: req_res_objects[:response],
|
124
|
-
data: nil,
|
125
|
-
category: (error ? Pubnub::Constants::STATUS_NON_JSON_RESPONSE : Pubnub::Constants::STATUS_ERROR),
|
126
|
-
error: true,
|
127
|
-
auto_retried: false,
|
128
|
-
|
129
|
-
current_timetoken: nil,
|
130
|
-
last_timetoken: nil,
|
131
|
-
subscribed_channels: nil,
|
132
|
-
subscribed_channel_groups: nil,
|
133
|
-
|
134
|
-
config: get_config
|
135
|
-
}
|
136
|
-
)
|
137
|
-
end
|
138
105
|
end
|
139
106
|
end
|
data/lib/pubnub/events/leave.rb
CHANGED
@@ -18,6 +18,10 @@ module Pubnub
|
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
+
def current_operation
|
22
|
+
Pubnub::Constants::OPERATION_PRESENCE_LEAVE
|
23
|
+
end
|
24
|
+
|
21
25
|
def path
|
22
26
|
'/' + [
|
23
27
|
'v2',
|
@@ -30,20 +34,6 @@ module Pubnub
|
|
30
34
|
].join('/')
|
31
35
|
end
|
32
36
|
|
33
|
-
def format_envelopes(response, request)
|
34
|
-
parsed_response, error = Formatter.parse_json(response.body)
|
35
|
-
|
36
|
-
error = response if parsed_response && response.code.to_i != 200
|
37
|
-
|
38
|
-
envelopes = if error
|
39
|
-
error_envelope(parsed_response, error, request: request, response: response)
|
40
|
-
else
|
41
|
-
valid_envelope(parsed_response, request: request, response: response)
|
42
|
-
end
|
43
|
-
|
44
|
-
envelopes
|
45
|
-
end
|
46
|
-
|
47
37
|
def valid_envelope(parsed_response, req_res_objects)
|
48
38
|
Pubnub::Envelope.new(
|
49
39
|
event: @event,
|
@@ -68,30 +58,5 @@ module Pubnub
|
|
68
58
|
}
|
69
59
|
)
|
70
60
|
end
|
71
|
-
|
72
|
-
def error_envelope(_parsed_response, error, req_res_objects)
|
73
|
-
Pubnub::ErrorEnvelope.new(
|
74
|
-
event: @event,
|
75
|
-
event_options: @given_options,
|
76
|
-
timetoken: nil,
|
77
|
-
status: {
|
78
|
-
code: req_res_objects[:response].code,
|
79
|
-
operation: Pubnub::Constants::OPERATION_HEARTBEAT,
|
80
|
-
client_request: req_res_objects[:request],
|
81
|
-
server_response: req_res_objects[:response],
|
82
|
-
data: nil,
|
83
|
-
category: (error ? Pubnub::Constants::STATUS_NON_JSON_RESPONSE : Pubnub::Constants::STATUS_ERROR),
|
84
|
-
error: true,
|
85
|
-
auto_retried: false,
|
86
|
-
|
87
|
-
current_timetoken: nil,
|
88
|
-
last_timetoken: nil,
|
89
|
-
subscribed_channels: nil,
|
90
|
-
subscribed_channel_groups: nil,
|
91
|
-
|
92
|
-
config: get_config
|
93
|
-
}
|
94
|
-
)
|
95
|
-
end
|
96
61
|
end
|
97
62
|
end
|
@@ -10,7 +10,9 @@ module Pubnub
|
|
10
10
|
def initialize(options, app)
|
11
11
|
@event = :publish
|
12
12
|
super
|
13
|
-
@sequence_number
|
13
|
+
@sequence_number = sequence_number!
|
14
|
+
@origination_time_token = @app.generate_ortt
|
15
|
+
|
14
16
|
@store = case @store
|
15
17
|
when false
|
16
18
|
0
|
@@ -33,15 +35,17 @@ module Pubnub
|
|
33
35
|
finalize_event(envelopes)
|
34
36
|
envelopes
|
35
37
|
ensure
|
36
|
-
# sender.terminate if @http_sync
|
37
38
|
terminate unless @stay_alive
|
38
39
|
end
|
39
40
|
|
40
41
|
private
|
41
42
|
|
42
|
-
def
|
43
|
-
|
44
|
-
|
43
|
+
def current_operation
|
44
|
+
Pubnub::Constants::OPERATION_PUBLISH
|
45
|
+
end
|
46
|
+
|
47
|
+
def parameters(*_args)
|
48
|
+
params = super
|
45
49
|
|
46
50
|
empty_if_blank = {
|
47
51
|
store: @store,
|
@@ -51,12 +55,12 @@ module Pubnub
|
|
51
55
|
replication = @replicate == false ? { norep: true } : {}
|
52
56
|
|
53
57
|
empty_if_blank.delete_if { |_k, v| v.blank? }
|
54
|
-
|
58
|
+
|
55
59
|
params = params.merge(empty_if_blank)
|
56
60
|
params = params.merge(replication)
|
57
61
|
params = params.merge(seqn: @sequence_number,
|
58
|
-
ortt:
|
59
|
-
|
62
|
+
ortt: { t: @origination_time_token })
|
63
|
+
params
|
60
64
|
end
|
61
65
|
|
62
66
|
def path
|
@@ -91,18 +95,6 @@ module Pubnub
|
|
91
95
|
nil
|
92
96
|
end
|
93
97
|
|
94
|
-
def format_envelopes(response, request)
|
95
|
-
parsed_response, error = Formatter.parse_json(response.body)
|
96
|
-
|
97
|
-
error = response if parsed_response && response.code.to_i != 200
|
98
|
-
|
99
|
-
if error
|
100
|
-
error_envelope(parsed_response, error, request: request, response: response)
|
101
|
-
else
|
102
|
-
valid_envelope(parsed_response, request: request, response: response)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
98
|
def valid_envelope(_parsed_response, req_res_objects)
|
107
99
|
Pubnub::Envelope.new(
|
108
100
|
event: @event,
|
@@ -127,30 +119,5 @@ module Pubnub
|
|
127
119
|
}
|
128
120
|
)
|
129
121
|
end
|
130
|
-
|
131
|
-
def error_envelope(_parsed_response, error, req_res_objects)
|
132
|
-
Pubnub::ErrorEnvelope.new(
|
133
|
-
event: @event,
|
134
|
-
event_options: @given_options,
|
135
|
-
timetoken: nil,
|
136
|
-
status: {
|
137
|
-
code: req_res_objects[:response].code,
|
138
|
-
operation: Pubnub::Constants::OPERATION_PUBLISH,
|
139
|
-
client_request: req_res_objects[:request],
|
140
|
-
server_response: req_res_objects[:response],
|
141
|
-
data: nil,
|
142
|
-
category: (error ? Pubnub::Constants::STATUS_NON_JSON_RESPONSE : Pubnub::Constants::STATUS_ERROR),
|
143
|
-
error: true,
|
144
|
-
auto_retried: false,
|
145
|
-
|
146
|
-
current_timetoken: nil,
|
147
|
-
last_timetoken: nil,
|
148
|
-
subscribed_channels: nil,
|
149
|
-
subscribed_channel_groups: nil,
|
150
|
-
|
151
|
-
config: get_config
|
152
|
-
}
|
153
|
-
)
|
154
|
-
end
|
155
122
|
end
|
156
123
|
end
|
data/lib/pubnub/events/revoke.rb
CHANGED
@@ -13,7 +13,11 @@ module Pubnub
|
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def
|
16
|
+
def current_operation
|
17
|
+
Pubnub::Constants::OPERATION_SET_STATE
|
18
|
+
end
|
19
|
+
|
20
|
+
def parameters(*_args)
|
17
21
|
parameters = super
|
18
22
|
parameters.merge!(state: encode_parameter(@state))
|
19
23
|
parameters.merge!('channel-group' => format_channel_group(@group).join(',')) unless @group.blank?
|
@@ -34,18 +38,6 @@ module Pubnub
|
|
34
38
|
].join('/')
|
35
39
|
end
|
36
40
|
|
37
|
-
def format_envelopes(response, request)
|
38
|
-
parsed_response, error = Formatter.parse_json(response.body)
|
39
|
-
|
40
|
-
error = response if parsed_response && response.code.to_i != 200
|
41
|
-
|
42
|
-
if error
|
43
|
-
error_envelope(parsed_response, error, request: request, response: response)
|
44
|
-
else
|
45
|
-
valid_envelope(parsed_response, request: request, response: response)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
41
|
def valid_envelope(_parsed_response, req_res_objects)
|
50
42
|
Pubnub::Envelope.new(
|
51
43
|
event: @event,
|
@@ -70,25 +62,5 @@ module Pubnub
|
|
70
62
|
}
|
71
63
|
)
|
72
64
|
end
|
73
|
-
|
74
|
-
def error_envelope(_parsed_response, error, req_res_objects)
|
75
|
-
Pubnub::ErrorEnvelope.new(
|
76
|
-
event: @event,
|
77
|
-
event_options: @given_options,
|
78
|
-
timetoken: nil,
|
79
|
-
status: {
|
80
|
-
code: req_res_objects[:response].code,
|
81
|
-
operation: Pubnub::Constants::OPERATION_SET_STATE,
|
82
|
-
client_request: req_res_objects[:request],
|
83
|
-
server_response: req_res_objects[:response],
|
84
|
-
data: nil,
|
85
|
-
category: (error ? Pubnub::Constants::STATUS_NON_JSON_RESPONSE : Pubnub::Constants::STATUS_ERROR),
|
86
|
-
error: true,
|
87
|
-
auto_retried: false,
|
88
|
-
|
89
|
-
config: get_config
|
90
|
-
}
|
91
|
-
)
|
92
|
-
end
|
93
65
|
end
|
94
66
|
end
|
data/lib/pubnub/events/state.rb
CHANGED
@@ -14,7 +14,11 @@ module Pubnub
|
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
-
def
|
17
|
+
def current_operation
|
18
|
+
Pubnub::Constants::OPERATION_GET_STATE
|
19
|
+
end
|
20
|
+
|
21
|
+
def parameters(*_args)
|
18
22
|
parameters = super
|
19
23
|
parameters.merge!(
|
20
24
|
'channel-group' => @group.join(',')
|
@@ -35,18 +39,6 @@ module Pubnub
|
|
35
39
|
].join('/')
|
36
40
|
end
|
37
41
|
|
38
|
-
def format_envelopes(response, request)
|
39
|
-
parsed_response, error = Formatter.parse_json(response.body)
|
40
|
-
|
41
|
-
error = response if parsed_response && response.code.to_i != 200
|
42
|
-
|
43
|
-
if error
|
44
|
-
error_envelope(parsed_response, error, request: request, response: response)
|
45
|
-
else
|
46
|
-
valid_envelope(parsed_response, request: request, response: response)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
42
|
def valid_envelope(parsed_response, req_res_objects)
|
51
43
|
Pubnub::Envelope.new(
|
52
44
|
event: @event,
|
@@ -82,30 +74,5 @@ module Pubnub
|
|
82
74
|
}
|
83
75
|
)
|
84
76
|
end
|
85
|
-
|
86
|
-
def error_envelope(_parsed_response, error, req_res_objects)
|
87
|
-
Pubnub::ErrorEnvelope.new(
|
88
|
-
event: @event,
|
89
|
-
event_options: @given_options,
|
90
|
-
timetoken: nil,
|
91
|
-
status: {
|
92
|
-
code: req_res_objects[:response].code,
|
93
|
-
operation: Pubnub::Constants::OPERATION_HEARTBEAT,
|
94
|
-
client_request: req_res_objects[:request],
|
95
|
-
server_response: req_res_objects[:response],
|
96
|
-
data: nil,
|
97
|
-
category: (error ? Pubnub::Constants::STATUS_NON_JSON_RESPONSE : Pubnub::Constants::STATUS_ERROR),
|
98
|
-
error: true,
|
99
|
-
auto_retried: false,
|
100
|
-
|
101
|
-
current_timetoken: nil,
|
102
|
-
last_timetoken: nil,
|
103
|
-
subscribed_channels: nil,
|
104
|
-
subscribed_channel_groups: nil,
|
105
|
-
|
106
|
-
config: get_config
|
107
|
-
}
|
108
|
-
)
|
109
|
-
end
|
110
77
|
end
|
111
78
|
end
|
data/lib/pubnub/events/time.rb
CHANGED
@@ -12,6 +12,10 @@ module Pubnub
|
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
|
+
def current_operation
|
16
|
+
Pubnub::Constants::OPERATION_TIME
|
17
|
+
end
|
18
|
+
|
15
19
|
def path
|
16
20
|
'/time/0'
|
17
21
|
end
|
@@ -22,18 +26,6 @@ module Pubnub
|
|
22
26
|
nil
|
23
27
|
end
|
24
28
|
|
25
|
-
def format_envelopes(response, request)
|
26
|
-
parsed_response, error = Formatter.parse_json(response.body)
|
27
|
-
|
28
|
-
error = response if parsed_response && response.code.to_i != 200
|
29
|
-
|
30
|
-
if error
|
31
|
-
error_envelope(parsed_response, error, request: request, response: response)
|
32
|
-
else
|
33
|
-
valid_envelope(parsed_response, request: request, response: response)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
29
|
def valid_envelope(parsed_response, req_res_objects)
|
38
30
|
Pubnub::Envelope.new(
|
39
31
|
event: @event,
|
@@ -64,30 +56,5 @@ module Pubnub
|
|
64
56
|
}
|
65
57
|
)
|
66
58
|
end
|
67
|
-
|
68
|
-
def error_envelope(_parsed_response, error, req_res_objects)
|
69
|
-
Pubnub::ErrorEnvelope.new(
|
70
|
-
event: @event,
|
71
|
-
event_options: @given_options,
|
72
|
-
timetoken: nil,
|
73
|
-
status: {
|
74
|
-
code: req_res_objects[:response].code,
|
75
|
-
operation: Pubnub::Constants::OPERATION_HEARTBEAT,
|
76
|
-
client_request: req_res_objects[:request],
|
77
|
-
server_response: req_res_objects[:response],
|
78
|
-
data: nil,
|
79
|
-
category: (error ? Pubnub::Constants::STATUS_NON_JSON_RESPONSE : Pubnub::Constants::STATUS_ERROR),
|
80
|
-
error: true,
|
81
|
-
auto_retried: false,
|
82
|
-
|
83
|
-
current_timetoken: nil,
|
84
|
-
last_timetoken: nil,
|
85
|
-
subscribed_channels: nil,
|
86
|
-
subscribed_channel_groups: nil,
|
87
|
-
|
88
|
-
config: get_config
|
89
|
-
}
|
90
|
-
)
|
91
|
-
end
|
92
59
|
end
|
93
60
|
end
|