aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsMessaging.cs
diff options
context:
space:
mode:
authorJeff Ames2009-04-27 05:22:44 +0000
committerJeff Ames2009-04-27 05:22:44 +0000
commit8dbcfc70bf87d503edd4239bd974339a130de153 (patch)
tree9adfe4db9d5658952cf181b919cbe45db170139b /OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsMessaging.cs
parentUpdate svn properties. (diff)
downloadopensim-SC_OLD-8dbcfc70bf87d503edd4239bd974339a130de153.zip
opensim-SC_OLD-8dbcfc70bf87d503edd4239bd974339a130de153.tar.gz
opensim-SC_OLD-8dbcfc70bf87d503edd4239bd974339a130de153.tar.bz2
opensim-SC_OLD-8dbcfc70bf87d503edd4239bd974339a130de153.tar.xz
Add copyright headers. Formatting cleanup.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsMessaging.cs143
1 files changed, 65 insertions, 78 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsMessaging.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsMessaging.cs
index 2dbe237..16dd0b6 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsMessaging.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsMessaging.cs
@@ -105,7 +105,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
105 } 105 }
106 106
107 m_debugEnabled = groupsConfig.GetBoolean("XmlRpcDebugEnabled", true); 107 m_debugEnabled = groupsConfig.GetBoolean("XmlRpcDebugEnabled", true);
108
109 } 108 }
110 109
111 m_log.Info("[GROUPS-MESSAGING]: XmlRpcGroupsMessaging starting up"); 110 m_log.Info("[GROUPS-MESSAGING]: XmlRpcGroupsMessaging starting up");
@@ -123,7 +122,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
123 122
124 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 123 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
125 124
126
127 m_groupsModule = scene.RequestModuleInterface<IGroupsModule>(); 125 m_groupsModule = scene.RequestModuleInterface<IGroupsModule>();
128 126
129 // No groups module, no groups messaging 127 // No groups module, no groups messaging
@@ -164,13 +162,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
164 m_sceneList.Remove(scene); 162 m_sceneList.Remove(scene);
165 } 163 }
166 164
167
168 public void Close() 165 public void Close()
169 { 166 {
170 if (!m_groupMessagingEnabled) 167 if (!m_groupMessagingEnabled)
171 return; 168 return;
172 169
173 if(m_debugEnabled) m_log.Debug("[GROUPS-MESSAGING]: Shutting down XmlRpcGroupsMessaging module."); 170 if (m_debugEnabled) m_log.Debug("[GROUPS-MESSAGING]: Shutting down XmlRpcGroupsMessaging module.");
174 171
175 foreach (Scene scene in m_sceneList) 172 foreach (Scene scene in m_sceneList)
176 { 173 {
@@ -222,19 +219,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
222 { 219 {
223 m_log.DebugFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 220 m_log.DebugFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
224 221
225 DebugGridInstantMessage(msg); 222 DebugGridInstantMessage(msg);
226 } 223 }
227 224
228 // Incoming message from a group 225 // Incoming message from a group
229 if ((msg.fromGroup == true) && 226 if ((msg.fromGroup == true) &&
230 ( (msg.dialog == (byte)InstantMessageDialog.SessionSend) 227 ((msg.dialog == (byte)InstantMessageDialog.SessionSend)
231 || (msg.dialog == (byte)InstantMessageDialog.SessionAdd) 228 || (msg.dialog == (byte)InstantMessageDialog.SessionAdd)
232 || (msg.dialog == (byte)InstantMessageDialog.SessionDrop) 229 || (msg.dialog == (byte)InstantMessageDialog.SessionDrop)))
233 ))
234 { 230 {
235 ProcessMessageFromGroupSession(msg); 231 ProcessMessageFromGroupSession(msg);
236 } 232 }
237
238 } 233 }
239 234
240 private void ProcessMessageFromGroupSession(GridInstantMessage msg) 235 private void ProcessMessageFromGroupSession(GridInstantMessage msg)
@@ -254,53 +249,52 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
254 case (byte)InstantMessageDialog.SessionSend: 249 case (byte)InstantMessageDialog.SessionSend:
255 if (!m_agentsInGroupSession.ContainsKey(msg.toAgentID) 250 if (!m_agentsInGroupSession.ContainsKey(msg.toAgentID)
256 && !m_agentsDroppedSession.ContainsKey(msg.toAgentID)) 251 && !m_agentsDroppedSession.ContainsKey(msg.toAgentID))
257 { 252 {
258 // Agent not in session and hasn't dropped from session 253 // Agent not in session and hasn't dropped from session
259 // Add them to the session for now, and Invite them 254 // Add them to the session for now, and Invite them
260 AddAgentToGroupSession(msg.toAgentID, msg.imSessionID); 255 AddAgentToGroupSession(msg.toAgentID, msg.imSessionID);
261 256
262 UUID toAgentID = new UUID(msg.toAgentID); 257 UUID toAgentID = new UUID(msg.toAgentID);
263 IClientAPI activeClient = GetActiveClient(toAgentID); 258 IClientAPI activeClient = GetActiveClient(toAgentID);
264 if (activeClient != null) 259 if (activeClient != null)
265 { 260 {
266 UUID groupID = new UUID(msg.fromAgentID); 261 UUID groupID = new UUID(msg.fromAgentID);
267 262
268 GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID); 263 GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID);
269 if (groupInfo != null) 264 if (groupInfo != null)
270 { 265 {
271 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING] Sending chatterbox invite instant message"); 266 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING] Sending chatterbox invite instant message");
272 267
273 // Force? open the group session dialog??? 268 // Force? open the group session dialog???
274 IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>(); 269 IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>();
275 eq.ChatterboxInvitation( 270 eq.ChatterboxInvitation(
276 groupID 271 groupID
277 , groupInfo.GroupName 272 , groupInfo.GroupName
278 , new UUID(msg.fromAgentID) 273 , new UUID(msg.fromAgentID)
279 , msg.message, new UUID(msg.toAgentID) 274 , msg.message, new UUID(msg.toAgentID)
280 , msg.fromAgentName 275 , msg.fromAgentName
281 , msg.dialog 276 , msg.dialog
282 , msg.timestamp 277 , msg.timestamp
283 , msg.offline == 1 278 , msg.offline == 1
284 , (int)msg.ParentEstateID 279 , (int)msg.ParentEstateID
285 , msg.Position 280 , msg.Position
286 , 1 281 , 1
287 , new UUID(msg.imSessionID) 282 , new UUID(msg.imSessionID)
288 , msg.fromGroup 283 , msg.fromGroup
289 , Utils.StringToBytes(groupInfo.GroupName) 284 , Utils.StringToBytes(groupInfo.GroupName)
290 ); 285 );
291 286
292 eq.ChatterBoxSessionAgentListUpdates( 287 eq.ChatterBoxSessionAgentListUpdates(
293 new UUID(groupID) 288 new UUID(groupID)
294 , new UUID(msg.fromAgentID) 289 , new UUID(msg.fromAgentID)
295 , new UUID(msg.toAgentID) 290 , new UUID(msg.toAgentID)
296 , false //canVoiceChat 291 , false //canVoiceChat
297 , false //isModerator 292 , false //isModerator
298 , false //text mute 293 , false //text mute
299 ); 294 );
300 295 }
296 }
301 } 297 }
302 }
303 }
304 else if (!m_agentsDroppedSession.ContainsKey(msg.toAgentID)) 298 else if (!m_agentsDroppedSession.ContainsKey(msg.toAgentID))
305 { 299 {
306 // User hasn't dropped, so they're in the session, 300 // User hasn't dropped, so they're in the session,
@@ -322,10 +316,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
322 default: 316 default:
323 m_log.WarnFormat("[GROUPS-MESSAGING] I don't know how to proccess a {0} message.", ((InstantMessageDialog)msg.dialog).ToString()); 317 m_log.WarnFormat("[GROUPS-MESSAGING] I don't know how to proccess a {0} message.", ((InstantMessageDialog)msg.dialog).ToString());
324 break; 318 break;
319 }
325 } 320 }
326 }
327
328
329 321
330 #endregion 322 #endregion
331 323
@@ -333,16 +325,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
333 325
334 private void RemoveAgentFromGroupSession(Guid agentID, Guid sessionID) 326 private void RemoveAgentFromGroupSession(Guid agentID, Guid sessionID)
335 { 327 {
336 if( m_agentsInGroupSession.ContainsKey(sessionID) ) 328 if (m_agentsInGroupSession.ContainsKey(sessionID))
337 { 329 {
338 // If in session remove 330 // If in session remove
339 if( m_agentsInGroupSession[sessionID].Contains(agentID) ) 331 if (m_agentsInGroupSession[sessionID].Contains(agentID))
340 { 332 {
341 m_agentsInGroupSession[sessionID].Remove(agentID); 333 m_agentsInGroupSession[sessionID].Remove(agentID);
342 } 334 }
343 335
344 // If not in dropped list, add 336 // If not in dropped list, add
345 if( !m_agentsDroppedSession[sessionID].Contains(agentID) ) 337 if (!m_agentsDroppedSession[sessionID].Contains(agentID))
346 { 338 {
347 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING] Dropped {1} from session {0}", sessionID, agentID); 339 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING] Dropped {1} from session {0}", sessionID, agentID);
348 m_agentsDroppedSession[sessionID].Add(agentID); 340 m_agentsDroppedSession[sessionID].Add(agentID);
@@ -356,13 +348,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
356 CreateGroupSessionTracking(sessionID); 348 CreateGroupSessionTracking(sessionID);
357 349
358 // If nessesary, remove from dropped list 350 // If nessesary, remove from dropped list
359 if( m_agentsDroppedSession[sessionID].Contains(agentID) ) 351 if (m_agentsDroppedSession[sessionID].Contains(agentID))
360 { 352 {
361 m_agentsDroppedSession[sessionID].Remove(agentID); 353 m_agentsDroppedSession[sessionID].Remove(agentID);
362 } 354 }
363 355
364 // If nessesary, add to in session list 356 // If nessesary, add to in session list
365 if( !m_agentsInGroupSession[sessionID].Contains(agentID) ) 357 if (!m_agentsInGroupSession[sessionID].Contains(agentID))
366 { 358 {
367 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING] Added {1} to session {0}", sessionID, agentID); 359 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING] Added {1} to session {0}", sessionID, agentID);
368 m_agentsInGroupSession[sessionID].Add(agentID); 360 m_agentsInGroupSession[sessionID].Add(agentID);
@@ -385,7 +377,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
385 { 377 {
386 m_log.DebugFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 378 m_log.DebugFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
387 379
388 DebugGridInstantMessage(im); 380 DebugGridInstantMessage(im);
389 } 381 }
390 382
391 // Start group IM session 383 // Start group IM session
@@ -424,13 +416,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
424 SendMessageToGroup(im, groupID); 416 SendMessageToGroup(im, groupID);
425 } 417 }
426 } 418 }
419
427 #endregion 420 #endregion
428 421
429 private void SendMessageToGroup(GridInstantMessage im, UUID groupID) 422 private void SendMessageToGroup(GridInstantMessage im, UUID groupID)
430 { 423 {
431 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 424 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
432 425
433
434 foreach (GroupMembersData member in m_groupsModule.GroupMembersRequest(null, groupID)) 426 foreach (GroupMembersData member in m_groupsModule.GroupMembersRequest(null, groupID))
435 { 427 {
436 if (m_agentsDroppedSession[im.imSessionID].Contains(member.AgentID.Guid)) 428 if (m_agentsDroppedSession[im.imSessionID].Contains(member.AgentID.Guid))
@@ -441,15 +433,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
441 } 433 }
442 434
443 // Copy Message 435 // Copy Message
444 GridInstantMessage msg = new GridInstantMessage(); 436 GridInstantMessage msg = new GridInstantMessage();
445 msg.imSessionID = im.imSessionID; 437 msg.imSessionID = im.imSessionID;
446 msg.fromAgentName = im.fromAgentName; 438 msg.fromAgentName = im.fromAgentName;
447 msg.message = im.message; 439 msg.message = im.message;
448 msg.dialog = im.dialog; 440 msg.dialog = im.dialog;
449 msg.offline = im.offline; 441 msg.offline = im.offline;
450 msg.ParentEstateID = im.ParentEstateID; 442 msg.ParentEstateID = im.ParentEstateID;
451 msg.Position = im.Position; 443 msg.Position = im.Position;
452 msg.RegionID = im.RegionID; 444 msg.RegionID = im.RegionID;
453 msg.binaryBucket = im.binaryBucket; 445 msg.binaryBucket = im.binaryBucket;
454 msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 446 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
455 447
@@ -464,8 +456,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
464 { 456 {
465 // If they're not local, forward across the grid 457 // If they're not local, forward across the grid
466 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING] Delivering to {0} via Grid", member.AgentID); 458 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING] Delivering to {0} via Grid", member.AgentID);
467 m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { }); 459 m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { });
468 } 460 }
469 else 461 else
470 { 462 {
471 // Deliver locally, directly 463 // Deliver locally, directly
@@ -488,24 +480,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
488 sessionMap.Add("type", OSD.FromInteger(0)); 480 sessionMap.Add("type", OSD.FromInteger(0));
489 sessionMap.Add("voice_enabled", OSD.FromBoolean(false)); 481 sessionMap.Add("voice_enabled", OSD.FromBoolean(false));
490 482
491
492 OSDMap bodyMap = new OSDMap(4); 483 OSDMap bodyMap = new OSDMap(4);
493 bodyMap.Add("session_id", OSD.FromUUID(groupID)); 484 bodyMap.Add("session_id", OSD.FromUUID(groupID));
494 bodyMap.Add("temp_session_id", OSD.FromUUID(groupID)); 485 bodyMap.Add("temp_session_id", OSD.FromUUID(groupID));
495 bodyMap.Add("success", OSD.FromBoolean(true)); 486 bodyMap.Add("success", OSD.FromBoolean(true));
496 bodyMap.Add("session_info", sessionMap); 487 bodyMap.Add("session_info", sessionMap);
497 488
498
499 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); 489 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
500 490
501 if (queue != null) 491 if (queue != null)
502 { 492 {
503 queue.Enqueue(EventQueueHelper.buildEvent("ChatterBoxSessionStartReply", bodyMap), remoteClient.AgentId); 493 queue.Enqueue(EventQueueHelper.buildEvent("ChatterBoxSessionStartReply", bodyMap), remoteClient.AgentId);
504 } 494 }
505
506 } 495 }
507 496
508
509 private void DebugGridInstantMessage(GridInstantMessage im) 497 private void DebugGridInstantMessage(GridInstantMessage im)
510 { 498 {
511 if (m_debugEnabled) 499 if (m_debugEnabled)
@@ -535,7 +523,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
535 foreach (Scene scene in m_sceneList) 523 foreach (Scene scene in m_sceneList)
536 { 524 {
537 if (scene.Entities.ContainsKey(agentID) && 525 if (scene.Entities.ContainsKey(agentID) &&
538 scene.Entities[agentID] is ScenePresence) 526 scene.Entities[agentID] is ScenePresence)
539 { 527 {
540 ScenePresence user = (ScenePresence)scene.Entities[agentID]; 528 ScenePresence user = (ScenePresence)scene.Entities[agentID];
541 if (!user.IsChildAgent) 529 if (!user.IsChildAgent)
@@ -546,7 +534,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
546 { 534 {
547 child = user.ControllingClient; 535 child = user.ControllingClient;
548 } 536 }
549 } 537 }
550 } 538 }
551 539
552 // If we didn't find a root, then just return whichever child we found, or null if none 540 // If we didn't find a root, then just return whichever child we found, or null if none
@@ -555,5 +543,4 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
555 543
556 #endregion 544 #endregion
557 } 545 }
558
559} 546}