* Instant Message functionality moved into a Region Modules

* You can now send instant messages to any user on the simulator, regardless of what region they are in.
afrisby
Adam Frisby 2007-10-19 19:25:22 +00:00
parent f756b1ee1c
commit d8cbd173f5
3 changed files with 41 additions and 39 deletions

View File

@ -26,18 +26,55 @@
* *
*/ */
using System.Collections.Generic;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using OpenSim.Framework.Console;
namespace OpenSim.Region.Environment.Modules namespace OpenSim.Region.Environment.Modules
{ {
public class InstantMessageModule : IRegionModule public class InstantMessageModule : IRegionModule
{ {
private Scene m_scene; private List<Scene> m_scenes;
private LogBase m_log;
public void Initialise(Scene scene) public void Initialise(Scene scene)
{ {
m_scene = scene; if (!m_scenes.Contains(scene))
m_scenes.Add(scene);
scene.EventManager.OnNewClient += OnNewClient;
m_log = OpenSim.Framework.Console.MainLog.Instance;
}
void OnNewClient(OpenSim.Framework.Interfaces.IClientAPI client)
{
client.OnInstantMessage += OnInstantMessage;
}
void OnInstantMessage(libsecondlife.LLUUID fromAgentID,
libsecondlife.LLUUID fromAgentSession, libsecondlife.LLUUID toAgentID,
libsecondlife.LLUUID imSessionID, uint timestamp, string fromAgentName,
string message, byte dialog)
{
// TODO: Remove after debugging. Privacy implications.
m_log.Verbose("IM",fromAgentName + ": " + message);
foreach (Scene m_scene in m_scenes)
{
if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
{
// Local Message
ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID];
user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message,
toAgentID, imSessionID, user.Firstname + " " + user.Lastname, dialog, timestamp);
// Message sent
return;
}
}
// Still here, try send via Grid
} }
public void PostInitialise() public void PostInitialise()
@ -55,7 +92,7 @@ namespace OpenSim.Region.Environment.Modules
public bool IsSharedModule public bool IsSharedModule
{ {
get { return false; } get { return true; }
} }
} }
} }

View File

@ -57,40 +57,6 @@ namespace OpenSim.Region.Environment.Scenes
Terrain.ModifyTerrain(height, seconds, brushsize, action, north, west, remoteUser); Terrain.ModifyTerrain(height, seconds, brushsize, action, north, west, remoteUser);
} }
/// <summary>
///
/// </summary>
/// <remarks>Inefficient. TODO: Fixme</remarks>
/// <param name="fromAgentID"></param>
/// <param name="toAgentID"></param>
/// <param name="timestamp"></param>
/// <param name="fromAgentName"></param>
/// <param name="message"></param>
public void InstantMessage(LLUUID fromAgentID, LLUUID fromAgentSession, LLUUID toAgentID, LLUUID imSessionID,
uint timestamp, string fromAgentName, string message, byte dialog)
{
if (m_scenePresences.ContainsKey(toAgentID))
{
if (m_scenePresences.ContainsKey(fromAgentID))
{
// Local sim message
ScenePresence fromAvatar = m_scenePresences[fromAgentID];
ScenePresence toAvatar = m_scenePresences[toAgentID];
string fromName = fromAvatar.Firstname + " " + fromAvatar.Lastname;
toAvatar.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, toAgentID,
imSessionID, fromName, dialog, timestamp);
}
else
{
// Message came from a user outside the sim, ignore?
}
}
else
{
// Grid message
}
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -531,4 +497,4 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
} }
} }

View File

@ -739,7 +739,6 @@ namespace OpenSim.Region.Environment.Scenes
//remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims);
client.OnModifyTerrain += ModifyTerrain; client.OnModifyTerrain += ModifyTerrain;
//client.OnChatFromViewer += SimChat; //client.OnChatFromViewer += SimChat;
client.OnInstantMessage += InstantMessage;
client.OnRequestWearables += InformClientOfNeighbours; client.OnRequestWearables += InformClientOfNeighbours;
client.OnAddPrim += AddNewPrim; client.OnAddPrim += AddNewPrim;
client.OnUpdatePrimGroupPosition += UpdatePrimPosition; client.OnUpdatePrimGroupPosition += UpdatePrimPosition;