Grab the presence module and load the friends connector into the friends module

slimupdates
Melanie 2010-02-25 03:07:46 +00:00
parent c7b1e76eb5
commit e776bf9316
1 changed files with 33 additions and 0 deletions

View File

@ -52,6 +52,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
protected int m_Port = 0; protected int m_Port = 0;
protected List<Scene> m_Scenes = new List<Scene>();
protected IPresenceService m_PresenceService = null;
protected IFriendsService m_FriendsService = null;
protected IPresenceService PresenceService
{
get
{
if (m_PresenceService == null)
{
if (m_Scenes.Count > 0)
m_PresenceService = m_Scenes[0].RequestModuleInterface<IPresenceService>();
}
return m_PresenceService;
}
}
public FriendsModule() public FriendsModule()
: base("POST", "/friends") : base("POST", "/friends")
{ {
@ -63,6 +82,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (friendsConfig != null) if (friendsConfig != null)
{ {
m_Port = friendsConfig.GetInt("Port", m_Port); m_Port = friendsConfig.GetInt("Port", m_Port);
string connector = friendsConfig.GetString("Connector", String.Empty);
Object[] args = new Object[] { config };
m_FriendsService = ServerUtils.LoadPlugin<IFriendsService>(connector, args);
}
if (m_FriendsService == null)
{
m_log.Error("[FRIENDS]: No Connector defined in section Friends, or filed to load, cannot continue");
throw new Exception("Connector load error");
} }
IHttpServer server = MainServer.GetHttpServer((uint)m_Port); IHttpServer server = MainServer.GetHttpServer((uint)m_Port);
@ -81,6 +111,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
public void AddRegion(Scene scene) public void AddRegion(Scene scene)
{ {
m_Scenes.Add(scene);
scene.RegisterModuleInterface<IFriendsModule>(this);
} }
public void RegionLoaded(Scene scene) public void RegionLoaded(Scene scene)
@ -89,6 +121,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
{ {
m_Scenes.Remove(scene);
} }
public override byte[] Handle(string path, Stream requestData, public override byte[] Handle(string path, Stream requestData,