several changes to xmlrpcGroups. Packets AgentData and AgentGroupData are private to the requesting agent, etc

avinationmerge
UbitUmarov 2015-09-27 06:10:12 +01:00
parent 238b32d95f
commit b269185031
1 changed files with 67 additions and 83 deletions

View File

@ -265,10 +265,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
sp.ControllingClient.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest; sp.ControllingClient.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest;
// Used for Notices and Group Invites/Accept/Reject // Used for Notices and Group Invites/Accept/Reject
sp.ControllingClient.OnInstantMessage += OnInstantMessage; sp.ControllingClient.OnInstantMessage += OnInstantMessage;
// Send client their groups information.
SendAgentGroupDataUpdate(sp.ControllingClient, sp.UUID); // we should send a DataUpdate here for compatibility,
// only send data viwer will ask rest later // but this is a bad place and a bad thread to do it
// OnAgentDataUpdateRequest(sp.ControllingClient, sp.UUID, sp.UUID); // also current viewers do ignore it and ask later on a much nicer thread
} }
private void OnMakeChild(ScenePresence sp) private void OnMakeChild(ScenePresence sp)
@ -291,7 +291,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
//GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetRequestingAgentID(remoteClient), avatarID).ToArray();
GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID);
remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
} }
@ -332,24 +331,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID)
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); // this a private message for own agent only
if (dataForAgentID != GetRequestingAgentID(remoteClient))
return;
UUID activeGroupID = UUID.Zero; SendAgentGroupDataUpdate(remoteClient, false);
string activeGroupTitle = string.Empty; // its a info request not a change, so nothing is sent to others
string activeGroupName = string.Empty; // they do get the group title with the avatar object update on arrivel to a region
ulong activeGroupPowers = (ulong)GroupPowers.None;
GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient), dataForAgentID);
if (membership != null)
{
activeGroupID = membership.GroupID;
activeGroupTitle = membership.GroupTitle;
activeGroupPowers = membership.GroupPowers;
}
SendAgentDataUpdate(remoteClient, dataForAgentID, activeGroupID, activeGroupName, activeGroupPowers, activeGroupTitle);
SendScenePresenceUpdate(dataForAgentID, activeGroupTitle);
} }
private void HandleUUIDGroupNameRequest(UUID GroupID, IClientAPI remoteClient) private void HandleUUIDGroupNameRequest(UUID GroupID, IClientAPI remoteClient)
@ -420,7 +408,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
OutgoingInstantMessage(msg, inviteInfo.AgentID); OutgoingInstantMessage(msg, inviteInfo.AgentID);
UpdateAllClientsWithGroupInfo(inviteInfo.AgentID); IClientAPI client = GetActiveClient(inviteInfo.AgentID);
if (client != null)
SendDataUpdate(remoteClient, true);
// TODO: If the inviter is still online, they need an agent dataupdate // TODO: If the inviter is still online, they need an agent dataupdate
// and maybe group membership updates for the invitee // and maybe group membership updates for the invitee
@ -673,13 +663,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
m_groupData.SetAgentActiveGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); UUID agentID = GetRequestingAgentID(remoteClient);
m_groupData.SetAgentActiveGroup(agentID, agentID, groupID);
// Changing active group changes title, active powers, all kinds of things // llClientView does this
// anyone who is in any region that can see this client, should probably be SendAgentGroupDataUpdate(remoteClient, true);
// updated with new group info. At a minimum, they should get ScenePresence
// updated with new title.
UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient));
} }
/// <summary> /// <summary>
@ -689,7 +677,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
@ -727,7 +714,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
} }
return data; return data;
} }
public List<GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID) public List<GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID)
@ -865,7 +851,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly");
// Update the founder with new group information. // Update the founder with new group information.
SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); SendAgentGroupDataUpdate(remoteClient, false);
return groupID; return groupID;
} }
@ -907,10 +893,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
// the client currently has set active, then we need to do a scene presence update too // the client currently has set active, then we need to do a scene presence update too
// if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID) // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID)
UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient)); SendDataUpdate(remoteClient, true);
} }
public void GroupRoleUpdate(IClientAPI remoteClient, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, byte updateType) public void GroupRoleUpdate(IClientAPI remoteClient, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, byte updateType)
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
@ -946,7 +931,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
} }
// TODO: This update really should send out updates for everyone in the role that just got changed. // TODO: This update really should send out updates for everyone in the role that just got changed.
SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); SendAgentGroupDataUpdate(remoteClient, false);
} }
public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes)
@ -972,7 +957,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
} }
// TODO: This update really should send out updates for everyone in the role that just got changed. // TODO: This update really should send out updates for everyone in the role that just got changed.
SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); SendAgentGroupDataUpdate(remoteClient, false);
} }
public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID)
@ -1052,14 +1037,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return msg; return msg;
} }
public void SendAgentGroupDataUpdate(IClientAPI remoteClient)
{
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
// Send agent information about his groups
SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
}
public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID)
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
@ -1069,8 +1046,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
remoteClient.SendJoinGroupReply(groupID, true); remoteClient.SendJoinGroupReply(groupID, true);
// Should this send updates to everyone in the group? SendAgentGroupDataUpdate(remoteClient, true);
SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
} }
public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID)
@ -1085,7 +1061,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
// SL sends out notifcations to the group messaging session that the person has left // SL sends out notifcations to the group messaging session that the person has left
// Should this also update everyone who is in the group? // Should this also update everyone who is in the group?
SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); SendAgentGroupDataUpdate(remoteClient, true);
} }
public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID)
@ -1194,10 +1170,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
msg.binaryBucket = new byte[0]; msg.binaryBucket = new byte[0];
OutgoingInstantMessage(msg, agentID); OutgoingInstantMessage(msg, agentID);
// SL sends out messages to everyone in the group // SL sends out messages to everyone in the group
// Who all should receive updates and what should they be updated with? // Who all should receive updates and what should they be updated with?
UpdateAllClientsWithGroupInfo(ejecteeID); // just tell this the group change
SendAgentGroupDataUpdate(remoteClient, false);
// TODO fix the rest of sends
} }
public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID) public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID)
@ -1378,7 +1355,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{ {
queue.Enqueue(queue.BuildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient)); queue.Enqueue(queue.BuildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient));
} }
} }
private void SendScenePresenceUpdate(UUID AgentID, string Title) private void SendScenePresenceUpdate(UUID AgentID, string Title)
@ -1403,34 +1379,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
} }
} }
/// <summary> public void SendAgentGroupDataUpdate(IClientAPI remoteClient)
/// Send updates to all clients who might be interested in groups data for dataForClientID
/// </summary>
private void UpdateAllClientsWithGroupInfo(UUID dataForClientID)
{ {
if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); SendAgentGroupDataUpdate(remoteClient, true);
// 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); });
}
}
} }
/// <summary> /// <summary>
/// Update remoteClient with group information about dataForAgentID /// Tell remoteClient about its agent groups, and optionally send title to others
/// </summary> /// </summary>
private void SendAgentGroupDataUpdate(IClientAPI remoteClient, UUID dataForAgentID) 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); if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called for {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name);
// TODO: All the client update functions need to be reexamined because most do too much and send too much stuff // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff
OnAgentDataUpdateRequest(remoteClient, dataForAgentID, UUID.Zero); UUID agentID = GetRequestingAgentID(remoteClient);
SendDataUpdate(remoteClient, tellOthers);
// Need to send a group membership update to the client // Need to send a group membership update to the client
// UDP version doesn't seem to behave nicely. But we're going to send it out here // UDP version doesn't seem to behave nicely. But we're going to send it out here
@ -1438,11 +1403,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
// to the core Groups Stub // to the core Groups Stub
remoteClient.SendGroupMembership(new GroupMembershipData[0]); remoteClient.SendGroupMembership(new GroupMembershipData[0]);
GroupMembershipData[] membershipArray = GetProfileListedGroupMemberships(remoteClient, dataForAgentID); GroupMembershipData[] membershipArray = GetProfileListedGroupMemberships(remoteClient, agentID);
SendGroupMembershipInfoViaCaps(remoteClient, dataForAgentID, membershipArray); SendGroupMembershipInfoViaCaps(remoteClient, agentID, membershipArray);
remoteClient.SendAvatarGroupsReply(dataForAgentID, membershipArray);
if (remoteClient.AgentId == dataForAgentID)
remoteClient.RefreshGroupMembership(); remoteClient.RefreshGroupMembership();
} }
@ -1495,13 +1458,27 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
return membershipArray; return membershipArray;
} }
//tell remoteClient about its agent group info, and optionally send title to others
private void SendAgentDataUpdate(IClientAPI remoteClient, UUID dataForAgentID, UUID activeGroupID, string activeGroupName, ulong activeGroupPowers, string activeGroupTitle) private void SendDataUpdate(IClientAPI remoteClient, bool tellOthers)
{ {
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
// TODO: All the client update functions need to be reexamined because most do too much and send too much stuff UUID activeGroupID = UUID.Zero;
UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, dataForAgentID); string activeGroupTitle = string.Empty;
string activeGroupName = string.Empty;
ulong activeGroupPowers = (ulong)GroupPowers.None;
UUID agentID = GetRequestingAgentID(remoteClient);
GroupMembershipData membership = m_groupData.GetAgentActiveMembership(agentID, agentID);
if (membership != null)
{
activeGroupID = membership.GroupID;
activeGroupTitle = membership.GroupTitle;
activeGroupPowers = membership.GroupPowers;
activeGroupName = membership.GroupName;
}
UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, agentID);
string firstname, lastname; string firstname, lastname;
if (account != null) if (account != null)
{ {
@ -1514,9 +1491,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
lastname = "Unknown"; lastname = "Unknown";
} }
remoteClient.SendAgentDataUpdate(dataForAgentID, activeGroupID, firstname, remoteClient.SendAgentDataUpdate(agentID, activeGroupID, firstname,
lastname, activeGroupPowers, activeGroupName, lastname, activeGroupPowers, activeGroupName,
activeGroupTitle); activeGroupTitle);
if (tellOthers)
SendScenePresenceUpdate(agentID, activeGroupTitle);
ScenePresence sp = (ScenePresence)remoteClient.SceneAgent;
if (sp != null)
sp.Grouptitle = activeGroupTitle;
} }
#endregion #endregion