aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs
diff options
context:
space:
mode:
authorMike Mazur2009-02-24 23:40:08 +0000
committerMike Mazur2009-02-24 23:40:08 +0000
commitd81fb565c1f48b013d107651c3bf383bd59e4daa (patch)
tree78b90903c6ee6dbce33f28b352d64e3b82fe3768 /OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs
parentClose-to-final tweaking with appearance. This time sending *everything*. Addr... (diff)
downloadopensim-SC_OLD-d81fb565c1f48b013d107651c3bf383bd59e4daa.zip
opensim-SC_OLD-d81fb565c1f48b013d107651c3bf383bd59e4daa.tar.gz
opensim-SC_OLD-d81fb565c1f48b013d107651c3bf383bd59e4daa.tar.bz2
opensim-SC_OLD-d81fb565c1f48b013d107651c3bf383bd59e4daa.tar.xz
Setting svn:eol-style=native on new files.
Diffstat (limited to 'OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs')
-rw-r--r--OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs426
1 files changed, 213 insertions, 213 deletions
diff --git a/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs b/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs
index f77ef4b..7b3edfb 100644
--- a/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs
+++ b/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs
@@ -1,213 +1,213 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
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 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Net; 31using System.Net;
32using System.Reflection; 32using System.Reflection;
33using System.Threading; 33using System.Threading;
34using System.Timers; 34using System.Timers;
35using log4net; 35using log4net;
36using Nwc.XmlRpc; 36using Nwc.XmlRpc;
37using OpenMetaverse; 37using OpenMetaverse;
38using OpenSim.Data; 38using OpenSim.Data;
39using OpenSim.Framework; 39using OpenSim.Framework;
40using OpenSim.Grid.Framework; 40using OpenSim.Grid.Framework;
41using Timer = System.Timers.Timer; 41using Timer = System.Timers.Timer;
42 42
43namespace OpenSim.Grid.MessagingServer.Modules 43namespace OpenSim.Grid.MessagingServer.Modules
44{ 44{
45 public class MessageRegionModule : IMessageRegionService 45 public class MessageRegionModule : IMessageRegionService
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private MessageServerConfig m_cfg; 49 private MessageServerConfig m_cfg;
50 50
51 private IMessageUserServerService m_userServerModule; 51 private IMessageUserServerService m_userServerModule;
52 52
53 private IUGAIMCore m_messageCore; 53 private IUGAIMCore m_messageCore;
54 54
55 // a dictionary of all current regions this server knows about 55 // a dictionary of all current regions this server knows about
56 private Dictionary<ulong, RegionProfileData> m_regionInfoCache = new Dictionary<ulong, RegionProfileData>(); 56 private Dictionary<ulong, RegionProfileData> m_regionInfoCache = new Dictionary<ulong, RegionProfileData>();
57 57
58 public MessageRegionModule(MessageServerConfig config, IUGAIMCore messageCore) 58 public MessageRegionModule(MessageServerConfig config, IUGAIMCore messageCore)
59 { 59 {
60 m_cfg = config; 60 m_cfg = config;
61 m_messageCore = messageCore; 61 m_messageCore = messageCore;
62 } 62 }
63 63
64 public void Initialise() 64 public void Initialise()
65 { 65 {
66 m_messageCore.RegisterInterface<IMessageRegionService>(this); 66 m_messageCore.RegisterInterface<IMessageRegionService>(this);
67 } 67 }
68 68
69 public void PostInitialise() 69 public void PostInitialise()
70 { 70 {
71 IMessageUserServerService messageUserServer; 71 IMessageUserServerService messageUserServer;
72 if (m_messageCore.TryGet<IMessageUserServerService>(out messageUserServer)) 72 if (m_messageCore.TryGet<IMessageUserServerService>(out messageUserServer))
73 { 73 {
74 m_userServerModule = messageUserServer; 74 m_userServerModule = messageUserServer;
75 } 75 }
76 } 76 }
77 77
78 public void RegisterHandlers() 78 public void RegisterHandlers()
79 { 79 {
80 //have these in separate method as some servers restart the http server and reregister all the handlers. 80 //have these in separate method as some servers restart the http server and reregister all the handlers.
81 81
82 } 82 }
83 83
84 /// <summary> 84 /// <summary>
85 /// Gets and caches a RegionInfo object from the gridserver based on regionhandle 85 /// Gets and caches a RegionInfo object from the gridserver based on regionhandle
86 /// if the regionhandle is already cached, use the cached values 86 /// if the regionhandle is already cached, use the cached values
87 /// Gets called by lots of threads!!!!! 87 /// Gets called by lots of threads!!!!!
88 /// </summary> 88 /// </summary>
89 /// <param name="regionhandle">handle to the XY of the region we're looking for</param> 89 /// <param name="regionhandle">handle to the XY of the region we're looking for</param>
90 /// <returns>A RegionInfo object to stick in the presence info</returns> 90 /// <returns>A RegionInfo object to stick in the presence info</returns>
91 public RegionProfileData GetRegionInfo(ulong regionhandle) 91 public RegionProfileData GetRegionInfo(ulong regionhandle)
92 { 92 {
93 RegionProfileData regionInfo = null; 93 RegionProfileData regionInfo = null;
94 94
95 lock (m_regionInfoCache) 95 lock (m_regionInfoCache)
96 { 96 {
97 m_regionInfoCache.TryGetValue(regionhandle, out regionInfo); 97 m_regionInfoCache.TryGetValue(regionhandle, out regionInfo);
98 } 98 }
99 99
100 if (regionInfo == null) // not found in cache 100 if (regionInfo == null) // not found in cache
101 { 101 {
102 regionInfo = RequestRegionInfo(regionhandle); 102 regionInfo = RequestRegionInfo(regionhandle);
103 103
104 if (regionInfo != null) // lookup was successful 104 if (regionInfo != null) // lookup was successful
105 { 105 {
106 lock (m_regionInfoCache) 106 lock (m_regionInfoCache)
107 { 107 {
108 m_regionInfoCache[regionhandle] = regionInfo; 108 m_regionInfoCache[regionhandle] = regionInfo;
109 } 109 }
110 } 110 }
111 } 111 }
112 112
113 return regionInfo; 113 return regionInfo;
114 } 114 }
115 115
116 public int ClearRegionCache() 116 public int ClearRegionCache()
117 { 117 {
118 int cachecount = 0; 118 int cachecount = 0;
119 119
120 lock (m_regionInfoCache) 120 lock (m_regionInfoCache)
121 { 121 {
122 cachecount = m_regionInfoCache.Count; 122 cachecount = m_regionInfoCache.Count;
123 m_regionInfoCache.Clear(); 123 m_regionInfoCache.Clear();
124 } 124 }
125 125
126 return cachecount; 126 return cachecount;
127 } 127 }
128 128
129 /// <summary> 129 /// <summary>
130 /// Get RegionProfileData from the GridServer. 130 /// Get RegionProfileData from the GridServer.
131 /// We'll cache this information in GetRegionInfo and use it for presence updates 131 /// We'll cache this information in GetRegionInfo and use it for presence updates
132 /// </summary> 132 /// </summary>
133 /// <param name="regionHandle"></param> 133 /// <param name="regionHandle"></param>
134 /// <returns></returns> 134 /// <returns></returns>
135 public RegionProfileData RequestRegionInfo(ulong regionHandle) 135 public RegionProfileData RequestRegionInfo(ulong regionHandle)
136 { 136 {
137 RegionProfileData regionProfile = null; 137 RegionProfileData regionProfile = null;
138 try 138 try
139 { 139 {
140 Hashtable requestData = new Hashtable(); 140 Hashtable requestData = new Hashtable();
141 requestData["region_handle"] = regionHandle.ToString(); 141 requestData["region_handle"] = regionHandle.ToString();
142 requestData["authkey"] = m_cfg.GridSendKey; 142 requestData["authkey"] = m_cfg.GridSendKey;
143 143
144 ArrayList SendParams = new ArrayList(); 144 ArrayList SendParams = new ArrayList();
145 SendParams.Add(requestData); 145 SendParams.Add(requestData);
146 146
147 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); 147 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
148 148
149 XmlRpcResponse GridResp = GridReq.Send(m_cfg.GridServerURL, 3000); 149 XmlRpcResponse GridResp = GridReq.Send(m_cfg.GridServerURL, 3000);
150 150
151 Hashtable responseData = (Hashtable)GridResp.Value; 151 Hashtable responseData = (Hashtable)GridResp.Value;
152 152
153 if (responseData.ContainsKey("error")) 153 if (responseData.ContainsKey("error"))
154 { 154 {
155 m_log.Error("[GRID]: error received from grid server" + responseData["error"]); 155 m_log.Error("[GRID]: error received from grid server" + responseData["error"]);
156 return null; 156 return null;
157 } 157 }
158 158
159 uint regX = Convert.ToUInt32((string)responseData["region_locx"]); 159 uint regX = Convert.ToUInt32((string)responseData["region_locx"]);
160 uint regY = Convert.ToUInt32((string)responseData["region_locy"]); 160 uint regY = Convert.ToUInt32((string)responseData["region_locy"]);
161 string internalIpStr = (string)responseData["sim_ip"]; 161 string internalIpStr = (string)responseData["sim_ip"];
162 162
163 regionProfile = new RegionProfileData(); 163 regionProfile = new RegionProfileData();
164 regionProfile.httpPort = (uint)Convert.ToInt32((string)responseData["http_port"]); 164 regionProfile.httpPort = (uint)Convert.ToInt32((string)responseData["http_port"]);
165 regionProfile.httpServerURI = "http://" + internalIpStr + ":" + regionProfile.httpPort + "/"; 165 regionProfile.httpServerURI = "http://" + internalIpStr + ":" + regionProfile.httpPort + "/";
166 regionProfile.regionHandle = Utils.UIntsToLong((regX * Constants.RegionSize), (regY * Constants.RegionSize)); 166 regionProfile.regionHandle = Utils.UIntsToLong((regX * Constants.RegionSize), (regY * Constants.RegionSize));
167 regionProfile.regionLocX = regX; 167 regionProfile.regionLocX = regX;
168 regionProfile.regionLocY = regY; 168 regionProfile.regionLocY = regY;
169 169
170 regionProfile.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); 170 regionProfile.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
171 regionProfile.UUID = new UUID((string)responseData["region_UUID"]); 171 regionProfile.UUID = new UUID((string)responseData["region_UUID"]);
172 regionProfile.regionName = (string)responseData["region_name"]; 172 regionProfile.regionName = (string)responseData["region_name"];
173 } 173 }
174 catch (WebException) 174 catch (WebException)
175 { 175 {
176 m_log.Error("[GRID]: " + 176 m_log.Error("[GRID]: " +
177 "Region lookup failed for: " + regionHandle.ToString() + 177 "Region lookup failed for: " + regionHandle.ToString() +
178 " - Is the GridServer down?"); 178 " - Is the GridServer down?");
179 } 179 }
180 180
181 return regionProfile; 181 return regionProfile;
182 } 182 }
183 183
184 public XmlRpcResponse RegionStartup(XmlRpcRequest request) 184 public XmlRpcResponse RegionStartup(XmlRpcRequest request)
185 { 185 {
186 Hashtable requestData = (Hashtable)request.Params[0]; 186 Hashtable requestData = (Hashtable)request.Params[0];
187 Hashtable result = new Hashtable(); 187 Hashtable result = new Hashtable();
188 result["success"] = "FALSE"; 188 result["success"] = "FALSE";
189 189
190 if (m_userServerModule.SendToUserServer(requestData, "region_startup")) 190 if (m_userServerModule.SendToUserServer(requestData, "region_startup"))
191 result["success"] = "TRUE"; 191 result["success"] = "TRUE";
192 192
193 XmlRpcResponse response = new XmlRpcResponse(); 193 XmlRpcResponse response = new XmlRpcResponse();
194 response.Value = result; 194 response.Value = result;
195 return response; 195 return response;
196 } 196 }
197 197
198 public XmlRpcResponse RegionShutdown(XmlRpcRequest request) 198 public XmlRpcResponse RegionShutdown(XmlRpcRequest request)
199 { 199 {
200 Hashtable requestData = (Hashtable)request.Params[0]; 200 Hashtable requestData = (Hashtable)request.Params[0];
201 Hashtable result = new Hashtable(); 201 Hashtable result = new Hashtable();
202 result["success"] = "FALSE"; 202 result["success"] = "FALSE";
203 203
204 if (m_userServerModule.SendToUserServer(requestData, "region_shutdown")) 204 if (m_userServerModule.SendToUserServer(requestData, "region_shutdown"))
205 result["success"] = "TRUE"; 205 result["success"] = "TRUE";
206 206
207 XmlRpcResponse response = new XmlRpcResponse(); 207 XmlRpcResponse response = new XmlRpcResponse();
208 response.Value = result; 208 response.Value = result;
209 return response; 209 return response;
210 } 210 }
211 211
212 } 212 }
213} 213}