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.

Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.pubnub.yml +8 -1
  3. data/.rubocop.yml +9 -3
  4. data/.travis.yml +6 -19
  5. data/CHANGELOG.md +86 -82
  6. data/Gemfile +7 -5
  7. data/Gemfile.lock +155 -157
  8. data/README.md +34 -34
  9. data/VERSION +1 -1
  10. data/gemfiles/celluloid_017.gemfile +4 -4
  11. data/gemfiles/celluloid_018.gemfile +4 -4
  12. data/gemfiles/celluloid_master.gemfile +4 -4
  13. data/gemfiles/concurrent-ruby-1.0.5.gem +0 -0
  14. data/gemfiles/concurrent-ruby-edge-0.3.1.gem +0 -0
  15. data/lib/pubnub.rb +3 -3
  16. data/lib/pubnub/client.rb +19 -16
  17. data/lib/pubnub/client/events.rb +5 -5
  18. data/lib/pubnub/client/getters_setters.rb +11 -12
  19. data/lib/pubnub/client/paged_history.rb +11 -9
  20. data/lib/pubnub/configuration.rb +1 -2
  21. data/lib/pubnub/constants.rb +47 -47
  22. data/lib/pubnub/crypto.rb +2 -2
  23. data/lib/pubnub/envelope.rb +7 -5
  24. data/lib/pubnub/error.rb +22 -15
  25. data/lib/pubnub/event.rb +24 -25
  26. data/lib/pubnub/event/formatter.rb +8 -5
  27. data/lib/pubnub/event/signature.rb +3 -3
  28. data/lib/pubnub/events/audit.rb +1 -1
  29. data/lib/pubnub/events/channel_registration.rb +10 -15
  30. data/lib/pubnub/events/delete_messages.rb +9 -9
  31. data/lib/pubnub/events/grant.rb +3 -3
  32. data/lib/pubnub/events/heartbeat.rb +4 -8
  33. data/lib/pubnub/events/here_now.rb +4 -8
  34. data/lib/pubnub/events/history.rb +10 -10
  35. data/lib/pubnub/events/leave.rb +2 -2
  36. data/lib/pubnub/events/presence.rb +1 -1
  37. data/lib/pubnub/events/publish.rb +3 -5
  38. data/lib/pubnub/events/revoke.rb +3 -3
  39. data/lib/pubnub/events/set_state.rb +3 -3
  40. data/lib/pubnub/events/state.rb +4 -6
  41. data/lib/pubnub/events/subscribe.rb +1 -1
  42. data/lib/pubnub/events/time.rb +2 -2
  43. data/lib/pubnub/events/where_now.rb +6 -6
  44. data/lib/pubnub/format.rb +73 -0
  45. data/lib/pubnub/formatter.rb +23 -21
  46. data/lib/pubnub/heart.rb +4 -4
  47. data/lib/pubnub/origin_manager.rb +3 -5
  48. data/lib/pubnub/pam.rb +5 -5
  49. data/lib/pubnub/schemas/envelope_schema.rb +1 -1
  50. data/lib/pubnub/subscribe_callback.rb +3 -3
  51. data/lib/pubnub/subscribe_event.rb +6 -10
  52. data/lib/pubnub/subscribe_event/formatter.rb +82 -80
  53. data/lib/pubnub/subscribe_event/heartbeat.rb +1 -1
  54. data/lib/pubnub/subscriber.rb +31 -32
  55. data/lib/pubnub/telemetry.rb +26 -27
  56. data/lib/pubnub/validators/audit.rb +3 -2
  57. data/lib/pubnub/validators/channel_registration.rb +6 -4
  58. data/lib/pubnub/validators/client.rb +1 -0
  59. data/lib/pubnub/validators/common_validator.rb +37 -31
  60. data/lib/pubnub/validators/delete.rb +5 -4
  61. data/lib/pubnub/validators/grant.rb +3 -2
  62. data/lib/pubnub/validators/history.rb +3 -2
  63. data/lib/pubnub/validators/leave.rb +3 -2
  64. data/lib/pubnub/validators/presence.rb +3 -2
  65. data/lib/pubnub/validators/publish.rb +15 -10
  66. data/lib/pubnub/validators/set_state.rb +0 -2
  67. data/lib/pubnub/validators/state.rb +3 -2
  68. data/lib/pubnub/version.rb +1 -1
  69. data/pubnub.gemspec +19 -18
  70. data/spec/examples/audit_examples_spec.rb +1268 -1418
  71. data/spec/examples/channel_registration_examples_spec.rb +655 -757
  72. data/spec/examples/delete_messages_examples_spec.rb +19 -21
  73. data/spec/examples/grant_examples_spec.rb +34028 -37920
  74. data/spec/examples/heartbeat_examples_spec.rb +583 -731
  75. data/spec/examples/here_now_examples_spec.rb +493 -569
  76. data/spec/examples/history_examples_spec.rb +979 -1127
  77. data/spec/examples/leave_examples_spec.rb +439 -551
  78. data/spec/examples/presence_examples_spec.rb +686 -830
  79. data/spec/examples/publish_examples_spec.rb +27223 -31547
  80. data/spec/examples/publish_with_ttl_spec.rb +11 -14
  81. data/spec/examples/revoke_examples_spec.rb +68048 -75828
  82. data/spec/examples/set_state_examples_spec.rb +295 -371
  83. data/spec/examples/state_examples_spec.rb +169 -197
  84. data/spec/examples/status_request_message_count_exceeded_spec.rb +16 -19
  85. data/spec/examples/subscribe_examples_spec.rb +43843 -52035
  86. data/spec/examples/time_examples_spec.rb +82 -98
  87. data/spec/examples/where_now_examples_spec.rb +88 -104
  88. data/spec/lib/client_spec.rb +99 -117
  89. data/spec/lib/connection_callback_spec.rb +27 -33
  90. data/spec/lib/custom_retries_examples_spec.rb +8 -11
  91. data/spec/lib/event_spec.rb +35 -42
  92. data/spec/lib/events/audit_spec.rb +19 -25
  93. data/spec/lib/events/channel_registration_spec.rb +17 -23
  94. data/spec/lib/events/delete_messages_spec.rb +14 -20
  95. data/spec/lib/events/grant_spec.rb +15 -21
  96. data/spec/lib/events/heartbeat_spec.rb +21 -27
  97. data/spec/lib/events/here_now_spec.rb +14 -20
  98. data/spec/lib/events/history_spec.rb +14 -20
  99. data/spec/lib/events/leave_spec.rb +14 -20
  100. data/spec/lib/events/presence_delta_spec.rb +15 -16
  101. data/spec/lib/events/presence_spec.rb +36 -45
  102. data/spec/lib/events/publish_spec.rb +33 -40
  103. data/spec/lib/events/revoke_spec.rb +16 -22
  104. data/spec/lib/events/state_spec.rb +16 -22
  105. data/spec/lib/events/subscribe_spec.rb +75 -85
  106. data/spec/lib/events/time_spec.rb +12 -18
  107. data/spec/lib/events/timeout_handling_spec.rb +8 -14
  108. data/spec/lib/events/where_now_spec.rb +14 -20
  109. data/spec/lib/keep_alive_spec.rb +4 -8
  110. data/spec/lib/multiple_ciphers_spec.rb +56 -60
  111. data/spec/lib/pubnub_spec.rb +10 -13
  112. data/spec/lib/signatures_spec.rb +118 -120
  113. data/spec/lib/ssl_error_spec.rb +14 -18
  114. data/spec/lib/super_admin_spec.rb +58 -66
  115. data/spec/lib/uuid_spec.rb +3 -4
  116. data/spec/spec_expectations.rb +3 -3
  117. data/spec/spec_helper.rb +29 -46
  118. metadata +52 -22
  119. data/lib/pubnub/message.rb +0 -43
@@ -26,7 +26,7 @@ module Pubnub
26
26
  def decrypt(cipher_text)
27
27
  decode_cipher = OpenSSL::Cipher.new(@alg).decrypt
28
28
  decode_cipher.key = @key
29
- decode_cipher.iv = @iv
29
+ decode_cipher.iv = @iv
30
30
 
31
31
  plain_text = decryption(cipher_text, decode_cipher)
32
32
  load_json(plain_text)
@@ -42,7 +42,7 @@ module Pubnub
42
42
  undecoded_text = Base64.decode64(cipher_text)
43
43
  plain_text = decode_cipher.update(undecoded_text)
44
44
  plain_text << decode_cipher.final
45
- rescue => e
45
+ rescue StandardError => e
46
46
  Pubnub.error('Pubnub') { "DECRYPTION ERROR #{e}" }
47
47
  '"DECRYPTION ERROR"'
48
48
  end
@@ -10,13 +10,13 @@ module Pubnub
10
10
  attr_accessor :status, :result, :timetoken
11
11
 
12
12
  def initialize(options)
13
- @id = UUID.generate # internal usage only
13
+ @id = UUID.generate # internal usage only
14
14
 
15
- @event = options[:event]
15
+ @event = options[:event]
16
16
  @event_options = options[:event_options]
17
- @status = options[:status]
18
- @result = options[:result]
19
- @timetoken = options[:timetoken]
17
+ @status = options[:status]
18
+ @result = options[:result]
19
+ @timetoken = options[:timetoken]
20
20
  end
21
21
 
22
22
  def repeat(client, changes = {})
@@ -31,12 +31,14 @@ module Pubnub
31
31
  def last?
32
32
  last
33
33
  end
34
+
34
35
  # :nocov:
35
36
 
36
37
  # :nocov:
37
38
  def first?
38
39
  first
39
40
  end
41
+
40
42
  # :nocov:
41
43
  end
42
44
  end
@@ -5,9 +5,7 @@ module Pubnub
5
5
  attr_reader :env, :message
6
6
 
7
7
  def initialize(env = {})
8
- unless env.instance_of? Hash
9
- fail ::ArgumentError, 'Env passed to Pubnub::Error must be a hash'
10
- end
8
+ raise ::ArgumentError, 'Env passed to Pubnub::Error must be a hash' unless env.instance_of? Hash
11
9
 
12
10
  @env = env
13
11
  @message = ''
@@ -20,13 +18,13 @@ module Pubnub
20
18
  private
21
19
 
22
20
  def build_message
23
- insert_value 'operation', @env[:operation]
24
- insert_value 'request', @env[:request]
25
- insert_value 'env', @env[:env]
26
- insert_value 'app', @env[:app]
27
- insert_value 'response', @env[:response]
28
- insert_value 'error type', @env[:error]
29
- insert_value 'error message', @env[:message]
21
+ insert_value 'operation', @env[:operation]
22
+ insert_value 'request', @env[:request]
23
+ insert_value 'env', @env[:env]
24
+ insert_value 'app', @env[:app]
25
+ insert_value 'response', @env[:response]
26
+ insert_value 'error type', @env[:error]
27
+ insert_value 'error message', @env[:message]
30
28
  insert_value 'error backtrace', backtrace
31
29
  end
32
30
 
@@ -39,9 +37,18 @@ module Pubnub
39
37
  end
40
38
  end
41
39
 
42
- class JSONParseError < Error; end
43
- class InitializationError < Error; end
44
- class ArgumentError < Error; end
45
- class RequestError < Error; end
46
- class ResponseError < Error; end
40
+ class JSONParseError < Error
41
+ end
42
+
43
+ class InitializationError < Error
44
+ end
45
+
46
+ class ArgumentError < Error
47
+ end
48
+
49
+ class RequestError < Error
50
+ end
51
+
52
+ class ResponseError < Error
53
+ end
47
54
  end
@@ -11,8 +11,8 @@ module Pubnub
11
11
  :presence_callback, :wildcard_channel, :ssl, :state,
12
12
  :given_options, :with_presence
13
13
 
14
- alias_method :channels, :channel
15
- alias_method :channel_groups, :channel_group
14
+ alias channels channel
15
+ alias channel_groups channel_group
16
16
 
17
17
  include Signature
18
18
  include EFormatter
@@ -41,8 +41,6 @@ module Pubnub
41
41
  envelopes = fire_callbacks(handle(response, uri))
42
42
  finalize_event(envelopes)
43
43
  envelopes
44
- ensure
45
- terminate unless @stay_alive
46
44
  end
47
45
 
48
46
  def send_request(compressed_body = '')
@@ -52,28 +50,28 @@ module Pubnub
52
50
  Pubnub.logger.debug('Pubnub::Event') { '#send_request got sender' }
53
51
 
54
52
  telemetry_time_start = ::Time.now.to_f
55
- if @event == Pubnub::Constants::OPERATION_DELETE
56
- response = sender.delete(uri.to_s)
57
- elsif compressed_body.empty?
58
- response = sender.get(uri.to_s)
59
- else
60
- response = sender.post(uri.to_s, body: compressed_body)
61
- end
53
+ response = if @event == Pubnub::Constants::OPERATION_DELETE
54
+ sender.delete(uri.to_s)
55
+ elsif compressed_body.empty?
56
+ sender.get(uri.to_s)
57
+ else
58
+ sender.post(uri.to_s, body: compressed_body)
59
+ end
62
60
 
63
61
  begin
64
62
  @app.record_telemetry(@telemetry_name, telemetry_time_start, ::Time.now.to_f)
65
- rescue => error
63
+ rescue StandardError => error
66
64
  Pubnub.logger.warn('Pubnub::Event') { "Couldn't record telemetry because of #{error}\n#{error.backtrace.join("\n")}" }
67
65
  end
68
66
 
69
- return response
70
- rescue => error
71
- Pubnub.logger.error('Pubnub::Event'){ error }
67
+ response
68
+ rescue StandardError => error
69
+ Pubnub.logger.error('Pubnub::Event') { error }
72
70
  error
73
71
  end
74
72
 
75
73
  def uri(memo = true)
76
- unless self.is_a? SubscribeEvent
74
+ unless is_a? SubscribeEvent
77
75
  return @uri = uri(false) if memo
78
76
  return @uri if @uri
79
77
  end
@@ -101,7 +99,7 @@ module Pubnub
101
99
 
102
100
  def secure_call(cb, arg)
103
101
  cb.call arg
104
- rescue => error
102
+ rescue StandardError => error
105
103
  Pubnub.logger.error('Pubnub::Event') { "Error while calling callback #{error.inspect}" }
106
104
  end
107
105
 
@@ -122,10 +120,11 @@ module Pubnub
122
120
  @telemetry_name => @current_telemetry
123
121
  }
124
122
 
125
- required.merge!(timestamp: @timestamp) if @app.env[:secret_key] && ![:grant, :revoke, :audit].include?(@event)
123
+ empty_if_blank[@telemetry_name] = nil if @app.env[:no_telemetry]
126
124
 
127
- empty_if_blank.delete_if { |_k, v| v.blank? }
125
+ required[:timestamp] = @timestamp if @app.env[:secret_key] && !%i[grant revoke audit].include?(@event)
128
126
 
127
+ empty_if_blank.delete_if { |_k, v| v.blank? }
129
128
  required.merge(empty_if_blank)
130
129
  end
131
130
 
@@ -135,14 +134,14 @@ module Pubnub
135
134
  end
136
135
 
137
136
  def create_variables_from_options(options)
138
- variables = %w(channel channels message http_sync callback
137
+ variables = %w[channel channels message http_sync callback
139
138
  ssl cipher_key secret_key auth_key
140
139
  publish_key subscribe_key timetoken
141
140
  open_timeout read_timeout idle_timeout heartbeat
142
141
  group action read write manage ttl presence start
143
142
  end count reverse presence_callback store skip_validate
144
143
  state channel_group channel_groups compressed meta customs include_token
145
- replicate with_presence cipher_key_selector)
144
+ replicate with_presence cipher_key_selector]
146
145
 
147
146
  options = options.each_with_object({}) { |option, obj| obj[option.first.to_sym] = option.last }
148
147
 
@@ -176,16 +175,16 @@ module Pubnub
176
175
 
177
176
  def error_message(parsed_response)
178
177
  parsed_response['message']
179
- rescue
178
+ rescue StandardError
180
179
  nil
181
180
  end
182
181
 
183
182
  def get_config
184
183
  {
185
- tls: @app.env[:ssl],
186
- uuid: @app.env[:uuid],
184
+ tls: @app.env[:ssl],
185
+ uuid: @app.env[:uuid],
187
186
  auth_key: @app.env[:auth_key],
188
- origin: @app.current_origin
187
+ origin: @app.current_origin
189
188
  }
190
189
  end
191
190
 
@@ -5,12 +5,15 @@ module Pubnub
5
5
  # Module that holds formatters for events
6
6
  module EFormatter
7
7
  def format_envelopes(response, request)
8
- if response.kind_of?(HTTPClient::TimeoutError) || response.is_a?(OpenSSL::SSL::SSLError)
9
- return error_envelope(nil, response, request: request, response: response)
10
- else
11
- parsed_response, error = Formatter.parse_json(response.body)
8
+ if response.is_a?(HTTPClient::TimeoutError) || response.is_a?(OpenSSL::SSL::SSLError)
9
+ return error_envelope(nil,
10
+ response,
11
+ request: request,
12
+ response: response)
12
13
  end
13
14
 
15
+ parsed_response, error = Formatter.parse_json(response.body)
16
+
14
17
  error = response if parsed_response && response.code.to_i != 200
15
18
 
16
19
  if error
@@ -21,7 +24,7 @@ module Pubnub
21
24
  end
22
25
 
23
26
  def format_channels
24
- @channel = Formatter.format_channel(@channel || @channels)
27
+ @channel = Formatter.format_channel(@channel || @channels)
25
28
  @channel += Formatter.format_presence_channel(@presence)
26
29
  @channel += Formatter.format_presence_channel(@channel || @channels) if @with_presence
27
30
  @wildcard_channel = @channel.select { |e| e.index('.*') } || []
@@ -13,7 +13,7 @@ module Pubnub
13
13
  @app.env[:subscribe_key],
14
14
  @app.env[:publish_key],
15
15
  path,
16
- variables_for_signature.gsub(/[!~'()*]/) { |char| '%' + char.ord.to_s(16).upcase } # Replace ! ~ * ' ( )
16
+ variables_for_signature.gsub(/[!~'()*]/) { |char| '%' + char.ord.to_s(16).upcase }, # Replace ! ~ * ' ( )
17
17
  ].join("\n")
18
18
 
19
19
  URI.encode_www_form_component(Base64.encode64(
@@ -24,10 +24,10 @@ module Pubnub
24
24
 
25
25
  def variables_for_signature
26
26
  parameters(true).map do |k, v|
27
- if %w(meta ortt).include?(k.to_s)
27
+ if %w[meta ortt].include?(k.to_s)
28
28
  encoded_value = URI.encode_www_form_component(v.to_json).gsub('+', '%20')
29
29
  "#{k}=#{encoded_value}"
30
- elsif %w(t state filter-expr).include?(k.to_s)
30
+ elsif %w[t state filter-expr].include?(k.to_s)
31
31
  "#{k}=#{v}"
32
32
  else
33
33
  "#{k}=#{URI.encode_www_form_component(v.to_s).gsub('+', '%20')}"
@@ -2,7 +2,7 @@
2
2
  module Pubnub
3
3
  # Holds here_now functionality
4
4
  class Audit < PAM
5
- include Celluloid
5
+ include Concurrent::Async
6
6
  include Pubnub::Validator::Audit
7
7
 
8
8
  def initialize(options, app)
@@ -2,7 +2,7 @@
2
2
  module Pubnub
3
3
  # Holds channel_registration functionality
4
4
  class ChannelRegistration < SingleEvent
5
- include Celluloid
5
+ include Concurrent::Async
6
6
  include Pubnub::Validator::ChannelRegistration
7
7
 
8
8
  def initialize(options, app)
@@ -16,13 +16,9 @@ module Pubnub
16
16
 
17
17
  def parameters(*_args)
18
18
  parameters = super
19
- if @action == :add && !@channel.blank?
20
- parameters.merge!(add: Formatter.channels_for_url(@channel, false))
21
- end
19
+ parameters[:add] = Formatter.channels_for_url(@channel, false) if @action == :add && !@channel.blank?
22
20
 
23
- if @action == :remove && !@channel.blank?
24
- parameters.merge!(remove: Formatter.channels_for_url(@channel, false))
25
- end
21
+ parameters[:remove] = Formatter.channels_for_url(@channel, false) if @action == :remove && !@channel.blank?
26
22
 
27
23
  parameters
28
24
  end
@@ -31,15 +27,15 @@ module Pubnub
31
27
  head = "/v1/channel-registration/sub-key/#{@subscribe_key}/"
32
28
 
33
29
  body = case @action
34
- when :list_groups then
30
+ when :list_groups
35
31
  body_list_groups
36
- when :list_namespaces then
32
+ when :list_namespaces
37
33
  body_list_namespaces
38
- when :get then
34
+ when :get
39
35
  body_get
40
- when :add then
36
+ when :add
41
37
  body_add
42
- when :remove then
38
+ when :remove
43
39
  body_remove
44
40
  else
45
41
  raise_action_key_error
@@ -49,7 +45,7 @@ module Pubnub
49
45
  end
50
46
 
51
47
  def raise_action_key_error
52
- fail ArgumentError.new(
48
+ raise ArgumentError.new(
53
49
  object: self,
54
50
  message: 'ChannelRegistration requires proper :action key'
55
51
  ), 'ChannelRegistration requires proper :action key'
@@ -102,7 +98,7 @@ module Pubnub
102
98
  event_options: @given_options,
103
99
  timetoken: nil,
104
100
  status: {
105
- code: req_res_objects [:response].code,
101
+ code: req_res_objects[:response].code,
106
102
  operation: define_operation,
107
103
  client_request: req_res_objects[:request],
108
104
  server_response: req_res_objects[:response],
@@ -118,7 +114,6 @@ module Pubnub
118
114
 
119
115
  config: get_config
120
116
  },
121
-
122
117
  result: {
123
118
  data: parsed_response['payload'],
124
119
  code: req_res_objects[:response].code,
@@ -2,7 +2,7 @@
2
2
  module Pubnub
3
3
  # Holds delete functionality
4
4
  class DeleteMessages < SingleEvent
5
- include Celluloid
5
+ include Concurrent::Async
6
6
  include Pubnub::Validator::Delete
7
7
 
8
8
  def initialize(options, app)
@@ -21,21 +21,21 @@ module Pubnub
21
21
  {
22
22
  start: @start,
23
23
  end: @end
24
- }.select { |_, value| !value.blank? }.merge(super(signature))
24
+ }.reject { |_, value| value.blank? }.merge(super(signature))
25
25
  end
26
26
 
27
27
  def path
28
28
  '/' + [
29
- 'v3',
30
- 'history',
31
- 'sub-key',
32
- @subscribe_key,
33
- 'channel',
34
- @channel
29
+ 'v3',
30
+ 'history',
31
+ 'sub-key',
32
+ @subscribe_key,
33
+ 'channel',
34
+ @channel
35
35
  ].join('/')
36
36
  end
37
37
 
38
- def valid_envelope(parsed_response, req_res_objects)
38
+ def valid_envelope(_parsed_response, req_res_objects)
39
39
  Pubnub::Envelope.new(
40
40
  event: @event,
41
41
  event_options: @given_options,
@@ -2,7 +2,7 @@
2
2
  module Pubnub
3
3
  # Holds grant functionality
4
4
  class Grant < PAM
5
- include Celluloid
5
+ include Concurrent::Async
6
6
  include Pubnub::Validator::Grant
7
7
 
8
8
  def initialize(options, app)
@@ -18,8 +18,8 @@ module Pubnub
18
18
  end
19
19
 
20
20
  def parameters(signature = false)
21
- write = [0, '0', false].include?(@write) ? 0 : 1
22
- read = [0, '0', false].include?(@read) ? 0 : 1
21
+ write = [0, '0', false].include?(@write) ? 0 : 1
22
+ read = [0, '0', false].include?(@read) ? 0 : 1
23
23
  manage = [0, '0', false].include?(@manage) ? 0 : 1 # unless @group.blank?
24
24
 
25
25
  { timestamp: @timestamp,
@@ -2,7 +2,7 @@
2
2
  module Pubnub
3
3
  # Holds heartbeat functionality
4
4
  class Heartbeat < SingleEvent
5
- include Celluloid
5
+ include Concurrent::Async
6
6
  include Pubnub::Validator::Heartbeat
7
7
  include Pubnub::Formatter
8
8
 
@@ -32,13 +32,9 @@ module Pubnub
32
32
 
33
33
  def parameters(*_args)
34
34
  parameters = super
35
- if @app.env[:state] && @app.env[:state][@origin]
36
- parameters.merge!(state: encode_state(@app.env[:state][@origin]))
37
- end
38
- parameters.merge!(heartbeat: @heartbeat)
39
- parameters.merge!(
40
- 'channel-group' => @group.join(',')
41
- ) unless @group.blank?
35
+ parameters[:state] = encode_state(@app.env[:state][@origin]) if @app.env[:state] && @app.env[:state][@origin]
36
+ parameters[:heartbeat] = @heartbeat
37
+ parameters['channel-group'] = @group.join(',') unless @group.blank?
42
38
  parameters
43
39
  end
44
40
 
@@ -2,7 +2,7 @@
2
2
  module Pubnub
3
3
  # Holds here_now functionality
4
4
  class HereNow < SingleEvent
5
- include Celluloid
5
+ include Concurrent::Async
6
6
  include Pubnub::Validator::HereNow
7
7
 
8
8
  def initialize(options, app)
@@ -49,17 +49,14 @@ module Pubnub
49
49
 
50
50
  def parameters(*_args)
51
51
  parameters = super
52
- parameters.merge!(
53
- 'channel-group' => @group.join(',')
54
- ) unless @group.blank?
52
+ parameters['channel-group'] = @group.join(',') unless @group.blank?
55
53
  parameters
56
54
  end
57
55
 
58
56
  def valid_envelope(parsed_response, req_res_objects)
59
57
  Pubnub::Envelope.new(
60
- event: @event,
61
- event_options: @given_options,
62
-
58
+ event: @event,
59
+ event_options: @given_options,
63
60
  result: {
64
61
  code: req_res_objects[:response].code,
65
62
  operation: get_operation,
@@ -73,7 +70,6 @@ module Pubnub
73
70
  channels: (parsed_response['payload'] ? parsed_response['payload']['channels'] : nil)
74
71
  }
75
72
  },
76
-
77
73
  status: {
78
74
  code: req_res_objects[:response].code,
79
75
  client_request: req_res_objects[:request],