aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorDiva Canto2012-11-09 20:39:55 -0800
committerDiva Canto2012-11-09 20:39:55 -0800
commit4f9825961743684dfb76827e2353497182a83d8a (patch)
treefa6def433016c66525f2a2b2c0c0b21c98d50f1c /OpenSim/Region
parentMapSearchModule also converted to new region module interface (37 to go). (diff)
downloadopensim-SC_OLD-4f9825961743684dfb76827e2353497182a83d8a.zip
opensim-SC_OLD-4f9825961743684dfb76827e2353497182a83d8a.tar.gz
opensim-SC_OLD-4f9825961743684dfb76827e2353497182a83d8a.tar.bz2
opensim-SC_OLD-4f9825961743684dfb76827e2353497182a83d8a.tar.xz
Minor improvement in the MapSearchModule. Stop blocking the client thread if the search takes too long.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs74
1 files changed, 55 insertions, 19 deletions
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index 7de1bb2..8f1a35d 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -45,6 +45,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
45 45
46 Scene m_scene = null; // only need one for communication with GridService 46 Scene m_scene = null; // only need one for communication with GridService
47 List<Scene> m_scenes = new List<Scene>(); 47 List<Scene> m_scenes = new List<Scene>();
48 List<UUID> m_Clients;
48 49
49 #region ISharedRegionModule Members 50 #region ISharedRegionModule Members
50 public void Initialise(IConfigSource source) 51 public void Initialise(IConfigSource source)
@@ -60,6 +61,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
60 61
61 m_scenes.Add(scene); 62 m_scenes.Add(scene);
62 scene.EventManager.OnNewClient += OnNewClient; 63 scene.EventManager.OnNewClient += OnNewClient;
64 m_Clients = new List<UUID>();
63 } 65 }
64 66
65 public void RemoveRegion(Scene scene) 67 public void RemoveRegion(Scene scene)
@@ -98,17 +100,51 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
98 100
99 private void OnNewClient(IClientAPI client) 101 private void OnNewClient(IClientAPI client)
100 { 102 {
101 client.OnMapNameRequest += OnMapNameRequest; 103 client.OnMapNameRequest += OnMapNameRequestHandler;
104 }
105
106 private void OnMapNameRequestHandler(IClientAPI remoteClient, string mapName, uint flags)
107 {
108 lock (m_Clients)
109 {
110 if (m_Clients.Contains(remoteClient.AgentId))
111 return;
112
113 m_Clients.Add(remoteClient.AgentId);
114 }
115
116 Util.FireAndForget(delegate
117 {
118 try
119 {
120 OnMapNameRequest(remoteClient, mapName, flags);
121 }
122 finally
123 {
124 lock (m_Clients)
125 m_Clients.Remove(remoteClient.AgentId);
126 }
127 });
128
102 } 129 }
103 130
104 private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) 131 private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags)
105 { 132 {
106 if (mapName.Length < 3) 133 List<MapBlockData> blocks = new List<MapBlockData>();
134 MapBlockData data;
135 if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4))
107 { 136 {
137 // final block, closing the search result
138 AddFinalBlock(blocks);
139
140 // flags are agent flags sent from the viewer.
141 // they have different values depending on different viewers, apparently
142 remoteClient.SendMapBlock(blocks, flags);
108 remoteClient.SendAlertMessage("Use a search string with at least 3 characters"); 143 remoteClient.SendAlertMessage("Use a search string with at least 3 characters");
109 return; 144 return;
110 } 145 }
111 146
147
112 //m_log.DebugFormat("MAP NAME=({0})", mapName); 148 //m_log.DebugFormat("MAP NAME=({0})", mapName);
113 149
114 // Hack to get around the fact that ll V3 now drops the port from the 150 // Hack to get around the fact that ll V3 now drops the port from the
@@ -129,13 +165,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
129 165
130 // try to fetch from GridServer 166 // try to fetch from GridServer
131 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); 167 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20);
132 if (regionInfos.Count == 0)
133 remoteClient.SendAlertMessage("Hyperlink could not be established.");
134 168
135 m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags); 169 m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags);
136 List<MapBlockData> blocks = new List<MapBlockData>();
137
138 MapBlockData data;
139 if (regionInfos.Count > 0) 170 if (regionInfos.Count > 0)
140 { 171 {
141 foreach (GridRegion info in regionInfos) 172 foreach (GridRegion info in regionInfos)
@@ -162,16 +193,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
162 } 193 }
163 194
164 // final block, closing the search result 195 // final block, closing the search result
165 data = new MapBlockData(); 196 AddFinalBlock(blocks);
166 data.Agents = 0;
167 data.Access = 255;
168 data.MapImageId = UUID.Zero;
169 data.Name = ""; // mapName;
170 data.RegionFlags = 0;
171 data.WaterHeight = 0; // not used
172 data.X = 0;
173 data.Y = 0;
174 blocks.Add(data);
175 197
176 // flags are agent flags sent from the viewer. 198 // flags are agent flags sent from the viewer.
177 // they have different values depending on different viewers, apparently 199 // they have different values depending on different viewers, apparently
@@ -183,12 +205,26 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
183 if (flags == 2) 205 if (flags == 2)
184 { 206 {
185 if (regionInfos.Count == 0) 207 if (regionInfos.Count == 0)
186 remoteClient.SendAgentAlertMessage("No regions found with that name.", true); 208 remoteClient.SendAlertMessage("No regions found with that name.");
187 else if (regionInfos.Count == 1) 209 else if (regionInfos.Count == 1)
188 remoteClient.SendAgentAlertMessage("Region found!", false); 210 remoteClient.SendAlertMessage("Region found!");
189 } 211 }
190 } 212 }
191 213
214 private void AddFinalBlock(List<MapBlockData> blocks)
215 {
216 // final block, closing the search result
217 MapBlockData data = new MapBlockData();
218 data.Agents = 0;
219 data.Access = 255;
220 data.MapImageId = UUID.Zero;
221 data.Name = "";
222 data.RegionFlags = 0;
223 data.WaterHeight = 0; // not used
224 data.X = 0;
225 data.Y = 0;
226 blocks.Add(data);
227 }
192// private Scene GetClientScene(IClientAPI client) 228// private Scene GetClientScene(IClientAPI client)
193// { 229// {
194// foreach (Scene s in m_scenes) 230// foreach (Scene s in m_scenes)