Class: Pubnub::Event

Inherits:
Object show all
Defined in:
lib/pubnub/event.rb

Overview

Event module holds most basic and required infrastructure for every pubnub event, there are also SingleEvent module and SubscribeEvent module

Direct Known Subclasses

SingleEvent, SubscribeEvent

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Event) initialize(options, app)

Returns a new instance of Event



12
13
14
15
16
17
18
19
20
# File 'lib/pubnub/event.rb', line 12

def initialize(options, app)
  @app = app
  create_variables_from_options(app.env.merge(options))
  @origin = @app.current_origin
  format_channels
  format_group
  set_timestamp
  Pubnub.logger.debug('Pubnub::Event') { "Initialized #{self.class}" }
end

Instance Attribute Details

- (Object) callback (readonly)

Returns the value of attribute callback



6
7
8
# File 'lib/pubnub/event.rb', line 6

def callback
  @callback
end

- (Object) channel (readonly) Also known as: channels

Returns the value of attribute channel



6
7
8
# File 'lib/pubnub/event.rb', line 6

def channel
  @channel
end

- (Object) error_callback (readonly)

Returns the value of attribute error_callback



6
7
8
# File 'lib/pubnub/event.rb', line 6

def error_callback
  @error_callback
end

- (Object) group (readonly)

Returns the value of attribute group



6
7
8
# File 'lib/pubnub/event.rb', line 6

def group
  @group
end

- (Object) idle_timeout (readonly)

Returns the value of attribute idle_timeout



6
7
8
# File 'lib/pubnub/event.rb', line 6

def idle_timeout
  @idle_timeout
end

- (Object) open_timeout (readonly)

Returns the value of attribute open_timeout



6
7
8
# File 'lib/pubnub/event.rb', line 6

def open_timeout
  @open_timeout
end

- (Object) origin (readonly)

Returns the value of attribute origin



6
7
8
# File 'lib/pubnub/event.rb', line 6

def origin
  @origin
end

- (Object) presence_callback (readonly)

Returns the value of attribute presence_callback



6
7
8
# File 'lib/pubnub/event.rb', line 6

def presence_callback
  @presence_callback
end

- (Object) read_timeout (readonly)

Returns the value of attribute read_timeout



6
7
8
# File 'lib/pubnub/event.rb', line 6

def read_timeout
  @read_timeout
end

Instance Method Details

- (Boolean) finalized?

Returns:

  • (Boolean)


46
47
48
# File 'lib/pubnub/event.rb', line 46

def finalized?
  @finalized || @stop
end

- (Object) fire



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

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

  sender = request_dispatcher

  message = sender.send_request(Celluloid::Actor.current)

  envelopes = fire_callbacks(handle(message))
  finalize_event(envelopes)
  envelopes
ensure
  sender.terminate if @http_sync
  terminate unless @stay_alive
end

- (Boolean) sync?

Returns:

  • (Boolean)


50
51
52
# File 'lib/pubnub/event.rb', line 50

def sync?
  @http_sync ? true : false
end

- (Object) uri



37
38
39
40
41
42
43
44
# File 'lib/pubnub/event.rb', line 37

def uri
  uri = @ssl ? 'https://' : 'http://'
  uri += @origin
  uri += path
  uri += '?' + Formatter.params_hash_to_url_params(parameters)
  Pubnub.logger.debug('Pubnub::Event') { "Requested URI: #{uri}" }
  URI uri
end