diff options
author | Adam Frisby | 2009-04-23 04:51:29 +0000 |
---|---|---|
committer | Adam Frisby | 2009-04-23 04:51:29 +0000 |
commit | 2af4ca44a62d00026515635efb073d3d6877b804 (patch) | |
tree | b267a248a78dd2d5697ee14cdad49c7b442cf939 /OpenSim/Client/VWoHTTP/ClientStack | |
parent | * Fix hypergrid standalone login by overriding AddNewUserAgent in HGUserServices (diff) | |
download | opensim-SC-2af4ca44a62d00026515635efb073d3d6877b804.zip opensim-SC-2af4ca44a62d00026515635efb073d3d6877b804.tar.gz opensim-SC-2af4ca44a62d00026515635efb073d3d6877b804.tar.bz2 opensim-SC-2af4ca44a62d00026515635efb073d3d6877b804.tar.xz |
* Adds additional background layer for VWoHTTP ClientStack
* Implements asset handling.
Diffstat (limited to 'OpenSim/Client/VWoHTTP/ClientStack')
-rw-r--r-- | OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs | 80 |
1 files changed, 70 insertions, 10 deletions
diff --git a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs index bf622c6..70b7d6c 100644 --- a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs +++ b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs | |||
@@ -1,8 +1,12 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Drawing; | ||
4 | using System.Drawing.Imaging; | ||
5 | using System.IO; | ||
3 | using System.Net; | 6 | using System.Net; |
4 | using System.Text; | 7 | using System.Text; |
5 | using OpenMetaverse; | 8 | using OpenMetaverse; |
9 | using OpenMetaverse.Imaging; | ||
6 | using OpenMetaverse.Packets; | 10 | using OpenMetaverse.Packets; |
7 | using OpenSim.Framework; | 11 | using OpenSim.Framework; |
8 | using OpenSim.Framework.Servers; | 12 | using OpenSim.Framework.Servers; |
@@ -12,21 +16,79 @@ namespace OpenSim.Client.VWoHTTP.ClientStack | |||
12 | { | 16 | { |
13 | class VWHClientView : IClientAPI | 17 | class VWHClientView : IClientAPI |
14 | { | 18 | { |
15 | // private Scene m_scene; | 19 | private Scene m_scene; |
16 | 20 | ||
17 | public void ProcessInMsg(OSHttpRequest req, OSHttpResponse resp) | 21 | |
22 | public bool ProcessInMsg(OSHttpRequest req, OSHttpResponse resp) | ||
18 | { | 23 | { |
19 | // string method = req.Url.AbsolutePath.Split('/')[2]; | 24 | // 0 1 2 3 |
25 | // http://simulator.com:9000/vwohttp/sessionid/methodname/param | ||
26 | string[] urlparts = req.Url.AbsolutePath.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries); | ||
27 | |||
28 | UUID sessionID; | ||
29 | // Check for session | ||
30 | if (!UUID.TryParse(urlparts[1], out sessionID)) | ||
31 | return false; | ||
32 | // Check we match session | ||
33 | if(sessionID != SessionId) | ||
34 | return false; | ||
35 | |||
36 | string method = urlparts[2]; | ||
37 | |||
38 | string param = String.Empty; | ||
39 | if (urlparts.Length > 3) | ||
40 | param = urlparts[3]; | ||
41 | |||
42 | bool found; | ||
43 | |||
44 | switch (method.ToLower()) | ||
45 | { | ||
46 | case "textures": | ||
47 | found = ProcessTextureRequest(param, resp); | ||
48 | break; | ||
49 | default: | ||
50 | found = false; | ||
51 | break; | ||
52 | } | ||
53 | |||
54 | return found; | ||
20 | } | 55 | } |
21 | 56 | ||
22 | // private void ProcessAssetRequest(OSHttpRequest req, OSHttpResponse resp) | 57 | private bool ProcessTextureRequest(string param, OSHttpResponse resp) |
23 | // { | 58 | { |
24 | // | 59 | UUID assetID; |
25 | // } | 60 | if(!UUID.TryParse(param, out assetID)) |
61 | return false; | ||
62 | |||
63 | AssetBase asset = m_scene.CommsManager.AssetCache.GetAsset(assetID, true); | ||
64 | |||
65 | if(asset == null) | ||
66 | return false; | ||
67 | |||
68 | ManagedImage tmp; | ||
69 | Image imgData; | ||
70 | |||
71 | OpenJPEG.DecodeToImage(asset.Data, out tmp, out imgData); | ||
72 | |||
73 | MemoryStream ms = new MemoryStream(); | ||
74 | |||
75 | imgData.Save(ms, ImageFormat.Jpeg); | ||
76 | |||
77 | byte[] jpegdata = ms.GetBuffer(); | ||
78 | |||
79 | ms.Close(); | ||
80 | |||
81 | resp.ContentType = "image/jpeg"; | ||
82 | resp.ContentLength = jpegdata.Length; | ||
83 | resp.StatusCode = 200; | ||
84 | resp.Body.Write(jpegdata, 0, jpegdata.Length); | ||
85 | |||
86 | return true; | ||
87 | } | ||
26 | 88 | ||
27 | public VWHClientView(UUID sessionID, UUID agentID, string agentName, Scene scene) | 89 | public VWHClientView(UUID sessionID, UUID agentID, string agentName, Scene scene) |
28 | { | 90 | { |
29 | // m_scene = scene; | 91 | m_scene = scene; |
30 | } | 92 | } |
31 | 93 | ||
32 | #region Implementation of IClientAPI | 94 | #region Implementation of IClientAPI |
@@ -1031,8 +1093,6 @@ namespace OpenSim.Client.VWoHTTP.ClientStack | |||
1031 | throw new System.NotImplementedException(); | 1093 | throw new System.NotImplementedException(); |
1032 | } | 1094 | } |
1033 | 1095 | ||
1034 | public event PlacesQuery OnPlacesQuery; | ||
1035 | |||
1036 | #endregion | 1096 | #endregion |
1037 | } | 1097 | } |
1038 | } | 1098 | } |