gridserv.rb 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. require "webrick"
  2. require "xmlrpc/server"
  3. require 'xmlrpc/client'
  4. require 'pp'
  5. require 'config.rb'
  6. #
  7. # Dummy grid server
  8. #
  9. #
  10. class SimServlet < WEBrick::HTTPServlet::AbstractServlet
  11. # does actually nothing
  12. def do_POST(req, res)
  13. STDERR.print "----\n"
  14. end
  15. end
  16. $SimUUID = ""
  17. s = XMLRPC::WEBrickServlet.new
  18. s.add_handler("map_block") do |param|
  19. # does just enough to login.. if you try using "map" you will cause the exception
  20. # and hang the client
  21. responseData = Hash.new
  22. responseData["sim-profiles"] = [ ]
  23. responseData
  24. end
  25. s.add_handler("simulator_login") do |param|
  26. sc = SimConfig.new
  27. responseData = Hash.new
  28. STDERR.print "simulator login: " + param.inspect + "\n"
  29. $SimUUID = param["UUID"]
  30. responseData["UUID"] = param["UUID"]
  31. responseData["region_locx"] = sc.cfgSimX
  32. responseData["region_locy"] = sc.cfgSimY
  33. responseData["regionname"] = "DalienLand"
  34. responseData["estate_id"] = "1"
  35. responseData["neighbours"] = [ ]
  36. responseData["sim_ip"] = sc.cfgSimIP
  37. responseData["sim_port"] = sc.cfgSimPort
  38. responseData["asset_url"] = sc.cfgAssetServerUrl
  39. responseData["asset_sendkey"] = ""
  40. responseData["asset_recvkey"] = ""
  41. responseData["user_url"] = sc.cfgUserServerUrl
  42. responseData["user_sendkey"] = ""
  43. responseData["user_recvkey"] = ""
  44. responseData["authkey"] = ""
  45. responseData
  46. end
  47. s.set_default_handler do |name, *args|
  48. STDERR.print "Unknown method #{name}, #{args.inspect}\n\n"
  49. raise XMLRPC::FaultException.new(-99, "Method #{name} missing" +
  50. " or wrong number of parameters!")
  51. end
  52. httpserver = WEBrick::HTTPServer.new(:Port => 8001)
  53. httpserver.mount("/", s)
  54. httpserver.mount("/sims", SimServlet)
  55. trap(:INT) { httpserver.shutdown } # use 1 instead of "HUP" on Windows
  56. httpserver.start