aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/share
diff options
context:
space:
mode:
authorAdam Frisby2007-11-06 21:41:11 +0000
committerAdam Frisby2007-11-06 21:41:11 +0000
commitc0010e4940dd0ca067d469d8194be69b2bc1dece (patch)
tree3dd9a39e2b9db0d6e97e15c8b3bb7d595f2da612 /share
parentset svn:eol-style (diff)
downloadopensim-SC-c0010e4940dd0ca067d469d8194be69b2bc1dece.zip
opensim-SC-c0010e4940dd0ca067d469d8194be69b2bc1dece.tar.gz
opensim-SC-c0010e4940dd0ca067d469d8194be69b2bc1dece.tar.bz2
opensim-SC-c0010e4940dd0ca067d469d8194be69b2bc1dece.tar.xz
* Moved /branches/ruby to /trunk/share/ruby
Diffstat (limited to 'share')
-rw-r--r--share/ruby/README14
-rw-r--r--share/ruby/aserv.rb35
-rw-r--r--share/ruby/config.rb38
-rw-r--r--share/ruby/gridserv.rb69
-rw-r--r--share/ruby/userserv.rb135
5 files changed, 291 insertions, 0 deletions
diff --git a/share/ruby/README b/share/ruby/README
new file mode 100644
index 0000000..f4a342d
--- /dev/null
+++ b/share/ruby/README
@@ -0,0 +1,14 @@
1This is a minimal and dummy gridservers implementation, just to get
2the OpenSim.exe booted into the grid mode.
3
4NOT INDENDED FOR PRODUCTION USE - DEVELOPERS ONLY
5
6provided AS IS, no any warranties whatsoever, use at your own risk.
7
8License: BSD
9
10/Dalien Talbot @ SecondLife
11
12http://daltonic.blogspot.com/search/label/opensim
13
14
diff --git a/share/ruby/aserv.rb b/share/ruby/aserv.rb
new file mode 100644
index 0000000..1ac3d60
--- /dev/null
+++ b/share/ruby/aserv.rb
@@ -0,0 +1,35 @@
1require "webrick"
2
3#
4# Dummy asset server
5#
6
7class AssetServlet < WEBrick::HTTPServlet::AbstractServlet
8 def do_GET(req, res)
9 uuid = req.path.split("/")[2].downcase.gsub(/[^0-9a-f]+/, "")
10 if uuid.length == 32
11 # length is correct
12 File.open("assets/#{uuid}/data") do |f|
13 res.body = f.read
14 end
15 end
16 # res["content-type"] = "text/plain" # or what do we set it to ?
17 end
18 def do_POST(req, res)
19 uuid = req.path.split("/")[2].downcase.gsub(/[^0-9a-f]+/, "")
20 if uuid.length == 32
21 Dir.mkdir("assets/#{uuid}")
22 File.open("assets/#{uuid}/data", "wb") do |f|
23 f.write req.body
24 STDERR.print "Written #{req.body.length} bytes for uuid #{uuid}\n\n"
25 end
26 end
27 end
28end
29
30
31svr = WEBrick::HTTPServer.new(:Port=>8003)
32svr.mount("/assets", AssetServlet, 5000000)
33trap(:INT){ svr.shutdown }
34svr.start
35
diff --git a/share/ruby/config.rb b/share/ruby/config.rb
new file mode 100644
index 0000000..8484274
--- /dev/null
+++ b/share/ruby/config.rb
@@ -0,0 +1,38 @@
1# Various config data
2
3class SimConfig
4 attr_reader :cfgSimName, :cfgSimIP, :cfgSimPort, :cfgSimX,
5 :cfgSimX, :cfgSimY, :cfgAssetServerUrl, :cfgUserServerUrl
6
7 def initialize
8 @cfgSimName = "DalienLand"
9 @cfgSimIP = "192.168.1.103"
10 @cfgSimPort = "9000"
11 @cfgSimX = 997
12 @cfgSimY = 996
13 @cfgSimX = 1000
14 @cfgSimY = 1000
15 @cfgAssetServerUrl = "http://192.168.1.103:8003/"
16 @cfgUserServerUrl = "http://192.168.1.103:8003/"
17 end
18
19end
20
21
22class UUID
23 def initialize
24 @uuid = rand(1<<128)
25 end
26 def to_dashed_s
27 part1 = @uuid & 0xFFFFFFFFFFFF
28 part2 = (@uuid >> 48) && 0xFFFF
29 part3 = (@uuid >> (48 + 16)) & 0xFFFF
30 part4 = (@uuid >> (48 + 32)) & 0xFFFF
31 part5 = @uuid >> (128-32)
32 return sprintf "%08x-%04x-%04x-%04x-%012x", part5, part4, part3, part2, part1
33 end
34end
35
36print UUID.new.to_dashed_s
37
38
diff --git a/share/ruby/gridserv.rb b/share/ruby/gridserv.rb
new file mode 100644
index 0000000..03cb4d1
--- /dev/null
+++ b/share/ruby/gridserv.rb
@@ -0,0 +1,69 @@
1require "webrick"
2require "xmlrpc/server"
3require 'xmlrpc/client'
4require 'pp'
5require 'config.rb'
6
7#
8# Dummy grid server
9#
10#
11
12class SimServlet < WEBrick::HTTPServlet::AbstractServlet
13 # does actually nothing
14 def do_POST(req, res)
15 STDERR.print "----\n"
16 end
17end
18
19$SimUUID = ""
20
21s = XMLRPC::WEBrickServlet.new
22s.add_handler("map_block") do |param|
23 # does just enough to login.. if you try using "map" you will cause the exception
24 # and hang the client
25 responseData = Hash.new
26 responseData["sim-profiles"] = [ ]
27 responseData
28end
29
30s.add_handler("simulator_login") do |param|
31 sc = SimConfig.new
32 responseData = Hash.new
33 STDERR.print "simulator login: " + param.inspect + "\n"
34 $SimUUID = param["UUID"]
35
36 responseData["UUID"] = param["UUID"]
37 responseData["region_locx"] = sc.cfgSimX
38 responseData["region_locy"] = sc.cfgSimY
39 responseData["regionname"] = "DalienLand"
40 responseData["estate_id"] = "1"
41 responseData["neighbours"] = [ ]
42 responseData["sim_ip"] = sc.cfgSimIP
43 responseData["sim_port"] = sc.cfgSimPort
44 responseData["asset_url"] = sc.cfgAssetServerUrl
45 responseData["asset_sendkey"] = ""
46 responseData["asset_recvkey"] = ""
47 responseData["user_url"] = sc.cfgUserServerUrl
48 responseData["user_sendkey"] = ""
49 responseData["user_recvkey"] = ""
50 responseData["authkey"] = ""
51
52 responseData
53
54end
55
56s.set_default_handler do |name, *args|
57 STDERR.print "Unknown method #{name}, #{args.inspect}\n\n"
58 raise XMLRPC::FaultException.new(-99, "Method #{name} missing" +
59 " or wrong number of parameters!")
60end
61
62httpserver = WEBrick::HTTPServer.new(:Port => 8001)
63httpserver.mount("/", s)
64httpserver.mount("/sims", SimServlet)
65
66trap(:INT) { httpserver.shutdown } # use 1 instead of "HUP" on Windows
67httpserver.start
68
69
diff --git a/share/ruby/userserv.rb b/share/ruby/userserv.rb
new file mode 100644
index 0000000..18559c0
--- /dev/null
+++ b/share/ruby/userserv.rb
@@ -0,0 +1,135 @@
1require "webrick"
2require "xmlrpc/server"
3require 'xmlrpc/client'
4require 'config.rb'
5
6class SessionServlet < WEBrick::HTTPServlet::AbstractServlet
7 def do_DELETE(req, res)
8 # does nothing, obviously
9 STDERR.print "----\n"
10 end
11end
12
13s = XMLRPC::WEBrickServlet.new
14s.add_handler("login_to_simulator") do |param|
15 sc = SimConfig.new
16 #
17 # Some stuff just grabbed from a sniff of the session with OGS
18 #
19 zSessionId = "133086b6-1270-78c6-66f7-c7f64865b16c"
20 zSecureSessionId = "6ee4df6a-0ea9-4cf5-8ac7-9745acbacccc"
21 zAgentId = "0f00ba47-42d1-498e-b010-aa585a81862e"
22 zAgentId = UUID.new.to_dashed_s
23 STDERR.print "AgentID: #{zAgentId}\n"
24 zCircuitCode = rand(0x1000000)
25 zRegionX = sc.cfgSimX
26 zRegionY = sc.cfgSimY
27
28 xxSimParams = Hash.new
29 xxSimParams["session_id"] = zSessionId.gsub("-","")
30 xxSimParams["secure_session_id"] = zSecureSessionId.gsub("-","")
31 xxSimParams["firstname"] = param["first"];
32 xxSimParams["lastname"] = param["last"];
33 xxSimParams["agent_id"] = zAgentId.gsub("-", "")
34 xxSimParams["circuit_code"] = zCircuitCode
35 xxSimParams["startpos_x"] = 128
36 xxSimParams["startpos_y"] = 128
37 xxSimParams["startpos_z"] = 30
38 xxSimParams["regionhandle"] = ((zRegionX << 40) + (zRegionY *256)).to_s
39 STDERR.print "Region handle: #{xxSimParams["regionhandle"]}\n"
40
41
42
43 server = XMLRPC::Client.new2("http://#{sc.cfgSimIP}:#{sc.cfgSimPort}/")
44 # the dispatcher in OpenSim.exe did not get excited from specifying
45 # the content-type in the request.. no XML was executed at all.
46 # this "fixes" it.
47 server.http_header_extra = { "Content-Type" => "text/xml" };
48 result = server.call("expect_user", xxSimParams )
49 # STDERR.print result.inspect
50
51 STDERR.print "---- notified the sim ----\n"
52
53 responseData = Hash.new
54
55 xxGlobalT = Hash.new
56 xxGlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271";
57 xxGlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
58 xxGlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
59
60 xxLoginFlags = Hash.new
61 xxLoginFlags["daylight_savings"] = "N"
62 xxLoginFlags["stipend_since_login"] = "N"
63 xxLoginFlags["gendered"] = "Y"
64 xxLoginFlags["ever_logged_in"] = "Y"
65
66 responseData["first_name"] = param["first"]
67 responseData["last_name"] = param["last"]
68 responseData["ui-config"] = [ { "allow_first_life" => "Y" } ]
69
70 responseData["login-flags"] = [ xxLoginFlags ]
71 responseData["global-textures"] = [ xxGlobalT ]
72 # responseData["classified_categories"] = [ { category_name => "Generic", category_id => 1 } ]
73 # responseData["event_categories"] =
74 responseData["inventory-skeleton"] = [
75 { "folder_id" => "9846e02a-f41b-4199-860e-cde46cc25649",
76 "parent_id" => "00000000-0000-0000-0000-000000000000",
77 "name" => "My Inventory test",
78 "type_default" => 8,
79 "version" => 1 },
80 { "folder_id" => "b846e02a-f41b-4199-860e-cde46cc25649",
81 "parent_id" => "9846e02a-f41b-4199-860e-cde46cc25649",
82 "name" => "test",
83 "type_default" => 0,
84 "version" => 1 }
85 ]
86 responseData["inventory-skel-lib"] = [
87 { "folder_id" => "a846e02a-f41b-4199-860e-cde46cc25649",
88 "parent_id" => "00000000-0000-0000-0000-000000000000",
89 "name" => "Lib Inventory",
90 "type_default" => 8,
91 "version" => 1 }
92 ]
93 responseData["inventory-root"] = [ { "folder_id" => "9846e02a-f41b-4199-860e-cde46cc25649" } ]
94 # responseData["event_notifications"] = [ ]
95 responseData["gestures"] = [ ]
96 # responseData["inventory-lib-owner"] =
97 responseData["initial-outfit"] = [
98 { "folder_name" => "Nightclub female", "gender" => "female" }
99 ]
100 responseData["seconds_since_epoch"] = Time.new.to_i
101 responseData["start_location"] = "last";
102 responseData["message"] = "Hello there!"
103 responseData["circuit_code"] = zCircuitCode # random
104 # responseData["look_at"] =
105 responseData["agent_id"] = zAgentId
106 responseData["home"] = "\{'region_handle':[r#{zRegionX*256}.0,r#{zRegionY*256}.0], 'position':[r128.0,r128.0,r30.0], 'look_at':[r0.0,r0.0,r0.0]\}"
107 # responseData["home"] = "\{'region_handle':[r255232,r254976], 'position':[r128,r128,r100], 'look_at':[r128,r128,r100]\}"
108
109 responseData["region_x"] = zRegionX*256
110 responseData["region_y"] = zRegionY*256
111 responseData["sim_ip"] = "192.168.1.103"
112 responseData["sim_port"] = 9000
113 # responseData["seed_capability"]
114 responseData["agent_access"] = "M";
115 responseData["session_id"] = zSessionId
116 responseData["secure_session_id"] = zSecureSessionId
117 responseData["login"] = "true"
118
119 # raise XMLRPC::FaultException.new(1, "just some exception")
120 responseData
121end
122
123s.set_default_handler do |name, *args|
124 STDERR.print "Unknown method #{name}, #{args.inspect}\n\n"
125 raise XMLRPC::FaultException.new(-99, "Method #{name} missing" +
126 " or wrong number of parameters!")
127end
128
129httpserver = WEBrick::HTTPServer.new(:Port => 8002)
130httpserver.mount("/", s)
131httpserver.mount("/usersessions", SessionServlet);
132
133trap(:INT) { httpserver.shutdown }
134httpserver.start
135