Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: bd2bce43da
Fetching contributors…

Cannot retrieve contributors at this time

file 47 lines (39 sloc) 1.823 kb
1 2 3 4 5 6 7 8 9 10 11 12 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
class RubyamfController < ActionController::Base

  def gateway
    RubyAMF::App::RequestStore.rails_authentication = nil #clear auth hash
    RubyAMF::App::RequestStore.rails_request = request
    RubyAMF::App::RequestStore.rails_response = response
          
    #Compress the amf output for smaller data transfer over the wire
    RubyAMF::App::RequestStore.gzip = request.env['ACCEPT_ENCODING'].to_s.match(/gzip,[\s]{0,1}deflate/)
    
    #if not flash user agent, send some html content
    amf_response = if request.env['CONTENT_TYPE'].to_s.match(/x-amf/)
      headers['Content-Type'] = "application/x-amf"
      RubyAMF::App::RailsGateway.new.service(request.raw_post) #send the raw data throught the rubyamf gateway and create the response
    else
      welcome_screen_html # load in some stub html
    end
      
    #render the AMF
    send_data(amf_response, :type => 'application/x-amf')
  rescue Exception => e #only errors in this scope will ever be rescued here, see BatchFiler
    STDOUT.puts e.to_s
    STDOUT.puts e.backtrace
  end
  
  
  def rescue_action(e)
    #There are a couple things that will trigger this rescue_action. Which aren't
    #ever returned to the flash player. be ware. but I will put a fix for this in.
    puts "/rubyamf/gateway/render_action"
    puts e.message
    puts e.backtrace
  end
  
  private
  def welcome_screen_html
    "<html>
<head>
<title>RubyAMF Gateway</title>
<style>body{margin:0;padding:0;font:12px sans-serif;color:#c8c8c8}td{font:12px sans-serif}</style>
</head>
<body bgcolor='#222222'>
<table width='100%' align=center valign=middle height='100%'><tr><td width=100 align=center>
<a href='http://blog.rubyamf.org'><img border=0 src='http://blog.rubyamf.org/images/gateway.png' /></a>"
  end
  
end
Something went wrong with that request. Please try again.