From c483206fd7ecd67ac4fc8c4e4b71f65dfd3de6c4 Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Sun, 29 Mar 2009 05:42:27 +0000
Subject: Change the client API to use GridInstantMessage for the "last mile"
of IM sending. With this change, all methods that handle IM now use
GridInstantMessage rather than individual parameters.
---
.../Region/ClientStack/LindenUDP/LLClientView.cs | 64 +++++++++-------------
.../CoreModules/Avatar/Friends/FriendsModule.cs | 8 ++-
.../Avatar/InstantMessage/InstantMessageModule.cs | 12 ++--
.../Avatar/InstantMessage/MessageTransferModule.cs | 24 ++------
.../Avatar/InstantMessage/OfflineMessageModule.cs | 16 +++---
.../Inventory/Transfer/InventoryTransferModule.cs | 30 ++--------
.../Region/Examples/SimpleModule/MyNpcCharacter.cs | 7 +--
.../Region/OptionalModules/World/NPC/NPCAvatar.cs | 7 +--
8 files changed, 57 insertions(+), 111 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 7d9efa6..ab643ae 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -1190,68 +1190,58 @@ namespace OpenSim.Region.ClientStack.LindenUDP
///
/// Send an instant message to this client
///
- public void SendInstantMessage(UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, uint timeStamp)
- {
- SendInstantMessage(fromAgent, message, toAgent, fromName, dialog, timeStamp, UUID.Zero, false, new byte[0]);
- }
-
- ///
- /// Send an instant message to this client
- ///
//
// Don't remove transaction ID! Groups and item gives need to set it!
- public void SendInstantMessage(UUID fromAgent, string message, UUID toAgent,
- string fromName, byte dialog, uint timeStamp,
- UUID transactionID, bool fromGroup, byte[] binaryBucket)
+ public void SendInstantMessage(GridInstantMessage im)
{
- if (((Scene)(m_scene)).Permissions.CanInstantMessage(fromAgent, toAgent))
+ if (((Scene)(m_scene)).Permissions.CanInstantMessage(new UUID(im.fromAgentID), new UUID(im.toAgentID)))
{
ImprovedInstantMessagePacket msg
= (ImprovedInstantMessagePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage);
- msg.AgentData.AgentID = fromAgent;
+ msg.AgentData.AgentID = new UUID(im.fromAgentID);
msg.AgentData.SessionID = UUID.Zero;
- msg.MessageBlock.FromAgentName = Utils.StringToBytes(fromName);
- msg.MessageBlock.Dialog = dialog;
- msg.MessageBlock.FromGroup = fromGroup;
- if (transactionID == UUID.Zero)
- msg.MessageBlock.ID = fromAgent ^ toAgent;
+ msg.MessageBlock.FromAgentName = Utils.StringToBytes(im.fromAgentName);
+ msg.MessageBlock.Dialog = im.dialog;
+ msg.MessageBlock.FromGroup = im.fromGroup;
+ if (im.imSessionID == UUID.Zero.Guid)
+ msg.MessageBlock.ID = new UUID(im.fromAgentID) ^ new UUID(im.toAgentID);
else
- msg.MessageBlock.ID = transactionID;
- msg.MessageBlock.Offline = 0;
- msg.MessageBlock.ParentEstateID = 0;
- msg.MessageBlock.Position = new Vector3();
- msg.MessageBlock.RegionID = UUID.Zero;
- msg.MessageBlock.Timestamp = timeStamp;
- msg.MessageBlock.ToAgentID = toAgent;
+ msg.MessageBlock.ID = new UUID(im.imSessionID);
+ 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);
// Cap the message length at 1099. There is a limit in ImprovedInstantMessagePacket
// the limit is 1100 but a 0 byte gets added to mark the end of the string
- if (message != null && message.Length > 1099)
- msg.MessageBlock.Message = Utils.StringToBytes(message.Substring(0, 1099));
+ if (im.message != null && im.message.Length > 1099)
+ msg.MessageBlock.Message = Utils.StringToBytes(im.message.Substring(0, 1099));
else
- msg.MessageBlock.Message = Utils.StringToBytes(message);
- msg.MessageBlock.BinaryBucket = binaryBucket;
+ msg.MessageBlock.Message = Utils.StringToBytes(im.message);
+ msg.MessageBlock.BinaryBucket = im.binaryBucket;
- if (message.StartsWith("[grouptest]"))
+ if (im.message.StartsWith("[grouptest]"))
{ // this block is test code for implementing group IM - delete when group IM is finished
IEventQueue eq = Scene.RequestModuleInterface();
if (eq != null)
{
- dialog = 17;
+ im.dialog = 17;
//eq.ChatterboxInvitation(
// new UUID("00000000-68f9-1111-024e-222222111123"),
- // "OpenSimulator Testing", fromAgent, message, toAgent, fromName, dialog, 0,
- // false, 0, new Vector3(), 1, transactionID, fromGroup, binaryBucket);
+ // "OpenSimulator Testing", im.fromAgentID, im.message, im.toAgentID, im.fromAgentName, im.dialog, 0,
+ // false, 0, new Vector3(), 1, im.imSessionID, im.fromGroup, im.binaryBucket);
eq.ChatterboxInvitation(
new UUID("00000000-68f9-1111-024e-222222111123"),
- "OpenSimulator Testing", fromAgent, message, toAgent, fromName, dialog, 0,
- false, 0, new Vector3(), 1, transactionID, fromGroup, Utils.StringToBytes("OpenSimulator Testing"));
+ "OpenSimulator Testing", new UUID(im.fromAgentID), im.message, new UUID(im.toAgentID), im.fromAgentName, im.dialog, 0,
+ false, 0, new Vector3(), 1, new UUID(im.imSessionID), im.fromGroup, Utils.StringToBytes("OpenSimulator Testing"));
eq.ChatterBoxSessionAgentListUpdates(
new UUID("00000000-68f9-1111-024e-222222111123"),
- fromAgent, toAgent, false, false, false);
+ new UUID(im.fromAgentID), new UUID(im.toAgentID), false, false, false);
}
Console.WriteLine("SendInstantMessage: " + msg);
@@ -7645,7 +7635,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
{
if (!ChildAgentStatus())
- SendInstantMessage(FromAvatarID, Message, AgentId, FromAvatarName, 1, (uint)Util.UnixTimeSinceEpoch());
+ SendInstantMessage(new GridInstantMessage(null, FromAvatarID, FromAvatarName, AgentId, 1, Message, false, new Vector3()));
//SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch());
}
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index d91e10d..edb2c56 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -679,9 +679,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
CreateCallingCard(client, friendID, callingCardFolders[0], friendPresence.Name);
// local message means OnGridInstantMessage won't be triggered, so do the work here.
- friendPresence.ControllingClient.SendInstantMessage(agentID, agentID.ToString(), friendID, client.Name,
- (byte)InstantMessageDialog.FriendshipAccepted,
- (uint)Util.UnixTimeSinceEpoch());
+ friendPresence.ControllingClient.SendInstantMessage(
+ new GridInstantMessage(client.Scene, agentID,
+ client.Name, friendID,
+ (byte)InstantMessageDialog.FriendshipAccepted,
+ agentID.ToString(), false, Vector3.Zero));
ApproveFriendship(agentID, friendID, client.Name);
}
else
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
index 01717ce..038f5c1 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
@@ -137,12 +137,14 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
if ((client != null) && !success)
{
- client.SendInstantMessage(new UUID(im.toAgentID),
- "Unable to send instant message. "+
- "User is not logged in.",
- new UUID(im.fromAgentID), "System",
+ client.SendInstantMessage(
+ new GridInstantMessage(
+ null, new UUID(im.fromAgentID), "System",
+ new UUID(im.toAgentID),
(byte)InstantMessageDialog.BusyAutoResponse,
- (uint)Util.UnixTimeSinceEpoch());
+ "Unable to send instant message. "+
+ "User is not logged in.", false,
+ new Vector3()));
}
}
);
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index d8d6219..23aaabe 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -113,16 +113,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
if (!user.IsChildAgent)
{
m_log.DebugFormat("[INSTANT MESSAGE]: Delivering to client");
- user.ControllingClient.SendInstantMessage(
- new UUID(im.fromAgentID),
- im.message,
- new UUID(im.toAgentID),
- im.fromAgentName,
- im.dialog,
- im.timestamp,
- new UUID(im.imSessionID),
- im.fromGroup,
- im.binaryBucket);
+ user.ControllingClient.SendInstantMessage(im);
+
// Message sent
result(true);
return;
@@ -143,16 +135,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
ScenePresence user = (ScenePresence) scene.Entities[toAgentID];
m_log.DebugFormat("[INSTANT MESSAGE]: Delivering to client");
- user.ControllingClient.SendInstantMessage(
- new UUID(im.fromAgentID),
- im.message,
- new UUID(im.toAgentID),
- im.fromAgentName,
- im.dialog,
- im.timestamp,
- new UUID(im.imSessionID),
- im.fromGroup,
- im.binaryBucket);
+ user.ControllingClient.SendInstantMessage(im);
+
// Message sent
result(true);
return;
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index 814b2de..9eb8e27 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -167,11 +167,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{
DateTime saved = Util.ToDateTime((uint)im.timestamp);
- client.SendInstantMessage(new UUID(im.toAgentID),
- "(saved " + saved.ToString() + ") " + im.message,
- new UUID(im.fromAgentID), im.fromAgentName,
- (byte)im.dialog,
- (uint)im.timestamp);
+ im.message = "(saved " + saved.ToString() + ") " + im.message;
+ client.SendInstantMessage(im);
}
}
@@ -188,12 +185,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
if (client == null)
return;
- client.SendInstantMessage(new UUID(im.fromAgentID),
+ client.SendInstantMessage(new GridInstantMessage(
+ null, new UUID(im.toAgentID),
+ "System", new UUID(im.fromAgentID),
+ (byte)InstantMessageDialog.MessageFromAgent,
"User is not logged in. "+
(success ? "Message saved." : "Message not saved"),
- new UUID(im.toAgentID), "System",
- (byte)InstantMessageDialog.MessageFromAgent,
- (uint)Util.UnixTimeSinceEpoch());
+ false, new Vector3()));
}
}
}
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index 2939282..b8e4f08 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -212,11 +212,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
// And notify. Transaction ID is the item ID. We get that
// same ID back on the reply so we know what to act on
//
- user.ControllingClient.SendInstantMessage(
- new UUID(im.fromAgentID), im.message,
- new UUID(im.toAgentID),
- im.fromAgentName, im.dialog, im.timestamp,
- copyID, false, im.binaryBucket);
+ user.ControllingClient.SendInstantMessage(im);
return;
}
@@ -232,11 +228,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
if (user != null) // Local
{
- user.ControllingClient.SendInstantMessage(
- new UUID(im.fromAgentID), im.message,
- new UUID(im.toAgentID),
- im.fromAgentName, im.dialog, im.timestamp,
- UUID.Zero, false, im.binaryBucket);
+ user.ControllingClient.SendInstantMessage(im);
}
else
{
@@ -303,11 +295,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
if (user != null) // Local
{
- user.ControllingClient.SendInstantMessage(
- new UUID(im.fromAgentID), im.message,
- new UUID(im.toAgentID),
- im.fromAgentName, im.dialog, im.timestamp,
- UUID.Zero, false, im.binaryBucket);
+ user.ControllingClient.SendInstantMessage(im);
}
else
{
@@ -460,11 +448,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
// Deliver message
//
- user.ControllingClient.SendInstantMessage(
- new UUID(msg.fromAgentID), msg.message,
- new UUID(msg.toAgentID),
- msg.fromAgentName, msg.dialog, msg.timestamp,
- folderID, false, msg.binaryBucket);
+ user.ControllingClient.SendInstantMessage(msg);
}
else
{
@@ -497,11 +481,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
// Deliver message
//
- user.ControllingClient.SendInstantMessage(
- new UUID(msg.fromAgentID), msg.message,
- new UUID(msg.toAgentID),
- msg.fromAgentName, msg.dialog, msg.timestamp,
- itemID, false, msg.binaryBucket);
+ user.ControllingClient.SendInstantMessage(msg);
}
}
}
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index 82d84fa..82d0198 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -416,12 +416,7 @@ namespace OpenSim.Region.Examples.SimpleModule
{
}
- public void SendInstantMessage(UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, uint timeStamp)
- {
-
- }
-
- public void SendInstantMessage(UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, uint timeStamp, UUID transactionID, bool fromGroup, byte[] binaryBucket)
+ public void SendInstantMessage(GridInstantMessage im)
{
}
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 415a24a..a2ca008 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -505,12 +505,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
{
}
- public void SendInstantMessage(UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, uint timeStamp)
- {
-
- }
-
- public void SendInstantMessage(UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, uint timeStamp, UUID transationID, bool fromGroup, byte[] binaryBucket)
+ public void SendInstantMessage(GridInstantMessage im)
{
}
--
cgit v1.1