From 0232f01a58a3c0a88e95c22589efec21f502f081 Mon Sep 17 00:00:00 2001 From: mingchen Date: Wed, 27 Jun 2007 19:43:46 +0000 Subject: *Moved all the classes into their own file from LLSDHelpers.cs *Some folder renaming to follow project Name *Updated prebuild.xml --- OpenSim/Region/Capabilities/Caps.cs | 279 ++++++++++++++++++++++++++++++++++++ 1 file changed, 279 insertions(+) create mode 100644 OpenSim/Region/Capabilities/Caps.cs (limited to 'OpenSim/Region/Capabilities/Caps.cs') diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs new file mode 100644 index 0000000..416a6bc --- /dev/null +++ b/OpenSim/Region/Capabilities/Caps.cs @@ -0,0 +1,279 @@ +/* +* Copyright (c) Contributors, http://www.openmetaverse.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.Xml; +using OpenSim.Framework.Servers; +using OpenSim.Framework; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Types; +using OpenSim.Region.Caches; +using libsecondlife; + +namespace OpenSim.Region.Capabilities +{ + public delegate void UpLoadedTexture(LLUUID assetID, LLUUID inventoryItem, byte[] data); + + public class Caps + { + private string httpListenerAddress; + private uint httpListenPort; + private string capsObjectPath = "00001-"; + private string requestPath = "0000/"; + private string mapLayerPath = "0001/"; + private string newInventory = "0002/"; + private string requestTexture = "0003/"; + private string eventQueue = "0100/"; + private BaseHttpServer httpListener; + private LLUUID agentID; + private AssetCache assetCache; + private int eventQueueCount = 1; + private Queue CapsEventQueue = new Queue(); + + public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent) + { + assetCache = assetCach; + capsObjectPath = capsPath; + httpListener = httpServer; + httpListenerAddress = httpListen; + httpListenPort = httpPort; + agentID = agent; + } + + /// + /// + /// + public void RegisterHandlers() + { + Console.WriteLine("registering CAPS handlers"); + httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + requestPath, CapsRequest); + httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + mapLayerPath, MapLayer); + httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + newInventory, NewAgentInventory); + httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + eventQueue, ProcessEventQueue); + } + + /// + /// + /// + /// + /// + /// + /// + public string CapsRequest(string request, string path, string param) + { + // Console.WriteLine("Caps Request " + request); + string result = ""; + result = LLSDHelpers.SerialiseLLSDReply(this.GetCapabilities()); + return result; + } + + /// + /// + /// + /// + protected LLSDCapsDetails GetCapabilities() + { + /* string capURLS = ""; + capURLS += "MapLayerhttp://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + mapLayerPath + ""; + capURLS += "NewFileAgentInventoryhttp://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + newInventory + ""; + //capURLS += "RequestTextureDownloadhttp://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + requestTexture + ""; + //capURLS += "EventQueueGethttp://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + eventQueue + ""; + return capURLS;*/ + + LLSDCapsDetails caps = new LLSDCapsDetails(); + caps.MapLayer = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + mapLayerPath; + caps.NewFileAgentInventory = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + newInventory; + return caps; + } + + /// + /// + /// + /// + /// + /// + /// + public string MapLayer(string request, string path, string param) + { + Encoding _enc = System.Text.Encoding.UTF8; + Hashtable hash =(Hashtable) LLSD.LLSDDeserialize(_enc.GetBytes(request)); + LLSDMapRequest mapReq = new LLSDMapRequest(); + LLSDHelpers.DeserialiseLLSDMap(hash, mapReq ); + + LLSDMapLayerResponse mapResponse= new LLSDMapLayerResponse(); + mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse()); + string res = LLSDHelpers.SerialiseLLSDReply(mapResponse); + + //Console.WriteLine(" Maplayer response is " + res); + + return res; + } + + /// + /// + /// + /// + protected LLSDMapLayer BuildLLSDMapLayerResponse() + { + LLSDMapLayer mapLayer = new LLSDMapLayer(); + mapLayer.Right = 5000; + mapLayer.Top = 5000; + mapLayer.ImageID = new LLUUID("00000000-0000-0000-9999-000000000006"); + + return mapLayer; + } + + public string ProcessEventQueue(string request, string path, string param) + { + string res = ""; + + if (this.CapsEventQueue.Count > 0) + { + lock (this.CapsEventQueue) + { + string item = CapsEventQueue.Dequeue(); + res = item; + } + } + else + { + res = this.CreateEmptyEventResponse(); + } + return res; + } + + public string CreateEstablishAgentComms(string caps, string ipAddressPort) + { + string res = "id" + eventQueueCount + ""; + res += "events"; + res += "messageEstablishAgentCommunication"; + res += "body"; + res += "sim-ip-and-port" + ipAddressPort + ""; + res += "seed-capability" + caps + ""; + res += "agent-id" + this.agentID.ToStringHyphenated() + ""; + res += ""; + res += ""; + res += ""; + eventQueueCount++; + this.CapsEventQueue.Enqueue(res); + return res; + } + + public string CreateEmptyEventResponse() + { + string res = "id" + eventQueueCount + ""; + res += "events"; + res += ""; + res += ""; + eventQueueCount++; + return res; + } + + public string NewAgentInventory(string request, string path, string param) + { + //Console.WriteLine("received upload request:"+ request); + string res = ""; + LLUUID newAsset = LLUUID.Random(); + LLUUID newInvItem = LLUUID.Random(); + string uploaderPath = capsObjectPath + Util.RandomClass.Next(5000, 8000).ToString("0000"); + AssetUploader uploader = new AssetUploader(newAsset, newInvItem, uploaderPath, this.httpListener); + httpListener.AddRestHandler("POST", "/CAPS/" + uploaderPath, uploader.uploaderCaps); + string uploaderURL = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + uploaderPath; + //Console.WriteLine("uploader url is " + uploaderURL); + res += ""; + res += "uploader" + uploaderURL + ""; + //res += "successtrue"; + res += "stateupload"; + res += ""; + uploader.OnUpLoad += this.UploadHandler; + return res; + } + + public void UploadHandler(LLUUID assetID, LLUUID inventoryItem, byte[] data) + { + // Console.WriteLine("upload handler called"); + AssetBase asset; + asset = new AssetBase(); + asset.FullID = assetID; + asset.Type = 0; + asset.InvType = 0; + asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000"); + asset.Data = data; + this.assetCache.AddAsset(asset); + } + + public class AssetUploader + { + public event UpLoadedTexture OnUpLoad; + + private string uploaderPath = ""; + private LLUUID newAssetID; + private LLUUID inventoryItemID; + private BaseHttpServer httpListener; + public AssetUploader(LLUUID assetID, LLUUID inventoryItem, string path, BaseHttpServer httpServer) + { + newAssetID = assetID; + inventoryItemID = inventoryItem; + uploaderPath = path; + httpListener = httpServer; + + } + + public string uploaderCaps(string request, string path, string param) + { + Encoding _enc = System.Text.Encoding.UTF8; + byte[] data = _enc.GetBytes(request); + //Console.WriteLine("recieved upload " + Util.FieldToString(data)); + LLUUID inv = this.inventoryItemID; + string res = ""; + res += ""; + res += "new_asset" + newAssetID.ToStringHyphenated() + ""; + res += "new_inventory_item" + inv.ToStringHyphenated() + ""; + res += "statecomplete"; + res += ""; + + // Console.WriteLine("asset " + newAssetID.ToStringHyphenated() + " , inventory item " + inv.ToStringHyphenated()); + httpListener.RemoveRestHandler("POST", "/CAPS/" + uploaderPath); + if (OnUpLoad != null) + { + OnUpLoad(newAssetID, inv, data); + } + + /*FileStream fs = File.Create("upload.jp2"); + BinaryWriter bw = new BinaryWriter(fs); + bw.Write(data); + bw.Close(); + fs.Close();*/ + return res; + } + } + } +} -- cgit v1.1 From 06a8c132005b4ab804f25d54c0c0f899fc98e3a1 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Sun, 1 Jul 2007 16:07:41 +0000 Subject: MAJOR IP RESTRUCTURING * moving towards IPEndPoints all over the place * trying to make the internal/external division --- OpenSim/Region/Capabilities/Caps.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Capabilities/Caps.cs') diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs index 416a6bc..2bbf656 100644 --- a/OpenSim/Region/Capabilities/Caps.cs +++ b/OpenSim/Region/Capabilities/Caps.cs @@ -44,8 +44,8 @@ namespace OpenSim.Region.Capabilities public class Caps { - private string httpListenerAddress; - private uint httpListenPort; + private string httpListenerHostName; + private int httpListenPort; private string capsObjectPath = "00001-"; private string requestPath = "0000/"; private string mapLayerPath = "0001/"; @@ -58,12 +58,12 @@ namespace OpenSim.Region.Capabilities private int eventQueueCount = 1; private Queue CapsEventQueue = new Queue(); - public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent) + public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent) { assetCache = assetCach; capsObjectPath = capsPath; httpListener = httpServer; - httpListenerAddress = httpListen; + httpListenerHostName = httpListen; httpListenPort = httpPort; agentID = agent; } @@ -109,8 +109,11 @@ namespace OpenSim.Region.Capabilities return capURLS;*/ LLSDCapsDetails caps = new LLSDCapsDetails(); - caps.MapLayer = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + mapLayerPath; - caps.NewFileAgentInventory = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + newInventory; + string capsBaseUrl = "http://" + httpListenerHostName + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath; + + caps.MapLayer = capsBaseUrl + mapLayerPath; + caps.NewFileAgentInventory = capsBaseUrl + newInventory; + return caps; } @@ -206,7 +209,7 @@ namespace OpenSim.Region.Capabilities string uploaderPath = capsObjectPath + Util.RandomClass.Next(5000, 8000).ToString("0000"); AssetUploader uploader = new AssetUploader(newAsset, newInvItem, uploaderPath, this.httpListener); httpListener.AddRestHandler("POST", "/CAPS/" + uploaderPath, uploader.uploaderCaps); - string uploaderURL = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + uploaderPath; + string uploaderURL = "http://" + httpListenerHostName + ":" + httpListenPort.ToString() + "/CAPS/" + uploaderPath; //Console.WriteLine("uploader url is " + uploaderURL); res += ""; res += "uploader" + uploaderURL + ""; -- cgit v1.1 From 9b6b6d05d45cf0f754a0b26bf6240ef50be66563 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 3 Jul 2007 14:37:29 +0000 Subject: * Optimized usings (the 'LL ate my scripts' commit) * added some licensing info --- OpenSim/Region/Capabilities/Caps.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Capabilities/Caps.cs') diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs index 2bbf656..b38979d 100644 --- a/OpenSim/Region/Capabilities/Caps.cs +++ b/OpenSim/Region/Capabilities/Caps.cs @@ -29,14 +29,11 @@ using System; using System.Collections; using System.Collections.Generic; using System.Text; -using System.IO; -using System.Xml; +using libsecondlife; using OpenSim.Framework.Servers; -using OpenSim.Framework; -using OpenSim.Framework.Utilities; using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; using OpenSim.Region.Caches; -using libsecondlife; namespace OpenSim.Region.Capabilities { @@ -126,7 +123,7 @@ namespace OpenSim.Region.Capabilities /// public string MapLayer(string request, string path, string param) { - Encoding _enc = System.Text.Encoding.UTF8; + Encoding _enc = Encoding.UTF8; Hashtable hash =(Hashtable) LLSD.LLSDDeserialize(_enc.GetBytes(request)); LLSDMapRequest mapReq = new LLSDMapRequest(); LLSDHelpers.DeserialiseLLSDMap(hash, mapReq ); @@ -252,7 +249,7 @@ namespace OpenSim.Region.Capabilities public string uploaderCaps(string request, string path, string param) { - Encoding _enc = System.Text.Encoding.UTF8; + Encoding _enc = Encoding.UTF8; byte[] data = _enc.GetBytes(request); //Console.WriteLine("recieved upload " + Util.FieldToString(data)); LLUUID inv = this.inventoryItemID; -- cgit v1.1 From bd8018fa1cb32aa42e2a1a41ebb01fc0f1b0a04b Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 3 Jul 2007 20:10:20 +0000 Subject: Today's work on Building support/tools. Think I am slowly getting there. --- OpenSim/Region/Capabilities/Caps.cs | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region/Capabilities/Caps.cs') diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs index b38979d..d9d6f51 100644 --- a/OpenSim/Region/Capabilities/Caps.cs +++ b/OpenSim/Region/Capabilities/Caps.cs @@ -98,13 +98,6 @@ namespace OpenSim.Region.Capabilities /// protected LLSDCapsDetails GetCapabilities() { - /* string capURLS = ""; - capURLS += "MapLayerhttp://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + mapLayerPath + ""; - capURLS += "NewFileAgentInventoryhttp://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + newInventory + ""; - //capURLS += "RequestTextureDownloadhttp://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + requestTexture + ""; - //capURLS += "EventQueueGethttp://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + eventQueue + ""; - return capURLS;*/ - LLSDCapsDetails caps = new LLSDCapsDetails(); string capsBaseUrl = "http://" + httpListenerHostName + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath; @@ -131,8 +124,6 @@ namespace OpenSim.Region.Capabilities LLSDMapLayerResponse mapResponse= new LLSDMapLayerResponse(); mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse()); string res = LLSDHelpers.SerialiseLLSDReply(mapResponse); - - //Console.WriteLine(" Maplayer response is " + res); return res; } @@ -172,27 +163,23 @@ namespace OpenSim.Region.Capabilities public string CreateEstablishAgentComms(string caps, string ipAddressPort) { - string res = "id" + eventQueueCount + ""; - res += "events"; - res += "messageEstablishAgentCommunication"; - res += "body"; - res += "sim-ip-and-port" + ipAddressPort + ""; - res += "seed-capability" + caps + ""; - res += "agent-id" + this.agentID.ToStringHyphenated() + ""; - res += ""; - res += ""; - res += ""; + LLSDCapEvent eventItem = new LLSDCapEvent(); + eventItem.id = eventQueueCount; + //should be creating a EstablishAgentComms item, but there isn't a class for it yet + eventItem.events.Array.Add(new LLSDEmpty()); + string res = LLSDHelpers.SerialiseLLSDReply(eventItem); eventQueueCount++; + this.CapsEventQueue.Enqueue(res); return res; } public string CreateEmptyEventResponse() { - string res = "id" + eventQueueCount + ""; - res += "events"; - res += ""; - res += ""; + LLSDCapEvent eventItem = new LLSDCapEvent(); + eventItem.id = eventQueueCount; + eventItem.events.Array.Add(new LLSDEmpty()); + string res = LLSDHelpers.SerialiseLLSDReply(eventItem); eventQueueCount++; return res; } -- cgit v1.1 From 249ce4cf6f353dd59ebec27689e74a527c39a090 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 4 Jul 2007 05:49:12 +0000 Subject: * More cleaning - Sugilite now only has build errors for "value is never used" properties (which I presume will be filled in over time) --- OpenSim/Region/Capabilities/Caps.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'OpenSim/Region/Capabilities/Caps.cs') diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs index d9d6f51..4a283b2 100644 --- a/OpenSim/Region/Capabilities/Caps.cs +++ b/OpenSim/Region/Capabilities/Caps.cs @@ -75,6 +75,7 @@ namespace OpenSim.Region.Capabilities httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + mapLayerPath, MapLayer); httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + newInventory, NewAgentInventory); httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + eventQueue, ProcessEventQueue); + httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + requestTexture, RequestTexture); } /// @@ -131,6 +132,19 @@ namespace OpenSim.Region.Capabilities /// /// /// + /// + /// + /// + /// + public string RequestTexture(string request, string path, string param) + { + // Needs implementing (added to remove compiler warning) + return ""; + } + + /// + /// + /// /// protected LLSDMapLayer BuildLLSDMapLayerResponse() { -- cgit v1.1 From 9a51949cb4c833dcacf2a5803a8f2753273941c8 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 4 Jul 2007 11:47:32 +0000 Subject: * Added StreamHandler support * Implemented RestStreamHandler * Some caps functions now use it * Moved out RestMethodEntry from httpserver * The IStreamHandler interface now reports required method and Content-Type --- OpenSim/Region/Capabilities/Caps.cs | 47 +++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region/Capabilities/Caps.cs') diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs index 4a283b2..0f6c471 100644 --- a/OpenSim/Region/Capabilities/Caps.cs +++ b/OpenSim/Region/Capabilities/Caps.cs @@ -41,13 +41,13 @@ namespace OpenSim.Region.Capabilities public class Caps { - private string httpListenerHostName; - private int httpListenPort; - private string capsObjectPath = "00001-"; - private string requestPath = "0000/"; - private string mapLayerPath = "0001/"; - private string newInventory = "0002/"; - private string requestTexture = "0003/"; + private string m_httpListenerHostName; + private int m_httpListenPort; + private string m_capsObjectPath = "00001-"; + private string m_requestPath = "0000/"; + private string m_mapLayerPath = "0001/"; + private string m_newInventory = "0002/"; + private string m_requestTexture = "0003/"; private string eventQueue = "0100/"; private BaseHttpServer httpListener; private LLUUID agentID; @@ -58,10 +58,10 @@ namespace OpenSim.Region.Capabilities public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent) { assetCache = assetCach; - capsObjectPath = capsPath; + m_capsObjectPath = capsPath; httpListener = httpServer; - httpListenerHostName = httpListen; - httpListenPort = httpPort; + m_httpListenerHostName = httpListen; + m_httpListenPort = httpPort; agentID = agent; } @@ -71,13 +71,20 @@ namespace OpenSim.Region.Capabilities public void RegisterHandlers() { Console.WriteLine("registering CAPS handlers"); - httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + requestPath, CapsRequest); - httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + mapLayerPath, MapLayer); - httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + newInventory, NewAgentInventory); - httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + eventQueue, ProcessEventQueue); - httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + requestTexture, RequestTexture); + + AddCapsHandler( httpListener, m_requestPath, CapsRequest); + AddCapsHandler( httpListener, m_mapLayerPath, MapLayer); + AddCapsHandler( httpListener, m_newInventory, NewAgentInventory); + AddCapsHandler( httpListener, eventQueue, ProcessEventQueue); + AddCapsHandler( httpListener, m_requestTexture, RequestTexture); } + private void AddCapsHandler( BaseHttpServer httpListener, string path, RestMethod restMethod ) + { + string capsBase = "/CAPS/" + m_capsObjectPath; + httpListener.AddStreamHandler(capsBase + path, new RestStreamHandler(restMethod, "POST", "application/xml")); + } + /// /// /// @@ -100,10 +107,10 @@ namespace OpenSim.Region.Capabilities protected LLSDCapsDetails GetCapabilities() { LLSDCapsDetails caps = new LLSDCapsDetails(); - string capsBaseUrl = "http://" + httpListenerHostName + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath; + string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; - caps.MapLayer = capsBaseUrl + mapLayerPath; - caps.NewFileAgentInventory = capsBaseUrl + newInventory; + caps.MapLayer = capsBaseUrl + m_mapLayerPath; + caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; return caps; } @@ -204,10 +211,10 @@ namespace OpenSim.Region.Capabilities string res = ""; LLUUID newAsset = LLUUID.Random(); LLUUID newInvItem = LLUUID.Random(); - string uploaderPath = capsObjectPath + Util.RandomClass.Next(5000, 8000).ToString("0000"); + string uploaderPath = m_capsObjectPath + Util.RandomClass.Next(5000, 8000).ToString("0000"); AssetUploader uploader = new AssetUploader(newAsset, newInvItem, uploaderPath, this.httpListener); httpListener.AddRestHandler("POST", "/CAPS/" + uploaderPath, uploader.uploaderCaps); - string uploaderURL = "http://" + httpListenerHostName + ":" + httpListenPort.ToString() + "/CAPS/" + uploaderPath; + string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + uploaderPath; //Console.WriteLine("uploader url is " + uploaderURL); res += ""; res += "uploader" + uploaderURL + ""; -- cgit v1.1 From 6a2588454a1ac4bb484ad0b9ee648e9ac156f8db Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 4 Jul 2007 14:12:32 +0000 Subject: * Removed AssetHttpServer, using BaseHttpServer instead * Removed legacy REST handling * Created two custom IStreamHandlers for asset up/download * Removed quite a lot of double and triple encodings, trying to work towards binary only and direct write into storage. * Introduced BaseStreamHandler with GetParam() and some other goodies --- OpenSim/Region/Capabilities/Caps.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Capabilities/Caps.cs') diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs index 0f6c471..1d07683 100644 --- a/OpenSim/Region/Capabilities/Caps.cs +++ b/OpenSim/Region/Capabilities/Caps.cs @@ -82,7 +82,7 @@ namespace OpenSim.Region.Capabilities private void AddCapsHandler( BaseHttpServer httpListener, string path, RestMethod restMethod ) { string capsBase = "/CAPS/" + m_capsObjectPath; - httpListener.AddStreamHandler(capsBase + path, new RestStreamHandler(restMethod, "POST", "application/xml")); + httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); } /// @@ -211,9 +211,11 @@ namespace OpenSim.Region.Capabilities string res = ""; LLUUID newAsset = LLUUID.Random(); LLUUID newInvItem = LLUUID.Random(); - string uploaderPath = m_capsObjectPath + Util.RandomClass.Next(5000, 8000).ToString("0000"); + string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); AssetUploader uploader = new AssetUploader(newAsset, newInvItem, uploaderPath, this.httpListener); - httpListener.AddRestHandler("POST", "/CAPS/" + uploaderPath, uploader.uploaderCaps); + + AddCapsHandler( httpListener, uploaderPath, uploader.uploaderCaps); + string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + uploaderPath; //Console.WriteLine("uploader url is " + uploaderURL); res += ""; @@ -269,7 +271,8 @@ namespace OpenSim.Region.Capabilities res += ""; // Console.WriteLine("asset " + newAssetID.ToStringHyphenated() + " , inventory item " + inv.ToStringHyphenated()); - httpListener.RemoveRestHandler("POST", "/CAPS/" + uploaderPath); + httpListener.RemoveStreamHandler("POST", "/CAPS/" + uploaderPath); + if (OnUpLoad != null) { OnUpLoad(newAssetID, inv, data); -- cgit v1.1 From 5c32b33a66fbdf371d53d85ee54ee8e837481570 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 4 Jul 2007 16:28:59 +0000 Subject: * re-fixed the utf-16 bug in xmlRpcResponse serialization * added LLSDStreamHandler.cs to Caps (Haven't enabled it yet, though) * removed last traces of old rest handling --- OpenSim/Region/Capabilities/Caps.cs | 38 +++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Capabilities/Caps.cs') diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs index 1d07683..70d601f 100644 --- a/OpenSim/Region/Capabilities/Caps.cs +++ b/OpenSim/Region/Capabilities/Caps.cs @@ -71,20 +71,33 @@ namespace OpenSim.Region.Capabilities public void RegisterHandlers() { Console.WriteLine("registering CAPS handlers"); + string capsBase = "/CAPS/" + m_capsObjectPath; + + AddLegacyCapsHandler( httpListener, m_mapLayerPath, MapLayer); + + //httpListener.AddStreamHandler( + // new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, this.GetMapLayer )); - AddCapsHandler( httpListener, m_requestPath, CapsRequest); - AddCapsHandler( httpListener, m_mapLayerPath, MapLayer); - AddCapsHandler( httpListener, m_newInventory, NewAgentInventory); - AddCapsHandler( httpListener, eventQueue, ProcessEventQueue); - AddCapsHandler( httpListener, m_requestTexture, RequestTexture); + AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest); + AddLegacyCapsHandler(httpListener, m_newInventory, NewAgentInventory); + AddLegacyCapsHandler( httpListener, eventQueue, ProcessEventQueue); + AddLegacyCapsHandler( httpListener, m_requestTexture, RequestTexture); } - private void AddCapsHandler( BaseHttpServer httpListener, string path, RestMethod restMethod ) + public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) + { + LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); + mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse()); + return mapResponse; + } + + [Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")] + private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod) { string capsBase = "/CAPS/" + m_capsObjectPath; httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); } - + /// /// /// @@ -125,17 +138,18 @@ namespace OpenSim.Region.Capabilities public string MapLayer(string request, string path, string param) { Encoding _enc = Encoding.UTF8; - Hashtable hash =(Hashtable) LLSD.LLSDDeserialize(_enc.GetBytes(request)); + Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(_enc.GetBytes(request)); LLSDMapRequest mapReq = new LLSDMapRequest(); - LLSDHelpers.DeserialiseLLSDMap(hash, mapReq ); + LLSDHelpers.DeserialiseLLSDMap(hash, mapReq); - LLSDMapLayerResponse mapResponse= new LLSDMapLayerResponse(); + LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse()); string res = LLSDHelpers.SerialiseLLSDReply(mapResponse); - + return res; } + /// /// /// @@ -214,7 +228,7 @@ namespace OpenSim.Region.Capabilities string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); AssetUploader uploader = new AssetUploader(newAsset, newInvItem, uploaderPath, this.httpListener); - AddCapsHandler( httpListener, uploaderPath, uploader.uploaderCaps); + AddLegacyCapsHandler( httpListener, uploaderPath, uploader.uploaderCaps); string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + uploaderPath; //Console.WriteLine("uploader url is " + uploaderURL); -- cgit v1.1 From beb3073bec9438a439e13eaec40a8320a9279adc Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 4 Jul 2007 19:07:27 +0000 Subject: A bit more work on Building tools/support. updated Axiom.MathLib.dll. --- OpenSim/Region/Capabilities/Caps.cs | 52 ++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Capabilities/Caps.cs') diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs index 70d601f..6206f65 100644 --- a/OpenSim/Region/Capabilities/Caps.cs +++ b/OpenSim/Region/Capabilities/Caps.cs @@ -73,6 +73,7 @@ namespace OpenSim.Region.Capabilities Console.WriteLine("registering CAPS handlers"); string capsBase = "/CAPS/" + m_capsObjectPath; + AddLegacyCapsHandler( httpListener, m_mapLayerPath, MapLayer); //httpListener.AddStreamHandler( @@ -82,6 +83,7 @@ namespace OpenSim.Region.Capabilities AddLegacyCapsHandler(httpListener, m_newInventory, NewAgentInventory); AddLegacyCapsHandler( httpListener, eventQueue, ProcessEventQueue); AddLegacyCapsHandler( httpListener, m_requestTexture, RequestTexture); + } public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) @@ -153,6 +155,20 @@ namespace OpenSim.Region.Capabilities /// /// /// + /// + protected LLSDMapLayer BuildLLSDMapLayerResponse() + { + LLSDMapLayer mapLayer = new LLSDMapLayer(); + mapLayer.Right = 5000; + mapLayer.Top = 5000; + mapLayer.ImageID = new LLUUID("00000000-0000-0000-9999-000000000006"); + + return mapLayer; + } + + /// + /// + /// /// /// /// @@ -166,17 +182,10 @@ namespace OpenSim.Region.Capabilities /// /// /// + /// + /// + /// /// - protected LLSDMapLayer BuildLLSDMapLayerResponse() - { - LLSDMapLayer mapLayer = new LLSDMapLayer(); - mapLayer.Right = 5000; - mapLayer.Top = 5000; - mapLayer.ImageID = new LLUUID("00000000-0000-0000-9999-000000000006"); - - return mapLayer; - } - public string ProcessEventQueue(string request, string path, string param) { string res = ""; @@ -196,6 +205,12 @@ namespace OpenSim.Region.Capabilities return res; } + /// + /// + /// + /// + /// + /// public string CreateEstablishAgentComms(string caps, string ipAddressPort) { LLSDCapEvent eventItem = new LLSDCapEvent(); @@ -209,6 +224,10 @@ namespace OpenSim.Region.Capabilities return res; } + /// + /// + /// + /// public string CreateEmptyEventResponse() { LLSDCapEvent eventItem = new LLSDCapEvent(); @@ -219,6 +238,13 @@ namespace OpenSim.Region.Capabilities return res; } + /// + /// + /// + /// + /// + /// + /// public string NewAgentInventory(string request, string path, string param) { //Console.WriteLine("received upload request:"+ request); @@ -241,6 +267,12 @@ namespace OpenSim.Region.Capabilities return res; } + /// + /// + /// + /// + /// + /// public void UploadHandler(LLUUID assetID, LLUUID inventoryItem, byte[] data) { // Console.WriteLine("upload handler called"); -- cgit v1.1 From 93f3ef7e0d1c7d8b9c578ffdf4e45d9c0d2dde6c Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 9 Jul 2007 15:59:35 +0000 Subject: Done a little bit of renaming in primitive.cs and on a few events in IClientAPI. Disabled CAPS asset uploading as it seems it now crashes the server. --- OpenSim/Region/Capabilities/Caps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Capabilities/Caps.cs') diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs index 6206f65..fdc21cf 100644 --- a/OpenSim/Region/Capabilities/Caps.cs +++ b/OpenSim/Region/Capabilities/Caps.cs @@ -125,7 +125,7 @@ namespace OpenSim.Region.Capabilities string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; caps.MapLayer = capsBaseUrl + m_mapLayerPath; - caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; + // caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; return caps; } -- cgit v1.1 From 9f5f65c8477e3d05f384bafbb1bdf6dcb3f577c8 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 9 Jul 2007 23:32:29 +0000 Subject: * LLSDStreamhandler now works. --- OpenSim/Region/Capabilities/Caps.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Capabilities/Caps.cs') diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs index fdc21cf..6068076 100644 --- a/OpenSim/Region/Capabilities/Caps.cs +++ b/OpenSim/Region/Capabilities/Caps.cs @@ -74,10 +74,10 @@ namespace OpenSim.Region.Capabilities string capsBase = "/CAPS/" + m_capsObjectPath; - AddLegacyCapsHandler( httpListener, m_mapLayerPath, MapLayer); + //AddLegacyCapsHandler( httpListener, m_mapLayerPath, MapLayer); - //httpListener.AddStreamHandler( - // new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, this.GetMapLayer )); + httpListener.AddStreamHandler( + new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, this.GetMapLayer )); AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest); AddLegacyCapsHandler(httpListener, m_newInventory, NewAgentInventory); @@ -86,13 +86,6 @@ namespace OpenSim.Region.Capabilities } - public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) - { - LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); - mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse()); - return mapResponse; - } - [Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")] private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod) { @@ -151,6 +144,13 @@ namespace OpenSim.Region.Capabilities return res; } + public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) + { + LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); + mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse()); + return mapResponse; + } + /// /// -- cgit v1.1