diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index f14ba3e171..83f5c4f4e9 100755 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -2998,24 +2998,75 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(economyData, ThrottleOutPacketType.Task); } - public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List Data) + static private readonly byte[] AvatarPickerReplyHeader = new byte[] { + Helpers.MSG_RELIABLE, + 0, 0, 0, 0, // sequence number + 0, // extra + 0xff, 0xff, 0, 28 // ID 28 (low frequency bigendian) + }; + + public void SendAvatarPickerReply(UUID QueryID, List users) { - //construct the AvatarPickerReply packet. - AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket(); - replyPacket.AgentData.AgentID = AgentData.AgentID; - replyPacket.AgentData.QueryID = AgentData.QueryID; - //int i = 0; - List data_block = new List(); - foreach (AvatarPickerReplyDataArgs arg in Data) + UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + byte[] data = buf.Data; + + //setup header + Buffer.BlockCopy(AvatarPickerReplyHeader, 0, data, 0, 10); + AgentId.ToBytes(data, 10); //26 + QueryID.ToBytes(data, 26); //42 + + if (users.Count == 0) { - AvatarPickerReplyPacket.DataBlock db = new AvatarPickerReplyPacket.DataBlock(); - db.AvatarID = arg.AvatarID; - db.FirstName = arg.FirstName; - db.LastName = arg.LastName; - data_block.Add(db); + data[42] = 0; + buf.DataLength = 43; + m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Task); + return; + } + + int pos = 43; + int count = 0; + for(int u = 0; u < users.Count; ++u) + { + UserData user = users[u]; + user.Id.ToBytes(data,pos); + pos+= 16; + byte[] tmp = Utils.StringToBytes(user.FirstName); + data[pos++] = (byte)tmp.Length; + if(tmp.Length > 0) + { + Buffer.BlockCopy(tmp, 0, data, pos, tmp.Length); + pos += tmp.Length; + } + tmp = Utils.StringToBytes(user.LastName); + data[pos++] = (byte)tmp.Length; + if (tmp.Length > 0) + { + Buffer.BlockCopy(tmp, 0, data, pos, tmp.Length); + pos += tmp.Length; + } + ++count; + + if (pos >= LLUDPServer.MAXPAYLOAD - 120) + { + data[42] = (byte)count; + buf.DataLength = pos; + m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Task); + if (u < users.Count - 1) + { + UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); + byte[] newdata = newbuf.Data; + Buffer.BlockCopy(data, 0, newdata, pos, 42); + pos = 43; + } + count = 0; + } + } + if(count > 0) + { + data[42] = (byte)count; + buf.DataLength = pos; + m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Task); } - replyPacket.Data = data_block.ToArray(); - OutPacket(replyPacket, ThrottleOutPacketType.Task); } public void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle) diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index 43952d60f3..b28ce9cab8 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs @@ -185,7 +185,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles if (p != null && !p.IsDeleted) flags |= 0x10; - if(!clients.Contains(client) && client.IsActive) + if(clients == null) { client.SendAvatarProperties(props.UserId, props.AboutText, born, membershipType, props.FirstLifeText, flags, props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId); @@ -195,17 +195,30 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles if (agentGroups != null) client.SendAvatarGroupsReply(avatarID, agentGroups); } - foreach (IClientAPI cli in clients) + else { - if (!cli.IsActive) - continue; - cli.SendAvatarProperties(props.UserId, props.AboutText, born, membershipType, props.FirstLifeText, flags, - props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId); + if (!clients.Contains(client) && client.IsActive) + { + client.SendAvatarProperties(props.UserId, props.AboutText, born, membershipType, props.FirstLifeText, flags, + props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId); - cli.SendAvatarInterestsReply(props.UserId, (uint)props.WantToMask, props.WantToText, - (uint)props.SkillsMask, props.SkillsText, props.Language); - if (agentGroups != null) - cli.SendAvatarGroupsReply(avatarID, agentGroups); + client.SendAvatarInterestsReply(props.UserId, (uint)props.WantToMask, props.WantToText, + (uint)props.SkillsMask, props.SkillsText, props.Language); + if (agentGroups != null) + client.SendAvatarGroupsReply(avatarID, agentGroups); + } + foreach (IClientAPI cli in clients) + { + if (!cli.IsActive) + continue; + cli.SendAvatarProperties(props.UserId, props.AboutText, born, membershipType, props.FirstLifeText, flags, + props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId); + + cli.SendAvatarInterestsReply(props.UserId, (uint)props.WantToMask, props.WantToText, + (uint)props.SkillsMask, props.SkillsText, props.Language); + if (agentGroups != null) + cli.SendAvatarGroupsReply(avatarID, agentGroups); + } } } } diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 98595ae4e3..e068c970c3 100755 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -26,6 +26,7 @@ */ using System; using System.Collections.Generic; +using System.Collections.Concurrent; using System.IO; using System.Reflection; using System.Threading; @@ -237,51 +238,8 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement //EventManager.TriggerAvatarPickerRequest(); m_log.DebugFormat("[USER MANAGEMENT MODULE]: HandleAvatarPickerRequest for {0}", query); - List users = GetUserData(query, 500, 1); - - AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); - // TODO: don't create new blocks if recycling an old packet - - AvatarPickerReplyPacket.DataBlock[] searchData = - new AvatarPickerReplyPacket.DataBlock[users.Count]; - AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); - - agentData.AgentID = avatarID; - agentData.QueryID = RequestID; - replyPacket.AgentData = agentData; - //byte[] bytes = new byte[AvatarResponses.Count*32]; - - int i = 0; - foreach (UserData item in users) - { - UUID translatedIDtem = item.Id; - searchData[i] = new AvatarPickerReplyPacket.DataBlock(); - searchData[i].AvatarID = translatedIDtem; - searchData[i].FirstName = Utils.StringToBytes((string)item.FirstName); - searchData[i].LastName = Utils.StringToBytes((string)item.LastName); - i++; - } - if (users.Count == 0) - { - searchData = new AvatarPickerReplyPacket.DataBlock[0]; - } - replyPacket.Data = searchData; - - AvatarPickerReplyAgentDataArgs agent_data = new AvatarPickerReplyAgentDataArgs(); - agent_data.AgentID = replyPacket.AgentData.AgentID; - agent_data.QueryID = replyPacket.AgentData.QueryID; - - List data_args = new List(); - for (i = 0; i < replyPacket.Data.Length; i++) - { - AvatarPickerReplyDataArgs data_arg = new AvatarPickerReplyDataArgs(); - data_arg.AvatarID = replyPacket.Data[i].AvatarID; - data_arg.FirstName = replyPacket.Data[i].FirstName; - data_arg.LastName = replyPacket.Data[i].LastName; - data_args.Add(data_arg); - } - client.SendAvatarPickerReply(agent_data, data_args); + client.SendAvatarPickerReply(RequestID, users); } protected virtual void AddAdditionalUsers(string query, List users) diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 7870f0256d..51eeaf63bd 100755 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -1176,7 +1176,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server } - public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List Data) + public void SendAvatarPickerReply(UUID QueryID, List users) { } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index daad4e7ba7..3c742cab8d 100755 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -677,7 +677,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } - public virtual void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List Data) + public virtual void SendAvatarPickerReply(UUID QueryID, List users) { } diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 8c4c5413e0..a54c054054 100755 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -583,7 +583,7 @@ namespace OpenSim.Tests.Common { } - public virtual void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List Data) + public virtual void SendAvatarPickerReply(UUID QueryID, List users) { }