diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs | 156 |
1 files changed, 93 insertions, 63 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs index 2802e2f..741a98f 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs | |||
@@ -237,9 +237,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
237 | return false; | 237 | return false; |
238 | } | 238 | } |
239 | } | 239 | } |
240 | |||
240 | 241 | ||
241 | public void SendMessageToGroup(GridInstantMessage im, UUID groupID) | 242 | public void SendMessageToGroup(GridInstantMessage im, UUID groupID) |
242 | { | 243 | { |
244 | SendMessageToGroup(im, groupID, null); | ||
245 | } | ||
246 | |||
247 | public void SendMessageToGroup(GridInstantMessage im, UUID groupID, Func<GroupMembersData, bool> sendCondition) | ||
248 | { | ||
243 | List<GroupMembersData> groupMembers = m_groupData.GetGroupMembers(new UUID(im.fromAgentID), groupID); | 249 | List<GroupMembersData> groupMembers = m_groupData.GetGroupMembers(new UUID(im.fromAgentID), groupID); |
244 | int groupMembersCount = groupMembers.Count; | 250 | int groupMembersCount = groupMembers.Count; |
245 | 251 | ||
@@ -279,10 +285,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
279 | 285 | ||
280 | foreach (GroupMembersData member in groupMembers) | 286 | foreach (GroupMembersData member in groupMembers) |
281 | { | 287 | { |
282 | if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID, groupID)) | 288 | if (sendCondition != null) |
289 | { | ||
290 | if (!sendCondition(member)) | ||
291 | { | ||
292 | if (m_debugEnabled) | ||
293 | m_log.DebugFormat( | ||
294 | "[GROUPS-MESSAGING]: Not sending to {0} as they do not fulfill send condition", | ||
295 | member.AgentID); | ||
296 | |||
297 | continue; | ||
298 | } | ||
299 | } | ||
300 | else if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID, groupID)) | ||
283 | { | 301 | { |
284 | // Don't deliver messages to people who have dropped this session | 302 | // Don't deliver messages to people who have dropped this session |
285 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID); | 303 | if (m_debugEnabled) |
304 | m_log.DebugFormat( | ||
305 | "[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID); | ||
306 | |||
286 | continue; | 307 | continue; |
287 | } | 308 | } |
288 | 309 | ||
@@ -315,7 +336,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
315 | { | 336 | { |
316 | // Deliver locally, directly | 337 | // Deliver locally, directly |
317 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name); | 338 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name); |
318 | ProcessMessageFromGroupSession(msg); | 339 | ProcessMessageFromGroupSession(msg, client); |
319 | } | 340 | } |
320 | } | 341 | } |
321 | 342 | ||
@@ -348,7 +369,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
348 | // Any other message type will not be delivered to a client by the | 369 | // Any other message type will not be delivered to a client by the |
349 | // Instant Message Module | 370 | // Instant Message Module |
350 | 371 | ||
351 | |||
352 | if (m_debugEnabled) | 372 | if (m_debugEnabled) |
353 | { | 373 | { |
354 | m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 374 | m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
@@ -362,11 +382,30 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
362 | || (msg.dialog == (byte)InstantMessageDialog.SessionAdd) | 382 | || (msg.dialog == (byte)InstantMessageDialog.SessionAdd) |
363 | || (msg.dialog == (byte)InstantMessageDialog.SessionDrop))) | 383 | || (msg.dialog == (byte)InstantMessageDialog.SessionDrop))) |
364 | { | 384 | { |
365 | ProcessMessageFromGroupSession(msg); | 385 | IClientAPI client = null; |
386 | |||
387 | if (msg.dialog == (byte)InstantMessageDialog.SessionSend) | ||
388 | { | ||
389 | client = GetActiveClient(new UUID(msg.toAgentID)); | ||
390 | |||
391 | if (client != null) | ||
392 | { | ||
393 | if (m_debugEnabled) | ||
394 | m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} locally", client.Name); | ||
395 | } | ||
396 | else | ||
397 | { | ||
398 | m_log.WarnFormat("[GROUPS-MESSAGING]: Received a message over the grid for a client that isn't here: {0}", msg.toAgentID); | ||
399 | |||
400 | return; | ||
401 | } | ||
402 | } | ||
403 | |||
404 | ProcessMessageFromGroupSession(msg, client); | ||
366 | } | 405 | } |
367 | } | 406 | } |
368 | 407 | ||
369 | private void ProcessMessageFromGroupSession(GridInstantMessage msg) | 408 | private void ProcessMessageFromGroupSession(GridInstantMessage msg, IClientAPI client) |
370 | { | 409 | { |
371 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID); | 410 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID); |
372 | 411 | ||
@@ -393,67 +432,58 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
393 | m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); | 432 | m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); |
394 | 433 | ||
395 | UUID toAgentID = new UUID(msg.toAgentID); | 434 | UUID toAgentID = new UUID(msg.toAgentID); |
396 | IClientAPI activeClient = GetActiveClient(toAgentID); | 435 | |
397 | if (activeClient != null) | 436 | GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null); |
437 | if (groupInfo != null) | ||
398 | { | 438 | { |
399 | GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null); | 439 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message"); |
400 | if (groupInfo != null) | 440 | |
401 | { | 441 | // Force? open the group session dialog??? |
402 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message"); | 442 | // and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg); |
403 | 443 | IEventQueue eq = client.Scene.RequestModuleInterface<IEventQueue>(); | |
404 | // Force? open the group session dialog??? | 444 | eq.ChatterboxInvitation( |
405 | // and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg); | 445 | GroupID |
406 | IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>(); | 446 | , groupInfo.GroupName |
407 | eq.ChatterboxInvitation( | 447 | , new UUID(msg.fromAgentID) |
408 | GroupID | 448 | , msg.message |
409 | , groupInfo.GroupName | 449 | , new UUID(msg.toAgentID) |
410 | , new UUID(msg.fromAgentID) | 450 | , msg.fromAgentName |
411 | , msg.message | 451 | , msg.dialog |
412 | , new UUID(msg.toAgentID) | 452 | , msg.timestamp |
413 | , msg.fromAgentName | 453 | , msg.offline == 1 |
414 | , msg.dialog | 454 | , (int)msg.ParentEstateID |
415 | , msg.timestamp | 455 | , msg.Position |
416 | , msg.offline == 1 | 456 | , 1 |
417 | , (int)msg.ParentEstateID | 457 | , new UUID(msg.imSessionID) |
418 | , msg.Position | 458 | , msg.fromGroup |
419 | , 1 | 459 | , Utils.StringToBytes(groupInfo.GroupName) |
420 | , new UUID(msg.imSessionID) | 460 | ); |
421 | , msg.fromGroup | 461 | |
422 | , Utils.StringToBytes(groupInfo.GroupName) | 462 | eq.ChatterBoxSessionAgentListUpdates( |
423 | ); | 463 | new UUID(GroupID) |
424 | 464 | , new UUID(msg.fromAgentID) | |
425 | eq.ChatterBoxSessionAgentListUpdates( | 465 | , new UUID(msg.toAgentID) |
426 | new UUID(GroupID) | 466 | , false //canVoiceChat |
427 | , new UUID(msg.fromAgentID) | 467 | , false //isModerator |
428 | , new UUID(msg.toAgentID) | 468 | , false //text mute |
429 | , false //canVoiceChat | 469 | ); |
430 | , false //isModerator | ||
431 | , false //text mute | ||
432 | ); | ||
433 | } | ||
434 | } | 470 | } |
471 | |||
472 | break; | ||
435 | } | 473 | } |
436 | else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID)) | 474 | else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID)) |
437 | { | 475 | { |
438 | // User hasn't dropped, so they're in the session, | 476 | // User hasn't dropped, so they're in the session, |
439 | // maybe we should deliver it. | 477 | // maybe we should deliver it. |
440 | IClientAPI client = GetActiveClient(new UUID(msg.toAgentID)); | 478 | client.SendInstantMessage(msg); |
441 | if (client != null) | ||
442 | { | ||
443 | // Deliver locally, directly | ||
444 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} locally", client.Name); | ||
445 | client.SendInstantMessage(msg); | ||
446 | } | ||
447 | else | ||
448 | { | ||
449 | m_log.WarnFormat("[GROUPS-MESSAGING]: Received a message over the grid for a client that isn't here: {0}", msg.toAgentID); | ||
450 | } | ||
451 | } | 479 | } |
480 | |||
452 | break; | 481 | break; |
453 | 482 | ||
454 | default: | 483 | default: |
455 | m_log.WarnFormat("[GROUPS-MESSAGING]: I don't know how to proccess a {0} message.", ((InstantMessageDialog)msg.dialog).ToString()); | 484 | client.SendInstantMessage(msg); |
456 | break; | 485 | |
486 | break;; | ||
457 | } | 487 | } |
458 | } | 488 | } |
459 | 489 | ||
@@ -549,13 +579,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
549 | if (m_debugEnabled && im.dialog != (byte)InstantMessageDialog.MessageFromAgent) | 579 | if (m_debugEnabled && im.dialog != (byte)InstantMessageDialog.MessageFromAgent) |
550 | { | 580 | { |
551 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromGroup({0})", im.fromGroup ? "True" : "False"); | 581 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromGroup({0})", im.fromGroup ? "True" : "False"); |
552 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: Dialog({0})", ((InstantMessageDialog)im.dialog).ToString()); | 582 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: Dialog({0})", (InstantMessageDialog)im.dialog); |
553 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromAgentID({0})", im.fromAgentID.ToString()); | 583 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromAgentID({0})", im.fromAgentID); |
554 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromAgentName({0})", im.fromAgentName.ToString()); | 584 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromAgentName({0})", im.fromAgentName); |
555 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: imSessionID({0})", im.imSessionID.ToString()); | 585 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: imSessionID({0})", im.imSessionID); |
556 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: message({0})", im.message.ToString()); | 586 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: message({0})", im.message); |
557 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: offline({0})", im.offline.ToString()); | 587 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: offline({0})", im.offline); |
558 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: toAgentID({0})", im.toAgentID.ToString()); | 588 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: toAgentID({0})", im.toAgentID); |
559 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: binaryBucket({0})", OpenMetaverse.Utils.BytesToHexString(im.binaryBucket, "BinaryBucket")); | 589 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: binaryBucket({0})", OpenMetaverse.Utils.BytesToHexString(im.binaryBucket, "BinaryBucket")); |
560 | } | 590 | } |
561 | } | 591 | } |