diff options
author | diva | 2009-03-21 18:03:44 +0000 |
---|---|---|
committer | diva | 2009-03-21 18:03:44 +0000 |
commit | b0f2bcbe79489ec99689cddbb5cbeebeb9f59009 (patch) | |
tree | e42521b5ad7b76e7da0207c2f096ac4f8e67b371 | |
parent | Add a QueryItem method to the inventory subsystem. Currently implemented for (diff) | |
download | opensim-SC_OLD-b0f2bcbe79489ec99689cddbb5cbeebeb9f59009.zip opensim-SC_OLD-b0f2bcbe79489ec99689cddbb5cbeebeb9f59009.tar.gz opensim-SC_OLD-b0f2bcbe79489ec99689cddbb5cbeebeb9f59009.tar.bz2 opensim-SC_OLD-b0f2bcbe79489ec99689cddbb5cbeebeb9f59009.tar.xz |
Moving HGStandaloneAssetService to a new place, and giving it a more generic name. MXP is going to use it too.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/Services/RegionAssetService.cs (renamed from OpenSim/Region/CoreModules/Hypergrid/HGStandaloneAssetService.cs) | 392 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs | 208 |
2 files changed, 404 insertions, 196 deletions
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneAssetService.cs b/OpenSim/Region/CoreModules/Framework/Services/RegionAssetService.cs index 4baefc4..629c9c0 100644 --- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneAssetService.cs +++ b/OpenSim/Region/CoreModules/Framework/Services/RegionAssetService.cs | |||
@@ -1,196 +1,196 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (c) 2008, Contributors. All rights reserved. | 2 | * Copyright (c) 2008, Contributors. All rights reserved. |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without modification, | 5 | * Redistribution and use in source and binary forms, with or without modification, |
6 | * are permitted provided that the following conditions are met: | 6 | * are permitted provided that the following conditions are met: |
7 | * | 7 | * |
8 | * * Redistributions of source code must retain the above copyright notice, | 8 | * * Redistributions of source code must retain the above copyright notice, |
9 | * this list of conditions and the following disclaimer. | 9 | * this list of conditions and the following disclaimer. |
10 | * * Redistributions in binary form must reproduce the above copyright notice, | 10 | * * Redistributions in binary form must reproduce the above copyright notice, |
11 | * this list of conditions and the following disclaimer in the documentation | 11 | * this list of conditions and the following disclaimer in the documentation |
12 | * and/or other materials provided with the distribution. | 12 | * and/or other materials provided with the distribution. |
13 | * * Neither the name of the Organizations nor the names of Individual | 13 | * * Neither the name of the Organizations nor the names of Individual |
14 | * Contributors may be used to endorse or promote products derived from | 14 | * Contributors may be used to endorse or promote products derived from |
15 | * this software without specific prior written permission. | 15 | * this software without specific prior written permission. |
16 | * | 16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
25 | * OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using log4net; | 30 | using log4net; |
31 | using Nini.Config; | 31 | using Nini.Config; |
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Data; | 33 | using OpenSim.Data; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
36 | using OpenSim.Framework.Communications.Cache; | 36 | using OpenSim.Framework.Communications.Cache; |
37 | using OpenSim.Framework.Servers; | 37 | using OpenSim.Framework.Servers; |
38 | using OpenSim.Framework.Servers.Interfaces; | 38 | using OpenSim.Framework.Servers.Interfaces; |
39 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
40 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
41 | 41 | ||
42 | namespace OpenSim.Region.CoreModules.Hypergrid | 42 | namespace OpenSim.Region.CoreModules.Framework.Services |
43 | { | 43 | { |
44 | public class HGStandaloneAssetService : IRegionModule | 44 | public class RegionAssetService : IRegionModule |
45 | { | 45 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | private static bool initialized = false; | 47 | private static bool initialized = false; |
48 | private static bool enabled = false; | 48 | private static bool enabled = false; |
49 | 49 | ||
50 | Scene m_scene; | 50 | Scene m_scene; |
51 | //AssetService m_assetService; | 51 | //AssetService m_assetService; |
52 | 52 | ||
53 | #region IRegionModule interface | 53 | #region IRegionModule interface |
54 | 54 | ||
55 | public void Initialise(Scene scene, IConfigSource config) | 55 | public void Initialise(Scene scene, IConfigSource config) |
56 | { | 56 | { |
57 | if (!initialized) | 57 | if (!initialized) |
58 | { | 58 | { |
59 | initialized = true; | 59 | initialized = true; |
60 | m_scene = scene; | 60 | m_scene = scene; |
61 | 61 | ||
62 | // This module is only on for standalones in hypergrid mode | 62 | // This module is only on for standalones in hypergrid mode |
63 | enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); | 63 | enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | public void PostInitialise() | 67 | public void PostInitialise() |
68 | { | 68 | { |
69 | if (enabled) | 69 | if (enabled) |
70 | { | 70 | { |
71 | m_log.Info("[HGStandaloneAssetService]: Starting..."); | 71 | m_log.Info("[HGStandaloneAssetService]: Starting..."); |
72 | 72 | ||
73 | //m_assetService = new AssetService(m_scene); | 73 | //m_assetService = new AssetService(m_scene); |
74 | new AssetService(m_scene); | 74 | new AssetService(m_scene); |
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | public void Close() | 78 | public void Close() |
79 | { | 79 | { |
80 | } | 80 | } |
81 | 81 | ||
82 | public string Name | 82 | public string Name |
83 | { | 83 | { |
84 | get { return "HGStandaloneAssetService"; } | 84 | get { return "HGStandaloneAssetService"; } |
85 | } | 85 | } |
86 | 86 | ||
87 | public bool IsSharedModule | 87 | public bool IsSharedModule |
88 | { | 88 | { |
89 | get { return true; } | 89 | get { return true; } |
90 | } | 90 | } |
91 | 91 | ||
92 | #endregion | 92 | #endregion |
93 | 93 | ||
94 | } | 94 | } |
95 | 95 | ||
96 | public class AssetService | 96 | public class AssetService |
97 | { | 97 | { |
98 | private IUserService m_userService; | 98 | private IUserService m_userService; |
99 | private bool m_doLookup = false; | 99 | private bool m_doLookup = false; |
100 | 100 | ||
101 | public bool DoLookup | 101 | public bool DoLookup |
102 | { | 102 | { |
103 | get { return m_doLookup; } | 103 | get { return m_doLookup; } |
104 | set { m_doLookup = value; } | 104 | set { m_doLookup = value; } |
105 | } | 105 | } |
106 | private static readonly ILog m_log | 106 | private static readonly ILog m_log |
107 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 107 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
108 | 108 | ||
109 | public AssetService(Scene m_scene) | 109 | public AssetService(Scene m_scene) |
110 | { | 110 | { |
111 | AddHttpHandlers(m_scene); | 111 | AddHttpHandlers(m_scene); |
112 | m_userService = m_scene.CommsManager.UserService; | 112 | m_userService = m_scene.CommsManager.UserService; |
113 | } | 113 | } |
114 | 114 | ||
115 | protected void AddHttpHandlers(Scene m_scene) | 115 | protected void AddHttpHandlers(Scene m_scene) |
116 | { | 116 | { |
117 | IAssetDataPlugin m_assetProvider | 117 | IAssetDataPlugin m_assetProvider |
118 | = ((AssetServerBase)m_scene.CommsManager.AssetCache.AssetServer).AssetProviderPlugin; | 118 | = ((AssetServerBase)m_scene.CommsManager.AssetCache.AssetServer).AssetProviderPlugin; |
119 | 119 | ||
120 | IHttpServer httpServer = m_scene.CommsManager.HttpServer; | 120 | IHttpServer httpServer = m_scene.CommsManager.HttpServer; |
121 | httpServer.AddStreamHandler(new GetAssetStreamHandler(m_assetProvider)); | 121 | httpServer.AddStreamHandler(new GetAssetStreamHandler(m_assetProvider)); |
122 | httpServer.AddStreamHandler(new PostAssetStreamHandler(m_assetProvider)); | 122 | httpServer.AddStreamHandler(new PostAssetStreamHandler(m_assetProvider)); |
123 | 123 | ||
124 | } | 124 | } |
125 | 125 | ||
126 | ///// <summary> | 126 | ///// <summary> |
127 | ///// Check that the source of an inventory request is one that we trust. | 127 | ///// Check that the source of an inventory request is one that we trust. |
128 | ///// </summary> | 128 | ///// </summary> |
129 | ///// <param name="peer"></param> | 129 | ///// <param name="peer"></param> |
130 | ///// <returns></returns> | 130 | ///// <returns></returns> |
131 | //public bool CheckTrustSource(IPEndPoint peer) | 131 | //public bool CheckTrustSource(IPEndPoint peer) |
132 | //{ | 132 | //{ |
133 | // if (m_doLookup) | 133 | // if (m_doLookup) |
134 | // { | 134 | // { |
135 | // m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer); | 135 | // m_log.InfoFormat("[GRID AGENT INVENTORY]: Checking trusted source {0}", peer); |
136 | // UriBuilder ub = new UriBuilder(m_userserver_url); | 136 | // UriBuilder ub = new UriBuilder(m_userserver_url); |
137 | // IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); | 137 | // IPAddress[] uaddrs = Dns.GetHostAddresses(ub.Host); |
138 | // foreach (IPAddress uaddr in uaddrs) | 138 | // foreach (IPAddress uaddr in uaddrs) |
139 | // { | 139 | // { |
140 | // if (uaddr.Equals(peer.Address)) | 140 | // if (uaddr.Equals(peer.Address)) |
141 | // { | 141 | // { |
142 | // return true; | 142 | // return true; |
143 | // } | 143 | // } |
144 | // } | 144 | // } |
145 | 145 | ||
146 | // m_log.WarnFormat( | 146 | // m_log.WarnFormat( |
147 | // "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources", | 147 | // "[GRID AGENT INVENTORY]: Rejecting request since source {0} was not in the list of trusted sources", |
148 | // peer); | 148 | // peer); |
149 | 149 | ||
150 | // return false; | 150 | // return false; |
151 | // } | 151 | // } |
152 | // else | 152 | // else |
153 | // { | 153 | // { |
154 | // return true; | 154 | // return true; |
155 | // } | 155 | // } |
156 | //} | 156 | //} |
157 | 157 | ||
158 | /// <summary> | 158 | /// <summary> |
159 | /// Check that the source of an inventory request for a particular agent is a current session belonging to | 159 | /// Check that the source of an inventory request for a particular agent is a current session belonging to |
160 | /// that agent. | 160 | /// that agent. |
161 | /// </summary> | 161 | /// </summary> |
162 | /// <param name="session_id"></param> | 162 | /// <param name="session_id"></param> |
163 | /// <param name="avatar_id"></param> | 163 | /// <param name="avatar_id"></param> |
164 | /// <returns></returns> | 164 | /// <returns></returns> |
165 | public bool CheckAuthSession(string session_id, string avatar_id) | 165 | public bool CheckAuthSession(string session_id, string avatar_id) |
166 | { | 166 | { |
167 | if (m_doLookup) | 167 | if (m_doLookup) |
168 | { | 168 | { |
169 | m_log.InfoFormat("[HGStandaloneInvService]: checking authed session {0} {1}", session_id, avatar_id); | 169 | m_log.InfoFormat("[HGStandaloneInvService]: checking authed session {0} {1}", session_id, avatar_id); |
170 | UUID userID = UUID.Zero; | 170 | UUID userID = UUID.Zero; |
171 | UUID sessionID = UUID.Zero; | 171 | UUID sessionID = UUID.Zero; |
172 | UUID.TryParse(avatar_id, out userID); | 172 | UUID.TryParse(avatar_id, out userID); |
173 | UUID.TryParse(session_id, out sessionID); | 173 | UUID.TryParse(session_id, out sessionID); |
174 | if (userID.Equals(UUID.Zero) || sessionID.Equals(UUID.Zero)) | 174 | if (userID.Equals(UUID.Zero) || sessionID.Equals(UUID.Zero)) |
175 | { | 175 | { |
176 | m_log.Info("[HGStandaloneInvService]: Invalid user or session id " + avatar_id + "; " + session_id); | 176 | m_log.Info("[HGStandaloneInvService]: Invalid user or session id " + avatar_id + "; " + session_id); |
177 | return false; | 177 | return false; |
178 | } | 178 | } |
179 | UserProfileData userProfile = m_userService.GetUserProfile(userID); | 179 | UserProfileData userProfile = m_userService.GetUserProfile(userID); |
180 | if (userProfile != null && userProfile.CurrentAgent != null && | 180 | if (userProfile != null && userProfile.CurrentAgent != null && |
181 | userProfile.CurrentAgent.SessionID == sessionID) | 181 | userProfile.CurrentAgent.SessionID == sessionID) |
182 | { | 182 | { |
183 | m_log.Info("[HGStandaloneInvService]: user is logged in and session is valid. Authorizing access."); | 183 | m_log.Info("[HGStandaloneInvService]: user is logged in and session is valid. Authorizing access."); |
184 | return true; | 184 | return true; |
185 | } | 185 | } |
186 | 186 | ||
187 | m_log.Warn("[HGStandaloneInvService]: unknown user or session_id, request rejected"); | 187 | m_log.Warn("[HGStandaloneInvService]: unknown user or session_id, request rejected"); |
188 | return false; | 188 | return false; |
189 | } | 189 | } |
190 | else | 190 | else |
191 | { | 191 | { |
192 | return true; | 192 | return true; |
193 | } | 193 | } |
194 | } | 194 | } |
195 | } | 195 | } |
196 | } | 196 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs b/OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs new file mode 100644 index 0000000..cc87459 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs | |||
@@ -0,0 +1,208 @@ | |||
1 | /** | ||
2 | * Copyright (c) 2008, Contributors. All rights reserved. | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without modification, | ||
6 | * are permitted provided that the following conditions are met: | ||
7 | * | ||
8 | * * Redistributions of source code must retain the above copyright notice, | ||
9 | * this list of conditions and the following disclaimer. | ||
10 | * * Redistributions in binary form must reproduce the above copyright notice, | ||
11 | * this list of conditions and the following disclaimer in the documentation | ||
12 | * and/or other materials provided with the distribution. | ||
13 | * * Neither the name of the Organizations nor the names of Individual | ||
14 | * Contributors may be used to endorse or promote products derived from | ||
15 | * this software without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
25 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | using System; | ||
30 | using System.Collections; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Reflection; | ||
33 | using log4net; | ||
34 | using Nini.Config; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Data; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Communications; | ||
39 | using OpenSim.Framework.Communications.Cache; | ||
40 | using OpenSim.Framework.Servers.Interfaces; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | |||
44 | using Nwc.XmlRpc; | ||
45 | |||
46 | |||
47 | namespace OpenSim.Region.CoreModules.Framework.Services | ||
48 | { | ||
49 | public class RegionMapService : IRegionModule | ||
50 | { | ||
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | private static bool initialized = false; | ||
53 | private static bool enabled = false; | ||
54 | |||
55 | Scene m_scene; | ||
56 | //AssetService m_assetService; | ||
57 | |||
58 | #region IRegionModule interface | ||
59 | |||
60 | public void Initialise(Scene scene, IConfigSource config) | ||
61 | { | ||
62 | if (!initialized) | ||
63 | { | ||
64 | initialized = true; | ||
65 | m_scene = scene; | ||
66 | |||
67 | // This module is only on for standalones in hypergrid mode | ||
68 | enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); | ||
69 | } | ||
70 | } | ||
71 | |||
72 | public void PostInitialise() | ||
73 | { | ||
74 | if (enabled) | ||
75 | { | ||
76 | m_log.Info("[HGStandaloneGridService]: Starting..."); | ||
77 | |||
78 | //m_assetService = new AssetService(m_scene); | ||
79 | new GridService(m_scene); | ||
80 | } | ||
81 | } | ||
82 | |||
83 | public void Close() | ||
84 | { | ||
85 | } | ||
86 | |||
87 | public string Name | ||
88 | { | ||
89 | get { return "HGStandaloneGridService"; } | ||
90 | } | ||
91 | |||
92 | public bool IsSharedModule | ||
93 | { | ||
94 | get { return true; } | ||
95 | } | ||
96 | |||
97 | #endregion | ||
98 | |||
99 | } | ||
100 | |||
101 | public class GridService | ||
102 | { | ||
103 | private IUserService m_userService; | ||
104 | private IGridServices m_gridService; | ||
105 | private bool m_doLookup = false; | ||
106 | |||
107 | public bool DoLookup | ||
108 | { | ||
109 | get { return m_doLookup; } | ||
110 | set { m_doLookup = value; } | ||
111 | } | ||
112 | private static readonly ILog m_log | ||
113 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
114 | |||
115 | public GridService(Scene m_scene) | ||
116 | { | ||
117 | AddHandlers(m_scene); | ||
118 | m_userService = m_scene.CommsManager.UserService; | ||
119 | m_gridService = m_scene.CommsManager.GridService; | ||
120 | } | ||
121 | |||
122 | protected void AddHandlers(Scene m_scene) | ||
123 | { | ||
124 | IAssetDataPlugin m_assetProvider | ||
125 | = ((AssetServerBase)m_scene.CommsManager.AssetCache.AssetServer).AssetProviderPlugin; | ||
126 | |||
127 | IHttpServer httpServer = m_scene.CommsManager.HttpServer; | ||
128 | httpServer.AddXmlRPCHandler("simulator_data_request", XmlRpcSimulatorDataRequestMethod); | ||
129 | //m_httpServer.AddXmlRPCHandler("map_block", XmlRpcMapBlockMethod); | ||
130 | //m_httpServer.AddXmlRPCHandler("search_for_region_by_name", XmlRpcSearchForRegionMethod); | ||
131 | |||
132 | } | ||
133 | |||
134 | /// <summary> | ||
135 | /// Returns an XML RPC response to a simulator profile request | ||
136 | /// </summary> | ||
137 | /// <param name="request"></param> | ||
138 | /// <returns></returns> | ||
139 | public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request) | ||
140 | { | ||
141 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
142 | Hashtable responseData = new Hashtable(); | ||
143 | RegionInfo simData = null; | ||
144 | if (requestData.ContainsKey("region_UUID")) | ||
145 | { | ||
146 | UUID regionID = new UUID((string)requestData["region_UUID"]); | ||
147 | simData = m_gridService.RequestNeighbourInfo(regionID); //.GetRegion(regionID); | ||
148 | if (simData == null) | ||
149 | { | ||
150 | m_log.WarnFormat("[HGGridService] didn't find region for regionID {0} from {1}", | ||
151 | regionID, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); | ||
152 | } | ||
153 | } | ||
154 | else if (requestData.ContainsKey("region_handle")) | ||
155 | { | ||
156 | //CFK: The if/else below this makes this message redundant. | ||
157 | //CFK: m_log.Info("requesting data for region " + (string) requestData["region_handle"]); | ||
158 | ulong regionHandle = Convert.ToUInt64((string)requestData["region_handle"]); | ||
159 | simData = m_gridService.RequestNeighbourInfo(regionHandle); //m_gridDBService.GetRegion(regionHandle); | ||
160 | if (simData == null) | ||
161 | { | ||
162 | m_log.WarnFormat("[HGGridService] didn't find region for regionHandle {0} from {1}", | ||
163 | regionHandle, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); | ||
164 | } | ||
165 | } | ||
166 | else if (requestData.ContainsKey("region_name_search")) | ||
167 | { | ||
168 | string regionName = (string)requestData["region_name_search"]; | ||
169 | List<RegionInfo> regInfos = m_gridService.RequestNamedRegions(regionName, 1);//m_gridDBService.GetRegion(regionName); | ||
170 | if (regInfos != null) | ||
171 | simData = regInfos[0]; | ||
172 | |||
173 | if (simData == null) | ||
174 | { | ||
175 | m_log.WarnFormat("[HGGridService] didn't find region for regionName {0} from {1}", | ||
176 | regionName, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); | ||
177 | } | ||
178 | } | ||
179 | else m_log.Warn("[HGGridService] regionlookup without regionID, regionHandle or regionHame"); | ||
180 | |||
181 | if (simData == null) | ||
182 | { | ||
183 | //Sim does not exist | ||
184 | responseData["error"] = "Sim does not exist"; | ||
185 | } | ||
186 | else | ||
187 | { | ||
188 | m_log.Debug("[HGGridService]: found " + (string)simData.RegionName + " regionHandle = " + | ||
189 | (string)requestData["region_handle"]); | ||
190 | responseData["sim_ip"] = simData.ExternalEndPoint.Address.ToString(); | ||
191 | responseData["sim_port"] = simData.ExternalEndPoint.Port.ToString(); | ||
192 | //responseData["server_uri"] = simData.serverURI; | ||
193 | responseData["http_port"] = simData.HttpPort.ToString(); | ||
194 | //responseData["remoting_port"] = simData.remotingPort.ToString(); | ||
195 | responseData["region_locx"] = simData.RegionLocX.ToString(); | ||
196 | responseData["region_locy"] = simData.RegionLocY.ToString(); | ||
197 | responseData["region_UUID"] = simData.RegionID.ToString(); | ||
198 | responseData["region_name"] = simData.RegionName; | ||
199 | responseData["region_secret"] = simData.regionSecret; | ||
200 | } | ||
201 | |||
202 | XmlRpcResponse response = new XmlRpcResponse(); | ||
203 | response.Value = responseData; | ||
204 | return response; | ||
205 | } | ||
206 | |||
207 | } | ||
208 | } | ||