take lludp out of usermanagement module

master
UbitUmarov 2020-03-04 20:02:45 +00:00
parent 20b974cff0
commit ad601c9502
6 changed files with 94 additions and 72 deletions

View File

@ -2998,24 +2998,75 @@ namespace OpenSim.Region.ClientStack.LindenUDP
OutPacket(economyData, ThrottleOutPacketType.Task); OutPacket(economyData, ThrottleOutPacketType.Task);
} }
public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> 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<UserData> users)
{ {
//construct the AvatarPickerReply packet. UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint);
AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket(); byte[] data = buf.Data;
replyPacket.AgentData.AgentID = AgentData.AgentID;
replyPacket.AgentData.QueryID = AgentData.QueryID; //setup header
//int i = 0; Buffer.BlockCopy(AvatarPickerReplyHeader, 0, data, 0, 10);
List<AvatarPickerReplyPacket.DataBlock> data_block = new List<AvatarPickerReplyPacket.DataBlock>(); AgentId.ToBytes(data, 10); //26
foreach (AvatarPickerReplyDataArgs arg in Data) QueryID.ToBytes(data, 26); //42
if (users.Count == 0)
{ {
AvatarPickerReplyPacket.DataBlock db = new AvatarPickerReplyPacket.DataBlock(); data[42] = 0;
db.AvatarID = arg.AvatarID; buf.DataLength = 43;
db.FirstName = arg.FirstName; m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Task);
db.LastName = arg.LastName; return;
data_block.Add(db); }
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) public void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)

View File

@ -185,7 +185,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
if (p != null && !p.IsDeleted) if (p != null && !p.IsDeleted)
flags |= 0x10; flags |= 0x10;
if(!clients.Contains(client) && client.IsActive) if(clients == null)
{ {
client.SendAvatarProperties(props.UserId, props.AboutText, born, membershipType, props.FirstLifeText, flags, client.SendAvatarProperties(props.UserId, props.AboutText, born, membershipType, props.FirstLifeText, flags,
props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId); props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId);
@ -195,17 +195,30 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
if (agentGroups != null) if (agentGroups != null)
client.SendAvatarGroupsReply(avatarID, agentGroups); client.SendAvatarGroupsReply(avatarID, agentGroups);
} }
foreach (IClientAPI cli in clients) else
{ {
if (!cli.IsActive) if (!clients.Contains(client) && client.IsActive)
continue; {
cli.SendAvatarProperties(props.UserId, props.AboutText, born, membershipType, props.FirstLifeText, flags, client.SendAvatarProperties(props.UserId, props.AboutText, born, membershipType, props.FirstLifeText, flags,
props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId); props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId);
cli.SendAvatarInterestsReply(props.UserId, (uint)props.WantToMask, props.WantToText, client.SendAvatarInterestsReply(props.UserId, (uint)props.WantToMask, props.WantToText,
(uint)props.SkillsMask, props.SkillsText, props.Language); (uint)props.SkillsMask, props.SkillsText, props.Language);
if (agentGroups != null) if (agentGroups != null)
cli.SendAvatarGroupsReply(avatarID, agentGroups); 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);
}
} }
} }
} }

View File

@ -26,6 +26,7 @@
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Concurrent;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
@ -237,51 +238,8 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
//EventManager.TriggerAvatarPickerRequest(); //EventManager.TriggerAvatarPickerRequest();
m_log.DebugFormat("[USER MANAGEMENT MODULE]: HandleAvatarPickerRequest for {0}", query); m_log.DebugFormat("[USER MANAGEMENT MODULE]: HandleAvatarPickerRequest for {0}", query);
List<UserData> users = GetUserData(query, 500, 1); List<UserData> users = GetUserData(query, 500, 1);
client.SendAvatarPickerReply(RequestID, users);
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<AvatarPickerReplyDataArgs> data_args = new List<AvatarPickerReplyDataArgs>();
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);
} }
protected virtual void AddAdditionalUsers(string query, List<UserData> users) protected virtual void AddAdditionalUsers(string query, List<UserData> users)

View File

@ -1176,7 +1176,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
} }
public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data) public void SendAvatarPickerReply(UUID QueryID, List<UserData> users)
{ {
} }

View File

@ -677,7 +677,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
{ {
} }
public virtual void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data) public virtual void SendAvatarPickerReply(UUID QueryID, List<UserData> users)
{ {
} }

View File

@ -583,7 +583,7 @@ namespace OpenSim.Tests.Common
{ {
} }
public virtual void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data) public virtual void SendAvatarPickerReply(UUID QueryID, List<UserData> users)
{ {
} }