Class: Pubnub::AddMessageAction

Inherits:
SingleEvent show all
Includes:
Concurrent::Async, Validator::AddMessageAction
Defined in:
lib/pubnub/events/add_message_action.rb

Overview

Holds add message action functionality

Instance Attribute Summary

Attributes inherited from Event

#callback, #channel, #channel_group, #fresh_clone, #given_options, #group, #idle_timeout, #open_timeout, #origin, #presence_callback, #read_timeout, #ssl, #state, #wildcard_channel, #with_presence

Instance Method Summary collapse

Methods included from Validator::AddMessageAction

#validate!

Methods included from Validator::CommonValidator

#validate_origin, #validate_publish_key, #validate_subscribe_key, #validate_user_id

Methods inherited from Event

#finalized?, #send_request, #sync?, #uri

Methods included from Event::EFormatter

#format_channels, #format_envelopes, #format_group

Constructor Details

#initialize(options, app) ⇒ AddMessageAction

Returns a new instance of AddMessageAction.



8
9
10
11
12
# File 'lib/pubnub/events/add_message_action.rb', line 8

def initialize(options, app)
  @event = current_operation
  @telemetry_name = :l_msga
  super
end

Instance Method Details

#fireObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pubnub/events/add_message_action.rb', line 14

def fire
  Pubnub.logger.debug('Pubnub::Add Message Action') { "Fired event #{self.class}" }
  type_payload = { type: @type, value: @value }
  body = Formatter.format_message(type_payload, nil, false)

  response = send_request(body, { "Content-Type": 'application/json' })

  envelopes = fire_callbacks(handle(response, uri))
  finalize_event(envelopes)
  envelopes
end