class FlashPolicyServer

Public Instance Methods

run!() click to toggle source

Loads up a policy file from pwd and starts the server.

# File lib/flash_policy_server.rb, line 7
def run!
  puts "Starting policy server..."
  load_policy_file
  start_server
end

Private Instance Methods

load_policy_file() click to toggle source
# File lib/flash_policy_server.rb, line 15
def load_policy_file
  @@policy = File.open("crossdomain.xml", "rb").read
end
start_server() click to toggle source
# File lib/flash_policy_server.rb, line 19
def start_server
  server = TCPServer.open(843)
  loop do
    Thread.start(server.accept) do |client|
      begin
        client.puts %Q(#{@@policy})
        client.close
      rescue Exception => e
        puts e.message
        client.close
      end
    end
  end
end