abstract out faye
This commit is contained in:
@@ -9,12 +9,12 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
def broadcast_user(uid, event, data = {})
|
||||
message = {channel: "/user/#{uid}", data: {event: event, data: data}}
|
||||
uri = URI.parse("http://localhost:9292/faye")
|
||||
uri = URI.parse(event_host)
|
||||
Net::HTTP.post_form(uri, :message => message.to_json)
|
||||
end
|
||||
def broadcast_supplier(sid, event, data = {})
|
||||
message = {channel: "/supplier/#{sid}", data: {event: event, data: data}}
|
||||
uri = URI.parse("http://localhost:9292/faye")
|
||||
uri = URI.parse(event_host)
|
||||
Net::HTTP.post_form(uri, :message => message.to_json)
|
||||
end
|
||||
def set_locale
|
||||
@@ -23,14 +23,10 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
def layout_by_resource
|
||||
if devise_controller?
|
||||
case session[:user_return_to]
|
||||
when /\/user\// then 'obtain_token'
|
||||
when /obtain_token/ then 'obtain_token'
|
||||
else 'theme1'
|
||||
end
|
||||
else
|
||||
"application"
|
||||
return 'obtain_token' if session[:user_return_to].present?
|
||||
return 'theme1' if session[:supplier_return_to].present?
|
||||
end
|
||||
"theme1"
|
||||
end
|
||||
def check_active_list_state
|
||||
if current_user.try(:active_list_id)
|
||||
@@ -60,4 +56,10 @@ class ApplicationController < ActionController::Base
|
||||
{ok: true, message: message}.merge(options).to_json
|
||||
end
|
||||
|
||||
# Return the hostname of the event server
|
||||
def event_host
|
||||
#TODO: do not do and environment check, its ugly!
|
||||
"http://#{Rails.env.production? ? 'events.qwaiter.com' : 'localhost'}:9296/faye"
|
||||
end
|
||||
helper_method :event_host
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user