mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 09:45:47 +08:00
* Finished SimulationServiceConnector
* Started rerouting calls to UserService. * Compiles. May run.
This commit is contained in:
@@ -37,6 +37,8 @@ using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||
using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
{
|
||||
@@ -46,10 +48,21 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
|
||||
private bool m_Enabled = false;
|
||||
protected List<Scene> m_Scenes = new List<Scene>();
|
||||
protected Dictionary<UUID, ulong> m_UserRegionMap = new Dictionary<UUID, ulong>();
|
||||
protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>();
|
||||
|
||||
public event UndeliveredMessage OnUndeliveredMessage;
|
||||
|
||||
private IPresenceService m_PresenceService;
|
||||
protected IPresenceService PresenceService
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_PresenceService == null)
|
||||
m_PresenceService = m_Scenes[0].RequestModuleInterface<IPresenceService>();
|
||||
return m_PresenceService;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Initialise(IConfigSource config)
|
||||
{
|
||||
IConfig cnf = config.Configs["Messaging"];
|
||||
@@ -416,7 +429,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
/// <summary>
|
||||
/// delegate for sending a grid instant message asynchronously
|
||||
/// </summary>
|
||||
public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, ulong prevRegionHandle);
|
||||
public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID);
|
||||
|
||||
protected virtual void GridInstantMessageCompleted(IAsyncResult iar)
|
||||
{
|
||||
@@ -430,7 +443,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
{
|
||||
GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync;
|
||||
|
||||
d.BeginInvoke(im, result, 0, GridInstantMessageCompleted, d);
|
||||
d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -445,11 +458,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
/// Pass in 0 the first time this method is called. It will be called recursively with the last
|
||||
/// regionhandle tried
|
||||
/// </param>
|
||||
protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, ulong prevRegionHandle)
|
||||
protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID)
|
||||
{
|
||||
UUID toAgentID = new UUID(im.toAgentID);
|
||||
|
||||
UserAgentData upd = null;
|
||||
PresenceInfo upd = null;
|
||||
|
||||
bool lookupAgent = false;
|
||||
|
||||
@@ -457,13 +470,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
{
|
||||
if (m_UserRegionMap.ContainsKey(toAgentID))
|
||||
{
|
||||
upd = new UserAgentData();
|
||||
upd.AgentOnline = true;
|
||||
upd.Handle = m_UserRegionMap[toAgentID];
|
||||
upd = new PresenceInfo();
|
||||
upd.Online = true;
|
||||
upd.RegionID = m_UserRegionMap[toAgentID];
|
||||
|
||||
// We need to compare the current regionhandle with the previous region handle
|
||||
// or the recursive loop will never end because it will never try to lookup the agent again
|
||||
if (prevRegionHandle == upd.Handle)
|
||||
if (prevRegionID == upd.RegionID)
|
||||
{
|
||||
lookupAgent = true;
|
||||
}
|
||||
@@ -479,14 +492,23 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
if (lookupAgent)
|
||||
{
|
||||
// Non-cached user agent lookup.
|
||||
upd = m_Scenes[0].CommsManager.UserService.GetAgentByUUID(toAgentID);
|
||||
PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() });
|
||||
if (presences != null)
|
||||
{
|
||||
foreach (PresenceInfo p in presences)
|
||||
if (p.Online)
|
||||
{
|
||||
upd = presences[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (upd != null)
|
||||
{
|
||||
// check if we've tried this before..
|
||||
// This is one way to end the recursive loop
|
||||
//
|
||||
if (upd.Handle == prevRegionHandle)
|
||||
if (upd.RegionID == prevRegionID)
|
||||
{
|
||||
m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
|
||||
HandleUndeliveredMessage(im, result);
|
||||
@@ -503,12 +525,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
|
||||
if (upd != null)
|
||||
{
|
||||
if (upd.AgentOnline)
|
||||
if (upd.Online)
|
||||
{
|
||||
uint x = 0, y = 0;
|
||||
Utils.LongToUInts(upd.Handle, out x, out y);
|
||||
GridRegion reginfo = m_Scenes[0].GridService.GetRegionByPosition(m_Scenes[0].RegionInfo.ScopeID,
|
||||
(int)x, (int)y);
|
||||
GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID,
|
||||
upd.RegionID);
|
||||
if (reginfo != null)
|
||||
{
|
||||
Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im);
|
||||
@@ -524,11 +544,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
{
|
||||
if (m_UserRegionMap.ContainsKey(toAgentID))
|
||||
{
|
||||
m_UserRegionMap[toAgentID] = upd.Handle;
|
||||
m_UserRegionMap[toAgentID] = upd.RegionID;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_UserRegionMap.Add(toAgentID, upd.Handle);
|
||||
m_UserRegionMap.Add(toAgentID, upd.RegionID);
|
||||
}
|
||||
}
|
||||
result(true);
|
||||
@@ -543,12 +563,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
|
||||
// This is recursive!!!!!
|
||||
SendGridInstantMessageViaXMLRPCAsync(im, result,
|
||||
upd.Handle);
|
||||
upd.RegionID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.Handle);
|
||||
m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID);
|
||||
HandleUndeliveredMessage(im, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
|
||||
try
|
||||
{
|
||||
if (m_aScene.CommsManager.UserService.AuthenticateUserByPassword(userInfo.UserProfile.ID, pass))
|
||||
if (m_aScene.AuthenticationService.Authenticate(userInfo.UserProfile.ID, pass, 1) != string.Empty)
|
||||
{
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles
|
||||
public void RequestAvatarProperty(IClientAPI remoteClient, UUID avatarID)
|
||||
{
|
||||
// FIXME: finish adding fields such as url, masking, etc.
|
||||
UserProfileData profile = m_scene.CommsManager.UserService.GetUserProfile(avatarID);
|
||||
UserProfileData profile = null; // m_scene.CommsManager.UserService.GetUserProfile(avatarID);
|
||||
if (null != profile)
|
||||
{
|
||||
Byte[] charterMember;
|
||||
@@ -143,26 +143,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles
|
||||
|
||||
public void UpdateAvatarProperties(IClientAPI remoteClient, UserProfileData newProfile)
|
||||
{
|
||||
UserProfileData Profile = m_scene.CommsManager.UserService.GetUserProfile(newProfile.ID);
|
||||
return;
|
||||
//UserProfileData Profile = m_scene.CommsManager.UserService.GetUserProfile(newProfile.ID);
|
||||
|
||||
// if it's the profile of the user requesting the update, then we change only a few things.
|
||||
if (remoteClient.AgentId.CompareTo(Profile.ID) == 0)
|
||||
{
|
||||
Profile.Image = newProfile.Image;
|
||||
Profile.FirstLifeImage = newProfile.FirstLifeImage;
|
||||
Profile.AboutText = newProfile.AboutText;
|
||||
Profile.FirstLifeAboutText = newProfile.FirstLifeAboutText;
|
||||
Profile.ProfileUrl = newProfile.ProfileUrl;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_scene.CommsManager.UserService.UpdateUserProfile(Profile))
|
||||
{
|
||||
RequestAvatarProperty(remoteClient, newProfile.ID);
|
||||
}
|
||||
//// if it's the profile of the user requesting the update, then we change only a few things.
|
||||
//if (remoteClient.AgentId.CompareTo(Profile.ID) == 0)
|
||||
//{
|
||||
// Profile.Image = newProfile.Image;
|
||||
// Profile.FirstLifeImage = newProfile.FirstLifeImage;
|
||||
// Profile.AboutText = newProfile.AboutText;
|
||||
// Profile.FirstLifeAboutText = newProfile.FirstLifeAboutText;
|
||||
// Profile.ProfileUrl = newProfile.ProfileUrl;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
|
||||
//if (m_scene.CommsManager.UserService.UpdateUserProfile(Profile))
|
||||
//{
|
||||
// RequestAvatarProperty(remoteClient, newProfile.ID);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,9 +139,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
|
||||
|
||||
if (scene != null)
|
||||
{
|
||||
UserProfileData profile = scene.CommsManager.UserService.GetUserProfile(new UUID(userID));
|
||||
isAuthorized = IsAuthorizedForRegion(userID, profile.FirstName, profile.SurName,
|
||||
profile.Email, scene.RegionInfo.RegionName, regionID, out message);
|
||||
UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, userID);
|
||||
isAuthorized = IsAuthorizedForRegion(userID, account.FirstName, account.LastName,
|
||||
account.Email, scene.RegionInfo.RegionName, regionID, out message);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "RemotePresenceServiceConnector"; }
|
||||
get { return "RemotePresenceServicesConnector"; }
|
||||
}
|
||||
|
||||
public void Initialise(IConfigSource source)
|
||||
|
||||
@@ -172,12 +172,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||
{
|
||||
if (s.RegionInfo.RegionHandle == destination.RegionHandle)
|
||||
{
|
||||
// m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle);
|
||||
m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", destination.RegionName);
|
||||
return s.NewUserConnection(aCircuit, teleportFlags, out reason);
|
||||
}
|
||||
}
|
||||
|
||||
// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle);
|
||||
m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", destination.RegionName);
|
||||
reason = "Did not find region " + destination.RegionName;
|
||||
return false;
|
||||
}
|
||||
@@ -241,14 +241,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ReleaseAgent(GridRegion destination, UUID id, string uri)
|
||||
public bool ReleaseAgent(UUID origin, UUID id, string uri)
|
||||
{
|
||||
if (destination == null)
|
||||
return false;
|
||||
|
||||
foreach (Scene s in m_sceneList)
|
||||
{
|
||||
if (s.RegionInfo.RegionHandle == destination.RegionHandle)
|
||||
if (s.RegionInfo.RegionID == origin)
|
||||
{
|
||||
//m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent");
|
||||
return s.IncomingReleaseAgent(id);
|
||||
@@ -334,6 +331,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsLocalRegion(UUID id)
|
||||
{
|
||||
foreach (Scene s in m_sceneList)
|
||||
if (s.RegionInfo.RegionID == id)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,18 +245,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
|
||||
|
||||
}
|
||||
|
||||
public bool ReleaseAgent(GridRegion destination, UUID id, string uri)
|
||||
public bool ReleaseAgent(UUID origin, UUID id, string uri)
|
||||
{
|
||||
if (destination == null)
|
||||
return false;
|
||||
|
||||
// Try local first
|
||||
if (m_localBackend.ReleaseAgent(destination, id, uri))
|
||||
if (m_localBackend.ReleaseAgent(origin, id, uri))
|
||||
return true;
|
||||
|
||||
// else do the remote thing
|
||||
if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
|
||||
return m_remoteConnector.ReleaseAgent(destination, id, uri);
|
||||
if (!m_localBackend.IsLocalRegion(origin))
|
||||
return m_remoteConnector.ReleaseAgent(origin, id, uri);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user