Class: PrivatePub::FayeExtension

Inherits:
Object
  • Object
show all
Defined in:
lib/private_pub/faye_extension.rb

Overview

This class is an extension for the Faye::RackAdapter. It is used inside of PrivatePub.faye_app.

Instance Method Summary collapse

Instance Method Details

#incoming(message, callback) ⇒ Object

Callback to handle incoming Faye messages. This authenticates both subscribe and publish calls.



7
8
9
10
11
12
13
14
# File 'lib/private_pub/faye_extension.rb', line 7

def incoming(message, callback)
  if message["channel"] == "/meta/subscribe"
    authenticate_subscribe(message)
  elsif message["channel"] !~ %r{^/meta/}
    authenticate_publish(message)
  end
  callback.call(message)
end