Class: FayeTracking::FayeExtension
- Inherits:
-
Object
- Object
- FayeTracking::FayeExtension
- Defined in:
- lib/faye_tracking/faye_extension.rb
Constant Summary collapse
- MONITORED_CHANNELS =
[ '/meta/subscribe', '/meta/unsubscribe', '/meta/disconnect' ]
Instance Method Summary collapse
- #incoming(message, callback) ⇒ Object
-
#initialize(tracker) ⇒ FayeExtension
constructor
A new instance of FayeExtension.
Constructor Details
#initialize(tracker) ⇒ FayeExtension
Returns a new instance of FayeExtension.
9 10 11 |
# File 'lib/faye_tracking/faye_extension.rb', line 9 def initialize(tracker) @tracker = tracker end |
Instance Method Details
#incoming(message, callback) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/faye_tracking/faye_extension.rb', line 13 def incoming(, callback) return callback.call() \ unless MONITORED_CHANNELS.include? ['channel'] FayeTracking.logger.debug "received incoming message: #{}" unless ['error'] subs_channel = ['subscription'] client_id = ['clientId'] run_subscribe_callbacks = false case ['channel'] when '/meta/subscribe' ext = ['ext'] if app_client_id = ext['faye_tracking_client_id'] @tracker.add(subs_channel, client_id, app_client_id) run_subscribe_callbacks = true else = "missing ext['faye_tracking_client_id']" FayeTracking.logger.error "error with message: #{}" ['error'] = end when '/meta/unsubscribe' # This is not reliable, more robust way to detect unsubscribe event. # see: http://faye.jcoglan.com/ruby/monitoring.html end end callback.call() if run_subscribe_callbacks FayeTracking.run_on_subscribe_callbacks( client_id, app_client_id, subs_channel ) end end |