aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2010-10-06 03:03:10 +0100
committerMelanie2010-10-06 03:03:10 +0100
commit17316170a5fb1396d7ed82f6d9c5f0976385cf31 (patch)
treeb270e7f35f2c0a55c94ad5f96616696a3672b42a /OpenSim
parentFix incorrect class name (diff)
downloadopensim-SC_OLD-17316170a5fb1396d7ed82f6d9c5f0976385cf31.zip
opensim-SC_OLD-17316170a5fb1396d7ed82f6d9c5f0976385cf31.tar.gz
opensim-SC_OLD-17316170a5fb1396d7ed82f6d9c5f0976385cf31.tar.bz2
opensim-SC_OLD-17316170a5fb1396d7ed82f6d9c5f0976385cf31.tar.xz
Add WOrldView request handler and plumbing
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs28
-rw-r--r--OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs127
2 files changed, 155 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs
index d89d274..098b741 100644
--- a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs
+++ b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs
@@ -36,6 +36,9 @@ using OpenMetaverse.Imaging;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Server.Base;
40using OpenSim.Framework.Servers.HttpServer;
41using OpenSim.Services.Interfaces;
39 42
40namespace OpenSim.Region.OptionalModules.World.WorldView 43namespace OpenSim.Region.OptionalModules.World.WorldView
41{ 44{
@@ -46,9 +49,18 @@ namespace OpenSim.Region.OptionalModules.World.WorldView
46 49
47 50
48 private bool m_Enabled = false; 51 private bool m_Enabled = false;
52 private IMapImageGenerator m_Generator;
49 53
50 public void Initialise(IConfigSource config) 54 public void Initialise(IConfigSource config)
51 { 55 {
56 IConfig moduleConfig = config.Configs["Modules"];
57 if (moduleConfig == null)
58 return;
59
60 if (moduleConfig.GetString("WorldViewModule", String.Empty) != Name)
61 return;
62
63 m_Enabled = true;
52 } 64 }
53 65
54 public void AddRegion(Scene scene) 66 public void AddRegion(Scene scene)
@@ -57,6 +69,17 @@ namespace OpenSim.Region.OptionalModules.World.WorldView
57 69
58 public void RegionLoaded(Scene scene) 70 public void RegionLoaded(Scene scene)
59 { 71 {
72 m_Generator = scene.RequestModuleInterface<IMapImageGenerator>();
73 if (m_Generator == null)
74 {
75 m_Enabled = false;
76 return;
77 }
78
79 m_log.Info("[WORLDVIEW]: Configured and enabled");
80
81 IHttpServer server = MainServer.GetHttpServer(0);
82 server.AddStreamHandler(new WorldViewRequestHandler(this));
60 } 83 }
61 84
62 public void RemoveRegion(Scene scene) 85 public void RemoveRegion(Scene scene)
@@ -76,5 +99,10 @@ namespace OpenSim.Region.OptionalModules.World.WorldView
76 public void Close() 99 public void Close()
77 { 100 {
78 } 101 }
102
103 public byte[] GenerateWorldView(Vector3 pos, Vector3 rot)
104 {
105 return new Byte[0];
106 }
79 } 107 }
80} 108}
diff --git a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs
new file mode 100644
index 0000000..a9cf1f1
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs
@@ -0,0 +1,127 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Xml;
33
34using OpenSim.Framework;
35using OpenSim.Server.Base;
36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Region.Framework.Interfaces;
39
40using OpenMetaverse;
41using log4net;
42
43namespace OpenSim.Region.OptionalModules.World.WorldView
44{
45 public class WorldViewRequestHandler : BaseStreamHandler
46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48
49 protected WorldViewModule m_WorldViewModule;
50 protected Object m_RequestLock = new Object();
51
52 public WorldViewRequestHandler(WorldViewModule fmodule)
53 : base("POST", "/worldview")
54 {
55 m_WorldViewModule = fmodule;
56 }
57
58 public override byte[] Handle(string path, Stream requestData,
59 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
60 {
61 StreamReader sr = new StreamReader(requestData);
62 string body = sr.ReadToEnd();
63 sr.Close();
64 body = body.Trim();
65
66 try
67 {
68 lock (m_RequestLock)
69 {
70 Dictionary<string, object> request =
71 ServerUtils.ParseQueryString(body);
72
73 return SendWorldView(request);
74 }
75 }
76 catch (Exception e)
77 {
78 m_log.Debug("[WORLDVIEW]: Exception {0}" + e.ToString());
79 }
80
81 return new Byte[0];
82 }
83
84 public Byte[] SendWorldView(Dictionary<string, object> request)
85 {
86 float posX;
87 float posY;
88 float posZ;
89 float rotX;
90 float rotY;
91 float rotZ;
92
93 if (!request.ContainsKey("posX"))
94 return new Byte[0];
95 if (!request.ContainsKey("posY"))
96 return new Byte[0];
97 if (!request.ContainsKey("posZ"))
98 return new Byte[0];
99 if (!request.ContainsKey("rotX"))
100 return new Byte[0];
101 if (!request.ContainsKey("rotY"))
102 return new Byte[0];
103 if (!request.ContainsKey("rotZ"))
104 return new Byte[0];
105
106 try
107 {
108 posX = Convert.ToSingle(request["posX"]);
109 posY = Convert.ToSingle(request["posY"]);
110 posZ = Convert.ToSingle(request["posZ"]);
111 rotX = Convert.ToSingle(request["rotX"]);
112 rotY = Convert.ToSingle(request["rotY"]);
113 rotZ = Convert.ToSingle(request["rotZ"]);
114 }
115 catch
116 {
117 return new Byte[0];
118 }
119
120 Vector3 pos = new Vector3(posX, posY, posZ);
121 Vector3 rot = new Vector3(rotX, rotY, rotZ);
122
123 return m_WorldViewModule.GenerateWorldView(pos, rot);
124 }
125 }
126}
127