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 | |
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')
-rw-r--r-- | OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs | 80 | ||||
-rw-r--r-- | OpenSim/Client/VWoHTTP/VWoHTTPModule.cs | 43 |
2 files changed, 110 insertions, 13 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 | } |
diff --git a/OpenSim/Client/VWoHTTP/VWoHTTPModule.cs b/OpenSim/Client/VWoHTTP/VWoHTTPModule.cs index 451bf1e..c5b5c09 100644 --- a/OpenSim/Client/VWoHTTP/VWoHTTPModule.cs +++ b/OpenSim/Client/VWoHTTP/VWoHTTPModule.cs | |||
@@ -13,17 +13,21 @@ namespace OpenSim.Client.VWoHTTP | |||
13 | { | 13 | { |
14 | class VWoHTTPModule : IRegionModule, IHttpAgentHandler | 14 | class VWoHTTPModule : IRegionModule, IHttpAgentHandler |
15 | { | 15 | { |
16 | private bool m_disabled = true; | ||
16 | 17 | ||
17 | private IHttpServer m_httpd; | 18 | private IHttpServer m_httpd; |
18 | 19 | ||
19 | private readonly List<Scene> m_scenes = new List<Scene>(); | 20 | private readonly List<Scene> m_scenes = new List<Scene>(); |
20 | 21 | ||
21 | //private Dictionary<UUID, VWHClientView> m_clients = new Dictionary<UUID, VWHClientView>(); | 22 | private Dictionary<UUID, VWHClientView> m_clients = new Dictionary<UUID, VWHClientView>(); |
22 | 23 | ||
23 | #region Implementation of IRegionModule | 24 | #region Implementation of IRegionModule |
24 | 25 | ||
25 | public void Initialise(Scene scene, IConfigSource source) | 26 | public void Initialise(Scene scene, IConfigSource source) |
26 | { | 27 | { |
28 | if(m_disabled) | ||
29 | return; | ||
30 | |||
27 | m_scenes.Add(scene); | 31 | m_scenes.Add(scene); |
28 | 32 | ||
29 | m_httpd = scene.CommsManager.HttpServer; | 33 | m_httpd = scene.CommsManager.HttpServer; |
@@ -31,11 +35,17 @@ namespace OpenSim.Client.VWoHTTP | |||
31 | 35 | ||
32 | public void PostInitialise() | 36 | public void PostInitialise() |
33 | { | 37 | { |
38 | if (m_disabled) | ||
39 | return; | ||
40 | |||
34 | m_httpd.AddAgentHandler("vwohttp", this); | 41 | m_httpd.AddAgentHandler("vwohttp", this); |
35 | } | 42 | } |
36 | 43 | ||
37 | public void Close() | 44 | public void Close() |
38 | { | 45 | { |
46 | if (m_disabled) | ||
47 | return; | ||
48 | |||
39 | m_httpd.RemoveAgentHandler("vwohttp", this); | 49 | m_httpd.RemoveAgentHandler("vwohttp", this); |
40 | } | 50 | } |
41 | 51 | ||
@@ -55,8 +65,35 @@ namespace OpenSim.Client.VWoHTTP | |||
55 | 65 | ||
56 | public bool Handle(OSHttpRequest req, OSHttpResponse resp) | 66 | public bool Handle(OSHttpRequest req, OSHttpResponse resp) |
57 | { | 67 | { |
58 | 68 | string[] urlparts = req.Url.AbsolutePath.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries); | |
59 | return false; | 69 | |
70 | if (urlparts.Length < 2) | ||
71 | return false; | ||
72 | |||
73 | if (urlparts[1] == "connect") | ||
74 | { | ||
75 | UUID sessID = UUID.Random(); | ||
76 | |||
77 | VWHClientView client = new VWHClientView(sessID, UUID.Random(), "VWoHTTPClient", m_scenes[0]); | ||
78 | |||
79 | m_clients.Add(sessID, client); | ||
80 | |||
81 | return true; | ||
82 | } | ||
83 | else | ||
84 | { | ||
85 | if (urlparts.Length < 3) | ||
86 | return false; | ||
87 | |||
88 | UUID sessionID; | ||
89 | if (!UUID.TryParse(urlparts[1], out sessionID)) | ||
90 | return false; | ||
91 | |||
92 | if (!m_clients.ContainsKey(sessionID)) | ||
93 | return false; | ||
94 | |||
95 | return m_clients[sessionID].ProcessInMsg(req, resp); | ||
96 | } | ||
60 | } | 97 | } |
61 | 98 | ||
62 | public bool Match(OSHttpRequest req, OSHttpResponse resp) | 99 | public bool Match(OSHttpRequest req, OSHttpResponse resp) |