Class: Pubnub::Publish

Inherits:
SingleEvent show all
Includes:
Celluloid, Validator::Publish
Defined in:
lib/pubnub/events/publish.rb

Overview

Holds publish functionality

Instance Attribute Summary collapse

Attributes inherited from Event

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

Instance Method Summary collapse

Methods included from Validator::Publish

#validate!

Methods included from Validator::CommonValidator

#validate_origin, #validate_publish_key, #validate_subscribe_key

Methods inherited from Event

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

Constructor Details

#initialize(options, app) ⇒ Publish

Returns a new instance of Publish.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pubnub/events/publish.rb', line 10

def initialize(options, app)
  @event = :publish
  super
  @sequence_number = nil
  @store = case @store
           when false
             0
           when true
             1
           end
end

Instance Attribute Details

#storeObject (readonly)

Returns the value of attribute store.



8
9
10
# File 'lib/pubnub/events/publish.rb', line 8

def store
  @store
end

Instance Method Details

#fireObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pubnub/events/publish.rb', line 22

def fire
  Pubnub.logger.debug('Pubnub::Publish') { "Fired event #{self.class}" }

  if @compressed
    compressed_body = Formatter.format_message(@message, @cipher_key, false)
    response = send_request(compressed_body)
  else
    response = send_request
  end

  envelopes = fire_callbacks(handle(response, uri))
  finalize_event(envelopes)
  envelopes
ensure
  # sender.terminate if @http_sync
  terminate unless @stay_alive
end