diff --git a/OpenSim/Addons/Groups/GroupsModule.cs b/OpenSim/Addons/Groups/GroupsModule.cs index 3336e940e0..13b7123a64 100644 --- a/OpenSim/Addons/Groups/GroupsModule.cs +++ b/OpenSim/Addons/Groups/GroupsModule.cs @@ -393,9 +393,11 @@ namespace OpenSim.Groups msg.binaryBucket = new byte[0]; OutgoingInstantMessage(msg, invitee); - - UpdateAllClientsWithGroupInfo(invitee); - + IClientAPI inviteeClient = GetActiveRootClient(invitee); + if(inviteeClient !=null) + { + SendAgentGroupDataUpdate(inviteeClient,true); + } } m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentIDStr(remoteClient), inviteID); @@ -521,14 +523,16 @@ namespace OpenSim.Groups UUID ejecteeID = new UUID(im.toAgentID); + im.imSessionID = UUID.Zero.Guid; im.dialog = (byte)InstantMessageDialog.MessageFromAgent; OutgoingInstantMessage(im, ejecteeID); - IClientAPI ejectee = GetActiveClient(ejecteeID); + IClientAPI ejectee = GetActiveRootClient(ejecteeID); if (ejectee != null) { UUID groupID = new UUID(im.imSessionID); ejectee.SendAgentDropGroup(groupID); + SendAgentGroupDataUpdate(ejectee,true); } } } @@ -548,7 +552,7 @@ namespace OpenSim.Groups case (byte)InstantMessageDialog.GroupInvitation: case (byte)InstantMessageDialog.GroupNotice: UUID toAgentID = new UUID(msg.toAgentID); - IClientAPI localClient = GetActiveClient(toAgentID); + IClientAPI localClient = GetActiveRootClient(toAgentID); if (localClient != null) { localClient.SendInstantMessage(msg); @@ -1058,10 +1062,31 @@ namespace OpenSim.Groups return; } + IClientAPI ejecteeClient = GetActiveRootClient(ejecteeID); + // Send Message to Ejectee GridInstantMessage msg = new GridInstantMessage(); - msg.imSessionID = UUID.Zero.Guid; + // if local send a normal message + if(ejecteeClient != null) + { + msg.imSessionID = UUID.Zero.Guid; + msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent; + // also execute and send update + ejecteeClient.SendAgentDropGroup(groupID); + SendAgentGroupDataUpdate(ejecteeClient,true); + } + else // send + { + // Interop, received special 210 code for ejecting a group member + // this only works within the comms servers domain, and won't work hypergrid + // TODO:FIXME: Use a presence server of some kind to find out where the + // client actually is, and try contacting that region directly to notify them, + // or provide the notification via xmlrpc update queue + + msg.imSessionID = groupInfo.GroupID.Guid; + msg.dialog = (byte)210; //interop + } msg.fromAgentID = agentID.Guid; // msg.fromAgentID = info.GroupID; msg.toAgentID = ejecteeID.Guid; @@ -1069,7 +1094,7 @@ namespace OpenSim.Groups msg.timestamp = 0; msg.fromAgentName = agentName; msg.message = string.Format("You have been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName); - msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent; + msg.fromGroup = false; msg.offline = (byte)0; msg.ParentEstateID = 0; @@ -1079,11 +1104,7 @@ namespace OpenSim.Groups OutgoingInstantMessage(msg, ejecteeID); // Message to ejector - // Interop, received special 210 code for ejecting a group member - // this only works within the comms servers domain, and won't work hypergrid - // TODO:FIXME: Use a presense server of some kind to find out where the - // client actually is, and try contacting that region directly to notify them, - // or provide the notification via xmlrpc update queue + msg = new GridInstantMessage(); msg.imSessionID = UUID.Zero.Guid; @@ -1099,7 +1120,7 @@ namespace OpenSim.Groups { msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName, "Unknown member"); } - msg.dialog = (byte)210; //interop + msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent; msg.fromGroup = false; msg.offline = (byte)0; msg.ParentEstateID = 0; @@ -1107,11 +1128,6 @@ namespace OpenSim.Groups msg.RegionID = regionInfo.RegionID.Guid; msg.binaryBucket = new byte[0]; OutgoingInstantMessage(msg, agentID); - - - // SL sends out messages to everyone in the group - // Who all should receive updates and what should they be updated with? - UpdateAllClientsWithGroupInfo(ejecteeID); } public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID) @@ -1174,6 +1190,18 @@ namespace OpenSim.Groups #endregion #region Client/Update Tools + private IClientAPI GetActiveRootClient(UUID agentID) + { + foreach (Scene scene in m_sceneList) + { + ScenePresence sp = scene.GetScenePresence(agentID); + if (sp != null && !sp.IsChildAgent && !sp.IsDeleted) + { + return sp.ControllingClient; + } + } + return null; + } /// /// Try to find an active IClientAPI reference for agentID giving preference to root connections @@ -1186,7 +1214,7 @@ namespace OpenSim.Groups foreach (Scene scene in m_sceneList) { ScenePresence sp = scene.GetScenePresence(agentID); - if (sp != null) + if (sp != null&& !sp.IsDeleted) { if (!sp.IsChildAgent) { @@ -1225,43 +1253,15 @@ namespace OpenSim.Groups } } - /// - /// Send updates to all clients who might be interested in groups data for dataForClientID - /// - private void UpdateAllClientsWithGroupInfo(UUID dataForClientID) - { - if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); - - // TODO: Probably isn't nessesary to update every client in every scene. - // Need to examine client updates and do only what's nessesary. - lock (m_sceneList) - { - foreach (Scene scene in m_sceneList) - { - scene.ForEachClient(delegate (IClientAPI client) { SendAgentGroupDataUpdate(client, dataForClientID); }); - } - } - } - public void SendAgentGroupDataUpdate(IClientAPI remoteClient) { - SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient), true); - } - - public void SendAgentGroupDataUpdate(IClientAPI remoteClient, UUID dataForClientID) - { - SendAgentGroupDataUpdate(remoteClient, dataForClientID, true); - } - - private void SendAgentGroupDataUpdate(IClientAPI remoteClient, bool tellOthers) - { - SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient), tellOthers); + SendAgentGroupDataUpdate(remoteClient, true); } /// /// Tell remoteClient about its agent groups, and optionally send title to others /// - private void SendAgentGroupDataUpdate(IClientAPI remoteClient, UUID dataForClientID, bool tellOthers) + private void SendAgentGroupDataUpdate(IClientAPI remoteClient, bool tellOthers) { if (m_debugEnabled) m_log.InfoFormat("[Groups]: {0} called for {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name); @@ -1279,7 +1279,7 @@ namespace OpenSim.Groups GroupMembershipData[] membershipArray = GetProfileListedGroupMemberships(remoteClient, agentID); IEventQueue eq = remoteClient.Scene.RequestModuleInterface(); if (eq != null) - eq.GroupMembershipData(GetRequestingAgentID(remoteClient), dataForClientID, membershipArray); + eq.GroupMembershipData(agentID, membershipArray); else remoteClient.SendGroupMembership(membershipArray); @@ -1388,7 +1388,7 @@ namespace OpenSim.Groups { if (m_debugEnabled) m_log.InfoFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); - IClientAPI localClient = GetActiveClient(msgTo); + IClientAPI localClient = GetActiveRootClient(msgTo); if (localClient != null) { if (m_debugEnabled) m_log.InfoFormat("[Groups]: MsgTo ({0}) is local, delivering directly", localClient.Name); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index d628cfcde9..9a1cef40fd 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -585,9 +585,9 @@ namespace OpenSim.Region.ClientStack.Linden Enqueue(item, avatarID); } - public void GroupMembershipData(UUID receiverAgent, UUID dataForClientID, GroupMembershipData[] data) + public void GroupMembershipData(UUID receiverAgent, GroupMembershipData[] data) { - OSD item = EventQueueHelper.GroupMembershipData(receiverAgent, dataForClientID, data); + OSD item = EventQueueHelper.GroupMembershipData(receiverAgent, data); Enqueue(item, receiverAgent); } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs index 7c8f441359..29d8b8501c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs @@ -367,7 +367,7 @@ namespace OpenSim.Region.ClientStack.Linden return groupUpdate; } - public static OSD GroupMembershipData(UUID receiverAgent, UUID dataForAgentID, GroupMembershipData[] data) + public static OSD GroupMembershipData(UUID receiverAgent, GroupMembershipData[] data) { OSDArray AgentData = new OSDArray(1); OSDMap AgentDataMap = new OSDMap(1); @@ -379,16 +379,6 @@ namespace OpenSim.Region.ClientStack.Linden foreach (GroupMembershipData membership in data) { - if (receiverAgent != dataForAgentID) - { - if (!membership.ListInProfile) - { - // If we're sending group info to remoteclient about another agent, - // filter out groups the other agent doesn't want to share. - continue; - } - } - OSDMap GroupDataMap = new OSDMap(6); OSDMap NewGroupDataMap = new OSDMap(1); diff --git a/OpenSim/Region/Framework/Interfaces/IEventQueue.cs b/OpenSim/Region/Framework/Interfaces/IEventQueue.cs index 1f29f7b6ef..f4014db897 100644 --- a/OpenSim/Region/Framework/Interfaces/IEventQueue.cs +++ b/OpenSim/Region/Framework/Interfaces/IEventQueue.cs @@ -59,7 +59,7 @@ namespace OpenSim.Region.Framework.Interfaces bool isModerator, bool textMute); void ParcelProperties(ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID); void GroupMembership(AgentGroupDataUpdatePacket groupUpdate, UUID avatarID); - void GroupMembershipData(UUID receiverAgent, UUID dataForClientID, GroupMembershipData[] data); + void GroupMembershipData(UUID receiverAgent, GroupMembershipData[] data); OSD ScriptRunningEvent(UUID objectID, UUID itemID, bool running, bool mono); OSD BuildEvent(string eventName, OSD eventBody); void partPhysicsProperties(uint localID, byte physhapetype, float density, float friction, float bounce, float gravmod, UUID avatarID); diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index 62f863bc63..2617723af6 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs @@ -217,6 +217,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups if (!m_groupsEnabled) return; + if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); + + scene.EventManager.OnNewClient -= OnNewClient; + scene.EventManager.OnMakeRootAgent -= OnMakeRoot; + scene.EventManager.OnMakeChildAgent -= OnMakeChild; + scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; + scene.EventManager.OnClientClosed -= OnClientClosed; if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); lock (m_sceneList) @@ -442,8 +449,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups OutgoingInstantMessage(msg, inviteInfo.AgentID); - UpdateAllClientsWithGroupInfo(inviteInfo.AgentID); - + IClientAPI inviteeClient = GetActiveRootClient(inviteInfo.AgentID); + if(inviteeClient !=null) + { + SendAgentGroupDataUpdate(inviteeClient,true); + } m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID); } @@ -634,15 +644,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups // so we need to send local updates to the agent. UUID ejecteeID = new UUID(im.toAgentID); - + im.imSessionID = UUID.Zero.Guid; im.dialog = (byte)InstantMessageDialog.MessageFromAgent; OutgoingInstantMessage(im, ejecteeID); - IClientAPI ejectee = GetActiveClient(ejecteeID); + IClientAPI ejectee = GetActiveRootClient(ejecteeID); if (ejectee != null) { UUID groupID = new UUID(im.imSessionID); ejectee.SendAgentDropGroup(groupID); + SendAgentGroupDataUpdate(ejectee,true); } } } @@ -662,7 +673,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups case (byte)InstantMessageDialog.GroupInvitation: case (byte)InstantMessageDialog.GroupNotice: UUID toAgentID = new UUID(msg.toAgentID); - IClientAPI localClient = GetActiveClient(toAgentID); + IClientAPI localClient = GetActiveRootClient(toAgentID); if (localClient != null) { localClient.SendInstantMessage(msg); @@ -1149,10 +1160,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups return; } + IClientAPI ejecteeClient = GetActiveRootClient(ejecteeID); + // Send Message to Ejectee GridInstantMessage msg = new GridInstantMessage(); - msg.imSessionID = UUID.Zero.Guid; + // if local send a normal message + if(ejecteeClient != null) + { + msg.imSessionID = UUID.Zero.Guid; + msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent; + // also execute and send update + ejecteeClient.SendAgentDropGroup(groupID); + SendAgentGroupDataUpdate(ejecteeClient,true); + } + else // send + { + // Interop, received special 210 code for ejecting a group member + // this only works within the comms servers domain, and won't work hypergrid + // TODO:FIXME: Use a presence server of some kind to find out where the + // client actually is, and try contacting that region directly to notify them, + // or provide the notification via xmlrpc update queue + + msg.imSessionID = groupInfo.GroupID.Guid; + msg.dialog = (byte)210; //interop + } + msg.fromAgentID = agentID.Guid; // msg.fromAgentID = info.GroupID; msg.toAgentID = ejecteeID.Guid; @@ -1160,7 +1193,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups msg.timestamp = 0; msg.fromAgentName = agentName; msg.message = string.Format("You have been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName); - msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent; +// msg.fromGroup = false; msg.offline = (byte)0; msg.ParentEstateID = 0; @@ -1170,11 +1203,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups OutgoingInstantMessage(msg, ejecteeID); // Message to ejector - // Interop, received special 210 code for ejecting a group member - // this only works within the comms servers domain, and won't work hypergrid - // TODO:FIXME: Use a presence server of some kind to find out where the - // client actually is, and try contacting that region directly to notify them, - // or provide the notification via xmlrpc update queue msg = new GridInstantMessage(); msg.imSessionID = UUID.Zero.Guid; @@ -1190,7 +1218,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups { msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName, "Unknown member"); } - msg.dialog = (byte)210; //interop +// msg.dialog = (byte)210; //interop + msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent; msg.fromGroup = false; msg.offline = (byte)0; msg.ParentEstateID = 0; @@ -1198,11 +1227,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups msg.RegionID = regionInfo.RegionID.Guid; msg.binaryBucket = new byte[0]; OutgoingInstantMessage(msg, agentID); - - // SL sends out messages to everyone in the group - // Who all should receive updates and what should they be updated with? - // just tell this the group change - UpdateAllClientsWithGroupInfo(ejecteeID); } public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID) @@ -1297,6 +1321,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups #region Client/Update Tools + private IClientAPI GetActiveRootClient(UUID agentID) + { + foreach (Scene scene in m_sceneList) + { + ScenePresence sp = scene.GetScenePresence(agentID); + if (sp != null && !sp.IsChildAgent && !sp.IsDeleted) + { + return sp.ControllingClient; + } + } + return null; + } + /// /// Try to find an active IClientAPI reference for agentID giving preference to root connections /// @@ -1308,7 +1345,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups foreach (Scene scene in m_sceneList) { ScenePresence sp = scene.GetScenePresence(agentID); - if (sp != null) + if (sp != null && !sp.IsDeleted) { if (!sp.IsChildAgent) { @@ -1347,43 +1384,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups } } - /// - /// Send updates to all clients who might be interested in groups data for dataForClientID - /// - private void UpdateAllClientsWithGroupInfo(UUID dataForClientID) - { - if (m_debugEnabled) m_log.InfoFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); - - // TODO: Probably isn't nessesary to update every client in every scene. - // Need to examine client updates and do only what's nessesary. - lock (m_sceneList) - { - foreach (Scene scene in m_sceneList) - { - scene.ForEachClient(delegate (IClientAPI client) { SendAgentGroupDataUpdate(client, dataForClientID); }); - } - } - } - public void SendAgentGroupDataUpdate(IClientAPI remoteClient) { SendAgentGroupDataUpdate(remoteClient, true); } - public void SendAgentGroupDataUpdate(IClientAPI remoteClient, UUID dataForClientID) - { - SendAgentGroupDataUpdate(remoteClient, dataForClientID, true); - } - - private void SendAgentGroupDataUpdate(IClientAPI remoteClient, bool tellOthers) - { - SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient), tellOthers); - } - /// /// Tell remoteClient about its agent groups, and optionally send title to others /// - private void SendAgentGroupDataUpdate(IClientAPI remoteClient, UUID dataForClientID, bool tellOthers) + private void SendAgentGroupDataUpdate(IClientAPI remoteClient, bool tellOthers) { if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called for {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name); @@ -1401,7 +1410,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups GroupMembershipData[] membershipArray = GetProfileListedGroupMemberships(remoteClient, agentID); IEventQueue eq = remoteClient.Scene.RequestModuleInterface(); if (eq != null) - eq.GroupMembershipData(GetRequestingAgentID(remoteClient), dataForClientID, membershipArray); + eq.GroupMembershipData(agentID, membershipArray); else remoteClient.SendGroupMembership(membershipArray); @@ -1510,7 +1519,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups { if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); - IClientAPI localClient = GetActiveClient(msgTo); + IClientAPI localClient = GetActiveRootClient(msgTo); if (localClient != null) { if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: MsgTo ({0}) is local, delivering directly", localClient.Name); diff --git a/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs index 192f84f0ca..332d59c45d 100644 --- a/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs +++ b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs @@ -162,7 +162,7 @@ namespace OpenSim.Tests.Common AddEvent(avatarID, "GroupMembership", groupUpdate); } - public void GroupMembershipData(UUID receiverAgent, UUID dataForClientID, GroupMembershipData[] data) + public void GroupMembershipData(UUID receiverAgent, GroupMembershipData[] data) { AddEvent(receiverAgent, "AgentGroupDataUpdate", data); }