public void llInstantMessage(string user, string message)
{
m_host.AddScriptLPS(1);
UUID result;
if (!UUID.TryParse(user, out result) || result == UUID.Zero)
{
Error("llInstantMessage","An invalid key was passed to llInstantMessage");
ScriptSleep(2000);
return;
}
// We may be able to use ClientView.SendInstantMessage here, but we need a client instance.
// InstantMessageModule.OnInstantMessage searches through a list of scenes for a client matching the toAgent,
// but I don't think we have a list of scenes available from here.
// (We also don't want to duplicate the code in OnInstantMessage if we can avoid it.)
// user is a UUID
// TODO: figure out values for client, fromSession, and imSessionID
// client.SendInstantMessage(m_host.UUID, fromSession, message, user, imSessionID, m_host.Name, AgentManager.InstantMessageDialog.MessageFromAgent, (uint)Util.UnixTimeSinceEpoch());
UUID friendTransactionID = UUID.Random();
//m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
GridInstantMessage msg = new GridInstantMessage();
msg.fromAgentID = new Guid(m_host.OwnerID.ToString()); // fromAgentID.Guid;
msg.toAgentID = new Guid(user); // toAgentID.Guid;
msg.imSessionID = new Guid(m_host.UUID.ToString()); // This is the item we're mucking with here
msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName;
if (message != null && message.Length > 1024)
msg.message = message.Substring(0, 1024);
else
msg.message = message;
msg.dialog = (byte)19; // MessageFromObject
msg.fromGroup = false;// fromGroup;
msg.offline = (byte)0; //offline;
msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID;
msg.Position = new Vector3(m_host.AbsolutePosition);
msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid;
Vector3 pos = m_host.AbsolutePosition;
msg.binaryBucket
= Util.StringToBytes256(
"{0}/{1}/{2}/{3}",
World.RegionInfo.RegionName,
(int)Math.Floor(pos.X),
(int)Math.Floor(pos.Y),
(int)Math.Floor(pos.Z));
if (m_TransferModule != null)
{
m_TransferModule.SendInstantMessage(msg, delegate(bool success) {});
}
ScriptSleep(m_sleepMsOnInstantMessage);
}