Class: Pubnub::SubscribeEvent
- Defined in:
- lib/pubnub/subscribe_event.rb,
lib/pubnub/subscribe_event/adding.rb,
lib/pubnub/subscribe_event/removing.rb,
lib/pubnub/subscribe_event/callbacks.rb,
lib/pubnub/subscribe_event/formatter.rb,
lib/pubnub/subscribe_event/heartbeat.rb
Overview
SubscribeEvent module holds infrastructure for subscribe events.
Defined Under Namespace
Modules: Adding, Callbacks, Formatter, Heartbeat, Removing
Instance Attribute Summary collapse
-
#c_cb_pool ⇒ Object
readonly
Returns the value of attribute c_cb_pool.
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#g_cb_pool ⇒ Object
readonly
Returns the value of attribute g_cb_pool.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#heart ⇒ Object
readonly
Returns the value of attribute heart.
-
#wc_cb_pool ⇒ Object
readonly
Returns the value of attribute wc_cb_pool.
-
#wildcard_channel ⇒ Object
readonly
Returns the value of attribute wildcard_channel.
Attributes inherited from Event
#callback, #fresh_clone, #given_options, #idle_timeout, #open_timeout, #origin, #presence_callback, #read_timeout, #ssl, #state
Instance Method Summary collapse
- #build(options) ⇒ Object
- #fire ⇒ Object
-
#initialize(options, app) ⇒ SubscribeEvent
constructor
A new instance of SubscribeEvent.
- #leave_all ⇒ Object
Methods included from Formatter
channels_for_url, classify_method, encode, format_channel, format_group, format_message, format_presence_channel, make_channel_array, params_hash_to_url_params, parse_json
Methods included from Removing
#remove, #remove_channels, #remove_groups
Methods included from Adding
#add, #add_channels, #add_groups
Methods inherited from Event
Constructor Details
#initialize(options, app) ⇒ SubscribeEvent
Returns a new instance of SubscribeEvent.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/pubnub/subscribe_event.rb', line 12 def initialize(, app) super @heartbeat = @app.env[:heartbeat] setup_cb_pools @wildcard_channel = @channel.select { |e| e.index('.*') } || [] @channel -= @wildcard_channel add_channel_cb_to_cb_pools add_group_cb_to_cb_pools add_wc_channel_cb_to_cb_pools end |
Instance Attribute Details
#c_cb_pool ⇒ Object (readonly)
Returns the value of attribute c_cb_pool.
10 11 12 |
# File 'lib/pubnub/subscribe_event.rb', line 10 def c_cb_pool @c_cb_pool end |
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
10 11 12 |
# File 'lib/pubnub/subscribe_event.rb', line 10 def channel @channel end |
#g_cb_pool ⇒ Object (readonly)
Returns the value of attribute g_cb_pool.
10 11 12 |
# File 'lib/pubnub/subscribe_event.rb', line 10 def g_cb_pool @g_cb_pool end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
10 11 12 |
# File 'lib/pubnub/subscribe_event.rb', line 10 def group @group end |
#heart ⇒ Object (readonly)
Returns the value of attribute heart.
10 11 12 |
# File 'lib/pubnub/subscribe_event.rb', line 10 def heart @heart end |
#wc_cb_pool ⇒ Object (readonly)
Returns the value of attribute wc_cb_pool.
10 11 12 |
# File 'lib/pubnub/subscribe_event.rb', line 10 def wc_cb_pool @wc_cb_pool end |
#wildcard_channel ⇒ Object (readonly)
Returns the value of attribute wildcard_channel.
10 11 12 |
# File 'lib/pubnub/subscribe_event.rb', line 10 def wildcard_channel @wildcard_channel end |
Instance Method Details
#build(options) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/pubnub/subscribe_event.rb', line 53 def build() @c_cb_pool = [:callbacks][:channels] @g_cb_pool = [:callbacks][:groups] @wc_cb_pool = [:callbacks][:wildcard_channels] @channel = [:channels] @group = [:groups] @wildcard_channel = [:wildcard_channels] end |
#fire ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/pubnub/subscribe_event.rb', line 25 def fire return false if @finalized Pubnub.logger.debug('Pubnub') { "Fired event #{self.class}" } consider_heartbeat response = send_request return false if @app.subscriber.current_subscription_id != object_id && @http_sync != true Pubnub.logger.debug('Pubnub') { 'Fire before fire_callback' } envelopes = finalize_event(fire_callbacks(handle(response, uri))) async.fire unless @http_sync envelopes end |