diff options
author | UbitUmarov | 2019-03-18 21:04:42 +0000 |
---|---|---|
committer | UbitUmarov | 2019-03-18 21:04:42 +0000 |
commit | 606d09670958c59b1b2daf75064ca36a17df248c (patch) | |
tree | 7d6853bb53804aaf808af05467f31c7a5f4547ed /OpenSim/Region | |
parent | lludp ChatFromSimulator enconding; some simplification (diff) | |
download | opensim-SC-606d09670958c59b1b2daf75064ca36a17df248c.zip opensim-SC-606d09670958c59b1b2daf75064ca36a17df248c.tar.gz opensim-SC-606d09670958c59b1b2daf75064ca36a17df248c.tar.bz2 opensim-SC-606d09670958c59b1b2daf75064ca36a17df248c.tar.xz |
lludp ImprovedInstantMessage enconding
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 115 |
1 files changed, 93 insertions, 22 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 97b2c5c..a44185a 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -973,34 +973,105 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
973 | /// Send an instant message to this client | 973 | /// Send an instant message to this client |
974 | /// </summary> | 974 | /// </summary> |
975 | // | 975 | // |
976 | |||
977 | static private readonly byte[] ImprovedInstantMessageHeader = new byte[] { | ||
978 | Helpers.MSG_RELIABLE, //| Helpers.MSG_ZEROCODED, not doing spec zeroencode on this | ||
979 | 0, 0, 0, 0, // sequence number | ||
980 | 0, // extra | ||
981 | 0xff, 0xff, 0, 254 // ID 139 (low frequency bigendian) | ||
982 | }; | ||
983 | |||
976 | public void SendInstantMessage(GridInstantMessage im) | 984 | public void SendInstantMessage(GridInstantMessage im) |
977 | { | 985 | { |
978 | if (((Scene)(m_scene)).Permissions.CanInstantMessage(new UUID(im.fromAgentID), new UUID(im.toAgentID))) | 986 | UUID fromAgentID = new UUID(im.fromAgentID); |
987 | UUID toAgentID = new UUID(im.toAgentID); | ||
988 | |||
989 | if (!m_scene.Permissions.CanInstantMessage(fromAgentID, toAgentID)) | ||
990 | return; | ||
991 | |||
992 | UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); | ||
993 | byte[] data = buf.Data; | ||
994 | |||
995 | //setup header | ||
996 | Buffer.BlockCopy(ImprovedInstantMessageHeader, 0, data, 0, 10); | ||
997 | |||
998 | //agentdata block | ||
999 | fromAgentID.ToBytes(data, 10); // 26 | ||
1000 | UUID.Zero.ToBytes(data, 26); // 42 sessionID zero?? TO check | ||
1001 | |||
1002 | int pos = 42; | ||
1003 | |||
1004 | //MessageBlock | ||
1005 | data[pos++] = (byte)((im.fromGroup) ? 1 : 0); | ||
1006 | toAgentID.ToBytes(data, pos); pos += 16; | ||
1007 | Utils.UIntToBytesSafepos(im.ParentEstateID, data, pos); pos += 4; | ||
1008 | (new UUID(im.RegionID)).ToBytes(data, pos); pos += 16; | ||
1009 | (im.Position).ToBytes(data, pos); pos += 12; | ||
1010 | data[pos++] = im.offline; | ||
1011 | data[pos++] = im.dialog; | ||
1012 | |||
1013 | // this is odd | ||
1014 | if (im.imSessionID == UUID.Zero.Guid) | ||
1015 | (fromAgentID ^ toAgentID).ToBytes(data, pos); | ||
1016 | else | ||
1017 | (new UUID(im.imSessionID)).ToBytes(data, pos); | ||
1018 | |||
1019 | pos += 16; | ||
1020 | |||
1021 | Utils.UIntToBytesSafepos(im.timestamp, data, pos); pos += 4; | ||
1022 | |||
1023 | byte[] tmp = Util.StringToBytes256(im.fromAgentName); | ||
1024 | int len = tmp.Length; | ||
1025 | data[pos++] = (byte)len; | ||
1026 | if(len > 0) | ||
1027 | Buffer.BlockCopy(tmp, 0, data, pos, len); pos += len; | ||
1028 | |||
1029 | tmp = Util.StringToBytes1024(im.message); | ||
1030 | len = tmp.Length; | ||
1031 | if (len == 0) | ||
1032 | { | ||
1033 | data[pos++] = 0; | ||
1034 | data[pos++] = 0; | ||
1035 | } | ||
1036 | else | ||
979 | { | 1037 | { |
980 | ImprovedInstantMessagePacket msg | 1038 | data[pos++] = (byte)len; |
981 | = (ImprovedInstantMessagePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage); | 1039 | data[pos++] = (byte)(len >> 8); |
1040 | Buffer.BlockCopy(tmp, 0, data, pos, len); pos += len; | ||
1041 | } | ||
982 | 1042 | ||
983 | msg.AgentData.AgentID = new UUID(im.fromAgentID); | 1043 | tmp = im.binaryBucket; |
984 | msg.AgentData.SessionID = UUID.Zero; | 1044 | if(tmp == null) |
985 | msg.MessageBlock.FromAgentName = Util.StringToBytes256(im.fromAgentName); | 1045 | { |
986 | msg.MessageBlock.Dialog = im.dialog; | 1046 | data[pos++] = 0; |
987 | msg.MessageBlock.FromGroup = im.fromGroup; | 1047 | data[pos++] = 0; |
988 | // this is odd | 1048 | } |
989 | if (im.imSessionID == UUID.Zero.Guid) | 1049 | else |
990 | msg.MessageBlock.ID = new UUID(im.fromAgentID) ^ new UUID(im.toAgentID); | 1050 | { |
1051 | len = tmp.Length; | ||
1052 | if (len == 0) | ||
1053 | { | ||
1054 | data[pos++] = 0; | ||
1055 | data[pos++] = 0; | ||
1056 | } | ||
991 | else | 1057 | else |
992 | msg.MessageBlock.ID = new UUID(im.imSessionID); | 1058 | { |
993 | msg.MessageBlock.Offline = im.offline; | 1059 | data[pos++] = (byte)len; |
994 | msg.MessageBlock.ParentEstateID = im.ParentEstateID; | 1060 | data[pos++] = (byte)(len >> 8); |
995 | msg.MessageBlock.Position = im.Position; | 1061 | Buffer.BlockCopy(tmp, 0, data, pos, len); pos += len; |
996 | msg.MessageBlock.RegionID = new UUID(im.RegionID); | 1062 | } |
997 | msg.MessageBlock.Timestamp = im.timestamp; | ||
998 | msg.MessageBlock.ToAgentID = new UUID(im.toAgentID); | ||
999 | msg.MessageBlock.Message = Util.StringToBytes1024(im.message); | ||
1000 | msg.MessageBlock.BinaryBucket = im.binaryBucket; | ||
1001 | |||
1002 | OutPacket(msg, ThrottleOutPacketType.Task); | ||
1003 | } | 1063 | } |
1064 | |||
1065 | //EstateBlock does not seem in use TODO | ||
1066 | //Utils.UIntToBytesSafepos(m_scene.RegionInfo.EstateSettings.EstateID, data, pos); pos += 4; | ||
1067 | data[pos++] = 0; | ||
1068 | data[pos++] = 0; | ||
1069 | data[pos++] = 0; | ||
1070 | data[pos++] = 0; | ||
1071 | |||
1072 | buf.DataLength = pos; | ||
1073 | //m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Unknown, null, false, true); | ||
1074 | m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Unknown); | ||
1004 | } | 1075 | } |
1005 | 1076 | ||
1006 | public void SendGenericMessage(string method, UUID invoice, List<string> message) | 1077 | public void SendGenericMessage(string method, UUID invoice, List<string> message) |