lludp ImprovedInstantMessage enconding

0.9.1.0-post-fixes
UbitUmarov 2019-03-18 21:04:42 +00:00
parent 6fd7b931b1
commit 606d096709
1 changed files with 95 additions and 24 deletions

View File

@ -973,34 +973,105 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// Send an instant message to this client /// Send an instant message to this client
/// </summary> /// </summary>
// //
static private readonly byte[] ImprovedInstantMessageHeader = new byte[] {
Helpers.MSG_RELIABLE, //| Helpers.MSG_ZEROCODED, not doing spec zeroencode on this
0, 0, 0, 0, // sequence number
0, // extra
0xff, 0xff, 0, 254 // ID 139 (low frequency bigendian)
};
public void SendInstantMessage(GridInstantMessage im) public void SendInstantMessage(GridInstantMessage im)
{ {
if (((Scene)(m_scene)).Permissions.CanInstantMessage(new UUID(im.fromAgentID), new UUID(im.toAgentID))) UUID fromAgentID = new UUID(im.fromAgentID);
{ UUID toAgentID = new UUID(im.toAgentID);
ImprovedInstantMessagePacket msg
= (ImprovedInstantMessagePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage); if (!m_scene.Permissions.CanInstantMessage(fromAgentID, toAgentID))
return;
UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint);
byte[] data = buf.Data;
//setup header
Buffer.BlockCopy(ImprovedInstantMessageHeader, 0, data, 0, 10);
//agentdata block
fromAgentID.ToBytes(data, 10); // 26
UUID.Zero.ToBytes(data, 26); // 42 sessionID zero?? TO check
int pos = 42;
//MessageBlock
data[pos++] = (byte)((im.fromGroup) ? 1 : 0);
toAgentID.ToBytes(data, pos); pos += 16;
Utils.UIntToBytesSafepos(im.ParentEstateID, data, pos); pos += 4;
(new UUID(im.RegionID)).ToBytes(data, pos); pos += 16;
(im.Position).ToBytes(data, pos); pos += 12;
data[pos++] = im.offline;
data[pos++] = im.dialog;
msg.AgentData.AgentID = new UUID(im.fromAgentID);
msg.AgentData.SessionID = UUID.Zero;
msg.MessageBlock.FromAgentName = Util.StringToBytes256(im.fromAgentName);
msg.MessageBlock.Dialog = im.dialog;
msg.MessageBlock.FromGroup = im.fromGroup;
// this is odd // this is odd
if (im.imSessionID == UUID.Zero.Guid) if (im.imSessionID == UUID.Zero.Guid)
msg.MessageBlock.ID = new UUID(im.fromAgentID) ^ new UUID(im.toAgentID); (fromAgentID ^ toAgentID).ToBytes(data, pos);
else else
msg.MessageBlock.ID = new UUID(im.imSessionID); (new UUID(im.imSessionID)).ToBytes(data, pos);
msg.MessageBlock.Offline = im.offline;
msg.MessageBlock.ParentEstateID = im.ParentEstateID;
msg.MessageBlock.Position = im.Position;
msg.MessageBlock.RegionID = new UUID(im.RegionID);
msg.MessageBlock.Timestamp = im.timestamp;
msg.MessageBlock.ToAgentID = new UUID(im.toAgentID);
msg.MessageBlock.Message = Util.StringToBytes1024(im.message);
msg.MessageBlock.BinaryBucket = im.binaryBucket;
OutPacket(msg, ThrottleOutPacketType.Task); pos += 16;
Utils.UIntToBytesSafepos(im.timestamp, data, pos); pos += 4;
byte[] tmp = Util.StringToBytes256(im.fromAgentName);
int len = tmp.Length;
data[pos++] = (byte)len;
if(len > 0)
Buffer.BlockCopy(tmp, 0, data, pos, len); pos += len;
tmp = Util.StringToBytes1024(im.message);
len = tmp.Length;
if (len == 0)
{
data[pos++] = 0;
data[pos++] = 0;
} }
else
{
data[pos++] = (byte)len;
data[pos++] = (byte)(len >> 8);
Buffer.BlockCopy(tmp, 0, data, pos, len); pos += len;
}
tmp = im.binaryBucket;
if(tmp == null)
{
data[pos++] = 0;
data[pos++] = 0;
}
else
{
len = tmp.Length;
if (len == 0)
{
data[pos++] = 0;
data[pos++] = 0;
}
else
{
data[pos++] = (byte)len;
data[pos++] = (byte)(len >> 8);
Buffer.BlockCopy(tmp, 0, data, pos, len); pos += len;
}
}
//EstateBlock does not seem in use TODO
//Utils.UIntToBytesSafepos(m_scene.RegionInfo.EstateSettings.EstateID, data, pos); pos += 4;
data[pos++] = 0;
data[pos++] = 0;
data[pos++] = 0;
data[pos++] = 0;
buf.DataLength = pos;
//m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Unknown, null, false, true);
m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Unknown);
} }
public void SendGenericMessage(string method, UUID invoice, List<string> message) public void SendGenericMessage(string method, UUID invoice, List<string> message)