aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Avatar/InstantMessage
diff options
context:
space:
mode:
authorHomer Horwitz2008-11-22 18:33:02 +0000
committerHomer Horwitz2008-11-22 18:33:02 +0000
commita7b01140db3c544dc599c257baad36b28304f11c (patch)
tree668f8c10bf817c53147b8fa8286d052b852df81d /OpenSim/Region/Environment/Modules/Avatar/InstantMessage
parent- Add a warning if the agent data of the destination of an IM isn't found (diff)
downloadopensim-SC_OLD-a7b01140db3c544dc599c257baad36b28304f11c.zip
opensim-SC_OLD-a7b01140db3c544dc599c257baad36b28304f11c.tar.gz
opensim-SC_OLD-a7b01140db3c544dc599c257baad36b28304f11c.tar.bz2
opensim-SC_OLD-a7b01140db3c544dc599c257baad36b28304f11c.tar.xz
Enclose the inter-region IM sending in a try-catch for now to find possibly missed exceptions.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/InstantMessage')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/InstantMessage/MessageTransferModule.cs366
1 files changed, 188 insertions, 178 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/MessageTransferModule.cs
index 584ad94..3af65a6 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -180,198 +180,208 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
180 protected virtual XmlRpcResponse processXMLRPCGridInstantMessage(XmlRpcRequest request) 180 protected virtual XmlRpcResponse processXMLRPCGridInstantMessage(XmlRpcRequest request)
181 { 181 {
182 bool successful = false; 182 bool successful = false;
183 // various rational defaults 183
184 UUID fromAgentID = UUID.Zero; 184 // TODO: For now, as IMs seem to be a bit unreliable on OSGrid, catch all exception that
185 UUID toAgentID = UUID.Zero; 185 // happen here and aren't caught and log them.
186 UUID imSessionID = UUID.Zero; 186 try {
187 uint timestamp = 0; 187 // various rational defaults
188 string fromAgentName = ""; 188 UUID fromAgentID = UUID.Zero;
189 string message = ""; 189 UUID toAgentID = UUID.Zero;
190 byte dialog = (byte)0; 190 UUID imSessionID = UUID.Zero;
191 bool fromGroup = false; 191 uint timestamp = 0;
192 byte offline = (byte)0; 192 string fromAgentName = "";
193 uint ParentEstateID=0; 193 string message = "";
194 Vector3 Position = Vector3.Zero; 194 byte dialog = (byte)0;
195 UUID RegionID = UUID.Zero ; 195 bool fromGroup = false;
196 byte[] binaryBucket = new byte[0]; 196 byte offline = (byte)0;
197 197 uint ParentEstateID=0;
198 float pos_x = 0; 198 Vector3 Position = Vector3.Zero;
199 float pos_y = 0; 199 UUID RegionID = UUID.Zero ;
200 float pos_z = 0; 200 byte[] binaryBucket = new byte[0];
201 //m_log.Info("Processing IM"); 201
202 202 float pos_x = 0;
203 203 float pos_y = 0;
204 Hashtable requestData = (Hashtable)request.Params[0]; 204 float pos_z = 0;
205 // Check if it's got all the data 205 //m_log.Info("Processing IM");
206 if (requestData.ContainsKey("from_agent_id") 206
207 && requestData.ContainsKey("to_agent_id") && requestData.ContainsKey("im_session_id") 207
208 && requestData.ContainsKey("timestamp") && requestData.ContainsKey("from_agent_name") 208 Hashtable requestData = (Hashtable)request.Params[0];
209 && requestData.ContainsKey("message") && requestData.ContainsKey("dialog") 209 // Check if it's got all the data
210 && requestData.ContainsKey("from_group") 210 if (requestData.ContainsKey("from_agent_id")
211 && requestData.ContainsKey("offline") && requestData.ContainsKey("parent_estate_id") 211 && requestData.ContainsKey("to_agent_id") && requestData.ContainsKey("im_session_id")
212 && requestData.ContainsKey("position_x") && requestData.ContainsKey("position_y") 212 && requestData.ContainsKey("timestamp") && requestData.ContainsKey("from_agent_name")
213 && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") 213 && requestData.ContainsKey("message") && requestData.ContainsKey("dialog")
214 && requestData.ContainsKey("binary_bucket")) 214 && requestData.ContainsKey("from_group")
215 { 215 && requestData.ContainsKey("offline") && requestData.ContainsKey("parent_estate_id")
216 // Do the easy way of validating the UUIDs 216 && requestData.ContainsKey("position_x") && requestData.ContainsKey("position_y")
217 UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID); 217 && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id")
218 UUID.TryParse((string)requestData["to_agent_id"], out toAgentID); 218 && requestData.ContainsKey("binary_bucket"))
219 UUID.TryParse((string)requestData["im_session_id"], out imSessionID); 219 {
220 UUID.TryParse((string)requestData["region_id"], out RegionID); 220 // Do the easy way of validating the UUIDs
221 221 UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID);
222 try 222 UUID.TryParse((string)requestData["to_agent_id"], out toAgentID);
223 { 223 UUID.TryParse((string)requestData["im_session_id"], out imSessionID);
224 timestamp = (uint)Convert.ToInt32((string)requestData["timestamp"]); 224 UUID.TryParse((string)requestData["region_id"], out RegionID);
225 } 225
226 catch (ArgumentException) 226 try
227 { 227 {
228 } 228 timestamp = (uint)Convert.ToInt32((string)requestData["timestamp"]);
229 catch (FormatException) 229 }
230 { 230 catch (ArgumentException)
231 } 231 {
232 catch (OverflowException) 232 }
233 { 233 catch (FormatException)
234 } 234 {
235 }
236 catch (OverflowException)
237 {
238 }
235 239
236 fromAgentName = (string)requestData["from_agent_name"]; 240 fromAgentName = (string)requestData["from_agent_name"];
237 message = (string)requestData["message"]; 241 message = (string)requestData["message"];
238 242
239 // Bytes don't transfer well over XMLRPC, so, we Base64 Encode them. 243 // Bytes don't transfer well over XMLRPC, so, we Base64 Encode them.
240 string requestData1 = (string)requestData["dialog"]; 244 string requestData1 = (string)requestData["dialog"];
241 if (string.IsNullOrEmpty(requestData1)) 245 if (string.IsNullOrEmpty(requestData1))
242 { 246 {
243 dialog = 0; 247 dialog = 0;
244 } 248 }
245 else 249 else
246 { 250 {
247 byte[] dialogdata = Convert.FromBase64String(requestData1); 251 byte[] dialogdata = Convert.FromBase64String(requestData1);
248 dialog = dialogdata[0]; 252 dialog = dialogdata[0];
249 } 253 }
250 254
251 if ((string)requestData["from_group"] == "TRUE") 255 if ((string)requestData["from_group"] == "TRUE")
252 fromGroup = true; 256 fromGroup = true;
253 257
254 string requestData2 = (string)requestData["offline"]; 258 string requestData2 = (string)requestData["offline"];
255 if (String.IsNullOrEmpty(requestData2)) 259 if (String.IsNullOrEmpty(requestData2))
256 { 260 {
257 offline = 0; 261 offline = 0;
258 } 262 }
259 else 263 else
260 { 264 {
261 byte[] offlinedata = Convert.FromBase64String(requestData2); 265 byte[] offlinedata = Convert.FromBase64String(requestData2);
262 offline = offlinedata[0]; 266 offline = offlinedata[0];
263 } 267 }
264
265 try
266 {
267 ParentEstateID = (uint)Convert.ToInt32((string)requestData["parent_estate_id"]);
268 }
269 catch (ArgumentException)
270 {
271 }
272 catch (FormatException)
273 {
274 }
275 catch (OverflowException)
276 {
277 }
278 268
279 try 269 try
280 { 270 {
281 pos_x = (uint)Convert.ToInt32((string)requestData["position_x"]); 271 ParentEstateID = (uint)Convert.ToInt32((string)requestData["parent_estate_id"]);
282 } 272 }
283 catch (ArgumentException) 273 catch (ArgumentException)
284 { 274 {
285 } 275 }
286 catch (FormatException) 276 catch (FormatException)
287 { 277 {
288 } 278 }
289 catch (OverflowException) 279 catch (OverflowException)
290 { 280 {
291 } 281 }
292 try
293 {
294 pos_y = (uint)Convert.ToInt32((string)requestData["position_y"]);
295 }
296 catch (ArgumentException)
297 {
298 }
299 catch (FormatException)
300 {
301 }
302 catch (OverflowException)
303 {
304 }
305 try
306 {
307 pos_z = (uint)Convert.ToInt32((string)requestData["position_z"]);
308 }
309 catch (ArgumentException)
310 {
311 }
312 catch (FormatException)
313 {
314 }
315 catch (OverflowException)
316 {
317 }
318 282
319 Position = new Vector3(pos_x, pos_y, pos_z); 283 try
284 {
285 pos_x = (uint)Convert.ToInt32((string)requestData["position_x"]);
286 }
287 catch (ArgumentException)
288 {
289 }
290 catch (FormatException)
291 {
292 }
293 catch (OverflowException)
294 {
295 }
296 try
297 {
298 pos_y = (uint)Convert.ToInt32((string)requestData["position_y"]);
299 }
300 catch (ArgumentException)
301 {
302 }
303 catch (FormatException)
304 {
305 }
306 catch (OverflowException)
307 {
308 }
309 try
310 {
311 pos_z = (uint)Convert.ToInt32((string)requestData["position_z"]);
312 }
313 catch (ArgumentException)
314 {
315 }
316 catch (FormatException)
317 {
318 }
319 catch (OverflowException)
320 {
321 }
320 322
321 string requestData3 = (string)requestData["binary_bucket"]; 323 Position = new Vector3(pos_x, pos_y, pos_z);
322 if (string.IsNullOrEmpty(requestData3))
323 {
324 binaryBucket = new byte[0];
325 }
326 else
327 {
328 binaryBucket = Convert.FromBase64String(requestData3);
329 }
330 324
331 // Create a New GridInstantMessageObject the the data 325 string requestData3 = (string)requestData["binary_bucket"];
332 GridInstantMessage gim = new GridInstantMessage(); 326 if (string.IsNullOrEmpty(requestData3))
333 gim.fromAgentID = fromAgentID.Guid;
334 gim.fromAgentName = fromAgentName;
335 gim.fromGroup = fromGroup;
336 gim.imSessionID = imSessionID.Guid;
337 gim.RegionID = RegionID.Guid;
338 gim.timestamp = timestamp;
339 gim.toAgentID = toAgentID.Guid;
340 gim.message = message;
341 gim.dialog = dialog;
342 gim.offline = offline;
343 gim.ParentEstateID = ParentEstateID;
344 gim.Position = Position;
345 gim.binaryBucket = binaryBucket;
346
347
348 // Trigger the Instant message in the scene.
349 foreach (Scene scene in m_Scenes)
350 {
351 if (scene.Entities.ContainsKey(toAgentID) &&
352 scene.Entities[toAgentID] is ScenePresence)
353 { 327 {
354 ScenePresence user = 328 binaryBucket = new byte[0];
355 (ScenePresence)scene.Entities[toAgentID]; 329 }
330 else
331 {
332 binaryBucket = Convert.FromBase64String(requestData3);
333 }
356 334
357 if (!user.IsChildAgent) 335 // Create a New GridInstantMessageObject the the data
336 GridInstantMessage gim = new GridInstantMessage();
337 gim.fromAgentID = fromAgentID.Guid;
338 gim.fromAgentName = fromAgentName;
339 gim.fromGroup = fromGroup;
340 gim.imSessionID = imSessionID.Guid;
341 gim.RegionID = RegionID.Guid;
342 gim.timestamp = timestamp;
343 gim.toAgentID = toAgentID.Guid;
344 gim.message = message;
345 gim.dialog = dialog;
346 gim.offline = offline;
347 gim.ParentEstateID = ParentEstateID;
348 gim.Position = Position;
349 gim.binaryBucket = binaryBucket;
350
351
352 // Trigger the Instant message in the scene.
353 foreach (Scene scene in m_Scenes)
354 {
355 if (scene.Entities.ContainsKey(toAgentID) &&
356 scene.Entities[toAgentID] is ScenePresence)
358 { 357 {
359 scene.EventManager.TriggerIncomingInstantMessage(gim); 358 ScenePresence user =
360 successful = true; 359 (ScenePresence)scene.Entities[toAgentID];
360
361 if (!user.IsChildAgent)
362 {
363 scene.EventManager.TriggerIncomingInstantMessage(gim);
364 successful = true;
365 }
361 } 366 }
362 } 367 }
368 if (!successful)
369 {
370 // If the message can't be delivered to an agent, it
371 // is likely to be a group IM. On a group IM, the
372 // imSessionID = toAgentID = group id. Raise the
373 // unhandled IM event to give the groups module
374 // a chance to pick it up. We raise that in a random
375 // scene, since the groups module is shared.
376 //
377 m_Scenes[0].EventManager.TriggerUnhandledInstantMessage(gim);
378 }
363 } 379 }
364 if (!successful) 380 }
365 { 381 catch (Exception e)
366 // If the message can't be delivered to an agent, it 382 {
367 // is likely to be a group IM. On a group IM, the 383 m_log.Error("[INSTANT MESSAGE]: Caught unexpected exception:", e);
368 // imSessionID = toAgentID = group id. Raise the 384 successful = false;
369 // unhandled IM event to give the groups module
370 // a chance to pick it up. We raise that in a random
371 // scene, since the groups module is shared.
372 //
373 m_Scenes[0].EventManager.TriggerUnhandledInstantMessage(gim);
374 }
375 } 385 }
376 386
377 //Send response back to region calling if it was successful 387 //Send response back to region calling if it was successful