aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs117
1 files changed, 44 insertions, 73 deletions
diff --git a/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs b/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs
index ebc9871..d7b99b2 100644
--- a/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs
+++ b/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs
@@ -91,6 +91,8 @@ namespace OpenSim.Region.Environment.Modules.Framework
91 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; 91 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
92 scene.EventManager.OnMakeChildAgent += MakeChildAgent; 92 scene.EventManager.OnMakeChildAgent += MakeChildAgent;
93 scene.EventManager.OnRegisterCaps += OnRegisterCaps; 93 scene.EventManager.OnRegisterCaps += OnRegisterCaps;
94
95 m_log.DebugFormat("[EVENTQUEUE]: Enabled EventQueueGetModule for region {0}", scene.RegionInfo.RegionName);
94 } 96 }
95 else 97 else
96 { 98 {
@@ -171,7 +173,7 @@ namespace OpenSim.Region.Environment.Modules.Framework
171 173
172 private void MakeChildAgent(ScenePresence avatar) 174 private void MakeChildAgent(ScenePresence avatar)
173 { 175 {
174 m_log.DebugFormat("[EVENTQUEUE]: Make Child agent {0}.", avatar.UUID); 176 m_log.DebugFormat("[EVENTQUEUE]: Make Child agent {0} in region {1}.", avatar.UUID, m_scene.RegionInfo.RegionName);
175 lock (m_ids) 177 lock (m_ids)
176 { 178 {
177 if (m_ids.ContainsKey(avatar.UUID)) 179 if (m_ids.ContainsKey(avatar.UUID))
@@ -184,7 +186,7 @@ namespace OpenSim.Region.Environment.Modules.Framework
184 186
185 public void OnRegisterCaps(UUID agentID, Caps caps) 187 public void OnRegisterCaps(UUID agentID, Caps caps)
186 { 188 {
187 m_log.DebugFormat("[EVENTQUEUE] OnRegisterCaps: agentID {0} caps {1} region", agentID, caps, m_scene.RegionInfo.RegionName); 189 m_log.DebugFormat("[EVENTQUEUE] OnRegisterCaps: agentID {0} caps {1} region {2}", agentID, caps, m_scene.RegionInfo.RegionName);
188 string capsBase = "/CAPS/"; 190 string capsBase = "/CAPS/";
189 caps.RegisterHandler("EventQueueGet", 191 caps.RegisterHandler("EventQueueGet",
190 new RestHTTPHandler("POST", capsBase + UUID.Random().ToString(), 192 new RestHTTPHandler("POST", capsBase + UUID.Random().ToString(),
@@ -208,97 +210,66 @@ namespace OpenSim.Region.Environment.Modules.Framework
208 // TODO: this has to be redone to not busy-wait (and block the thread), 210 // TODO: this has to be redone to not busy-wait (and block the thread),
209 // TODO: as soon as we have a non-blocking way to handle HTTP-requests. 211 // TODO: as soon as we have a non-blocking way to handle HTTP-requests.
210 212
213 if(m_log.IsDebugEnabled) {
214 String debug = "[EVENTQUEUE]: Got request for agent {0} in region {1} from thread {2}: [ ";
215 foreach (object key in request.Keys)
216 {
217 debug += key.ToString() + "=" + request[key].ToString() + " ";
218 }
219 m_log.DebugFormat(debug + " ]", agentID, m_scene.RegionInfo.RegionName, System.Threading.Thread.CurrentThread.Name);
220 }
221
211 BlockingLLSDQueue queue = GetQueue(agentID); 222 BlockingLLSDQueue queue = GetQueue(agentID);
212 LLSD element = queue.Dequeue(15000); // 15s timeout 223 LLSD element = queue.Dequeue(15000); // 15s timeout
213 224
225 Hashtable responsedata = new Hashtable();
226
227 int thisID = 0;
228 lock (m_ids)
229 thisID = m_ids[agentID];
214 230
215 String debug = "[EVENTQUEUE]: Got request for agent {0} in region {1}: [ "; 231 if (thisID == -1) // close-request
216 foreach (object key in request.Keys)
217 { 232 {
218 debug += key.ToString() + "=" + request[key].ToString() + " "; 233 responsedata["int_response_code"] = 502;
234 responsedata["content_type"] = "text/plain";
235 responsedata["keepalive"] = false;
236 responsedata["str_response_string"] = "";
237 return responsedata;
219 } 238 }
220 m_log.DebugFormat(debug, agentID, m_scene.RegionInfo.RegionName);
221 239
222 Hashtable responsedata = new Hashtable(); 240 LLSDArray array = new LLSDArray();
223
224 if (element == null) // didn't have an event in 15s 241 if (element == null) // didn't have an event in 15s
225 { 242 {
226 // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say! 243 // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say!
227 element = EventQueueHelper.KeepAliveEvent(); 244 array.Add(EventQueueHelper.KeepAliveEvent());
228 245 m_log.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName);
229 //ScenePresence avatar;
230 //m_scene.TryGetAvatar(agentID, out avatar);
231
232 LLSDArray array = new LLSDArray();
233 array.Add(element);
234 int thisID = 0;
235 lock (m_ids)
236 thisID = m_ids[agentID];
237
238
239
240 if (thisID == -1)
241 {
242 responsedata = new Hashtable();
243 responsedata["int_response_code"] = 502;
244 responsedata["content_type"] = "text/plain";
245 responsedata["keepalive"] = false;
246 responsedata["str_response_string"] = "";
247 return responsedata;
248 }
249
250 while (queue.Count() > 0)
251 {
252 array.Add(queue.Dequeue(1));
253 thisID++;
254 }
255 LLSDMap events = new LLSDMap();
256 events.Add("events", array);
257
258 events.Add("id", new LLSDInteger(thisID));
259 lock (m_ids)
260 {
261 m_ids[agentID] = thisID + 1;
262 }
263 responsedata = new Hashtable();
264 responsedata["int_response_code"] = 200;
265 responsedata["content_type"] = "application/llsd+xml";
266 responsedata["keepalive"] = true;
267 responsedata["str_response_string"] = LLSDParser.SerializeXmlString(events);
268 m_log.DebugFormat("[EVENTQUEUE]: sending fake response for {0} in region{1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
269
270 return responsedata;
271 } 246 }
272 else 247 else
273 { 248 {
274 ScenePresence avatar;
275 m_scene.TryGetAvatar(agentID, out avatar);
276
277 LLSDArray array = new LLSDArray();
278 array.Add(element); 249 array.Add(element);
279 int thisID = m_ids[agentID];
280 while (queue.Count() > 0) 250 while (queue.Count() > 0)
281 { 251 {
282 array.Add(queue.Dequeue(1)); 252 array.Add(queue.Dequeue(1));
283 thisID++; 253 thisID++;
284 } 254 }
285 LLSDMap events = new LLSDMap();
286 events.Add("events", array);
287
288 events.Add("id", new LLSDInteger(thisID));
289 lock (m_ids)
290 {
291 m_ids[agentID] = thisID + 1;
292 }
293 responsedata = new Hashtable();
294 responsedata["int_response_code"] = 200;
295 responsedata["content_type"] = "application/llsd+xml";
296 responsedata["keepalive"] = true;
297 responsedata["str_response_string"] = LLSDParser.SerializeXmlString(events);
298 m_log.DebugFormat("[EVENTQUEUE]: sending fake response for {0} in region{1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
299
300 return responsedata;
301 } 255 }
256
257 LLSDMap events = new LLSDMap();
258 events.Add("events", array);
259
260 events.Add("id", new LLSDInteger(thisID));
261 lock (m_ids)
262 {
263 m_ids[agentID] = thisID + 1;
264 }
265
266 responsedata["int_response_code"] = 200;
267 responsedata["content_type"] = "application/xml";
268 responsedata["keepalive"] = true;
269 responsedata["str_response_string"] = LLSDParser.SerializeXmlString(events);
270 m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
271
272 return responsedata;
302 } 273 }
303 } 274 }
304} 275}