aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-10-14 18:37:22 +0100
committerJustin Clark-Casey (justincc)2014-11-25 23:21:38 +0000
commit16a5e154436fc56235ac03846d4bb1ba4d21ac87 (patch)
tree19ed04e82bfa813519e7d55f70e575bfd5e4f585 /OpenSim
parentStart JobEngine by default in simulator for now. (diff)
downloadopensim-SC-16a5e154436fc56235ac03846d4bb1ba4d21ac87.zip
opensim-SC-16a5e154436fc56235ac03846d4bb1ba4d21ac87.tar.gz
opensim-SC-16a5e154436fc56235ac03846d4bb1ba4d21ac87.tar.bz2
opensim-SC-16a5e154436fc56235ac03846d4bb1ba4d21ac87.tar.xz
Allow GetMesh capability to be served directly by a server like GetTexture
To do this required GetMesh to be converted to a BaseStreamHandler Unlike GetTexture connector, no redirect URL functionality yet (this wasn't present in the first place).
Diffstat (limited to '')
-rw-r--r--OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs60
-rw-r--r--OpenSim/Capabilities/Handlers/GetMesh/GetMeshServerConnector.cs11
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs33
3 files changed, 46 insertions, 58 deletions
diff --git a/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs b/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs
index 720640e..9fe00e0 100644
--- a/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs
@@ -30,6 +30,7 @@ using System.Collections;
30using System.Collections.Specialized; 30using System.Collections.Specialized;
31using System.Reflection; 31using System.Reflection;
32using System.IO; 32using System.IO;
33using System.Text;
33using System.Web; 34using System.Web;
34using log4net; 35using log4net;
35using Nini.Config; 36using Nini.Config;
@@ -43,41 +44,37 @@ using Caps = OpenSim.Framework.Capabilities.Caps;
43 44
44namespace OpenSim.Capabilities.Handlers 45namespace OpenSim.Capabilities.Handlers
45{ 46{
46 public class GetMeshHandler 47 public class GetMeshHandler : BaseStreamHandler
47 { 48 {
48// private static readonly ILog m_log = 49// private static readonly ILog m_log =
49// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 51
51 private IAssetService m_assetService; 52 private IAssetService m_assetService;
52 53
53 public GetMeshHandler(IAssetService assService) 54 public GetMeshHandler(string path, IAssetService assService, string name, string description)
55 : base("GET", path, name, description)
54 { 56 {
55 m_assetService = assService; 57 m_assetService = assService;
56 } 58 }
57 59
58 public Hashtable ProcessGetMesh(Hashtable request, UUID AgentId, Caps cap) 60 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
59 { 61 {
60 Hashtable responsedata = new Hashtable(); 62 // Try to parse the texture ID from the request URL
61 responsedata["int_response_code"] = 400; //501; //410; //404; 63 NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
62 responsedata["content_type"] = "text/plain"; 64 string meshStr = query.GetOne("mesh_id");
63 responsedata["keepalive"] = false;
64 responsedata["str_response_string"] = "Request wasn't what was expected";
65 65
66 string meshStr = string.Empty; 66// m_log.DebugFormat("Fetching mesh {0}", meshStr);
67
68 if (request.ContainsKey("mesh_id"))
69 meshStr = request["mesh_id"].ToString();
70 67
71 UUID meshID = UUID.Zero; 68 UUID meshID = UUID.Zero;
72 if (!String.IsNullOrEmpty(meshStr) && UUID.TryParse(meshStr, out meshID)) 69 if (!String.IsNullOrEmpty(meshStr) && UUID.TryParse(meshStr, out meshID))
73 { 70 {
74 if (m_assetService == null) 71 if (m_assetService == null)
75 { 72 {
76 responsedata["int_response_code"] = 404; //501; //410; //404; 73 httpResponse.StatusCode = 404;
77 responsedata["content_type"] = "text/plain"; 74 httpResponse.ContentType = "text/plain";
78 responsedata["keepalive"] = false; 75 byte[] data = Encoding.UTF8.GetBytes("The asset service is unavailable. So is your mesh.");
79 responsedata["str_response_string"] = "The asset service is unavailable. So is your mesh."; 76 httpResponse.Body.Write(data, 0, data.Length);
80 return responsedata; 77 return null;
81 } 78 }
82 79
83 AssetBase mesh = m_assetService.Get(meshID.ToString()); 80 AssetBase mesh = m_assetService.Get(meshID.ToString());
@@ -86,31 +83,32 @@ namespace OpenSim.Capabilities.Handlers
86 { 83 {
87 if (mesh.Type == (SByte)AssetType.Mesh) 84 if (mesh.Type == (SByte)AssetType.Mesh)
88 { 85 {
89 responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); 86 byte[] data = mesh.Data;
90 responsedata["content_type"] = "application/vnd.ll.mesh"; 87 httpResponse.Body.Write(data, 0, data.Length);
91 responsedata["int_response_code"] = 200; 88 httpResponse.ContentType = "application/vnd.ll.mesh";
89 httpResponse.StatusCode = 200;
92 } 90 }
93 // Optionally add additional mesh types here 91 // Optionally add additional mesh types here
94 else 92 else
95 { 93 {
96 responsedata["int_response_code"] = 404; //501; //410; //404; 94 httpResponse.StatusCode = 404;
97 responsedata["content_type"] = "text/plain"; 95 httpResponse.ContentType = "text/plain";
98 responsedata["keepalive"] = false; 96 byte[] data = Encoding.UTF8.GetBytes("Unfortunately, this asset isn't a mesh.");
99 responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh."; 97 httpResponse.Body.Write(data, 0, data.Length);
100 return responsedata; 98 httpResponse.KeepAlive = false;
101 } 99 }
102 } 100 }
103 else 101 else
104 { 102 {
105 responsedata["int_response_code"] = 404; //501; //410; //404; 103 httpResponse.StatusCode = 404;
106 responsedata["content_type"] = "text/plain"; 104 httpResponse.ContentType = "text/plain";
107 responsedata["keepalive"] = false; 105 byte[] data = Encoding.UTF8.GetBytes("Your Mesh wasn't found. Sorry!");
108 responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!"; 106 httpResponse.Body.Write(data, 0, data.Length);
109 return responsedata; 107 httpResponse.KeepAlive = false;
110 } 108 }
111 } 109 }
112 110
113 return responsedata; 111 return null;
114 } 112 }
115 } 113 }
116} \ No newline at end of file 114} \ No newline at end of file
diff --git a/OpenSim/Capabilities/Handlers/GetMesh/GetMeshServerConnector.cs b/OpenSim/Capabilities/Handlers/GetMesh/GetMeshServerConnector.cs
index 8a275f3..9c53862 100644
--- a/OpenSim/Capabilities/Handlers/GetMesh/GetMeshServerConnector.cs
+++ b/OpenSim/Capabilities/Handlers/GetMesh/GetMeshServerConnector.cs
@@ -65,15 +65,8 @@ namespace OpenSim.Capabilities.Handlers
65 if (m_AssetService == null) 65 if (m_AssetService == null)
66 throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName)); 66 throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName));
67 67
68 GetMeshHandler gmeshHandler = new GetMeshHandler(m_AssetService); 68 server.AddStreamHandler(
69 IRequestHandler reqHandler 69 new GetMeshHandler("/CAPS/GetMesh/" /*+ UUID.Random() */, m_AssetService, "GetMesh", null));
70 = new RestHTTPHandler(
71 "GET",
72 "/CAPS/" + UUID.Random(),
73 httpMethod => gmeshHandler.ProcessGetMesh(httpMethod, UUID.Zero, null),
74 "GetMesh",
75 null);
76 server.AddStreamHandler(reqHandler);
77 } 70 }
78 } 71 }
79} \ No newline at end of file 72} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
index 8e1f63a..4aecc99 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
@@ -110,32 +110,29 @@ namespace OpenSim.Region.ClientStack.Linden
110 110
111 #endregion 111 #endregion
112 112
113
114 public void RegisterCaps(UUID agentID, Caps caps) 113 public void RegisterCaps(UUID agentID, Caps caps)
115 { 114 {
116// UUID capID = UUID.Random();
117 115
118 //caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture)); 116 //caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture));
119 if (m_URL == "localhost") 117 if (m_URL == "localhost")
120 { 118 {
121// m_log.DebugFormat("[GETMESH]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); 119 // m_log.DebugFormat("[GETTEXTURE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName);
122 GetMeshHandler gmeshHandler = new GetMeshHandler(m_AssetService); 120
123 IRequestHandler reqHandler 121 UUID capID = UUID.Random();
124 = new RestHTTPHandler( 122
125 "GET", 123 caps.RegisterHandler(
126 "/CAPS/" + UUID.Random(), 124 "GetMesh",
127 httpMethod => gmeshHandler.ProcessGetMesh(httpMethod, UUID.Zero, null), 125 new GetMeshHandler("/CAPS/" + capID + "/", m_AssetService, "GetMesh", agentID.ToString()));
128 "GetMesh",
129 agentID.ToString());
130
131 caps.RegisterHandler("GetMesh", reqHandler);
132 } 126 }
133 else 127 else
134 { 128 {
135// m_log.DebugFormat("[GETMESH]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); 129 // m_log.DebugFormat("[GETTEXTURE]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName);
136 caps.RegisterHandler("GetMesh", m_URL); 130 IExternalCapsModule handler = m_scene.RequestModuleInterface<IExternalCapsModule>();
131 if (handler != null)
132 handler.RegisterExternalUserCapsHandler(agentID, caps, "GetMesh", m_URL);
133 else
134 caps.RegisterHandler("GetMesh", m_URL);
137 } 135 }
138 } 136 }
139
140 } 137 }
141} 138} \ No newline at end of file