XmlRpcGridRouter

Flesh out XmlRpcGridRouter to reap unused channels from gateway when scripts or objects are removed, or when the llCloseRemoteDataChannel is called.

  See: http://http://forge.opensimulator.org/gf/project/xmlrpcrouter/ or
       https://github.com/BlueWall/XmlRpcRouter

  for php gateway and test code.
integration
BlueWall 2012-12-03 20:09:54 -05:00
parent 09dc8d6f96
commit 8a3a7fbf83
4 changed files with 79 additions and 21 deletions

View File

@ -34,5 +34,6 @@ namespace OpenSim.Region.Framework.Interfaces
void RegisterNewReceiver(IScriptModule scriptEngine, UUID channelID, UUID objectID, UUID itemID, string url);
void ScriptRemoved(UUID itemID);
void ObjectRemoved(UUID objectID);
void UnRegisterReceiver(string channelID, UUID itemID);
}
}

View File

@ -46,6 +46,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
{
public class XmlRpcInfo
{
public UUID item;
public UUID channel;
public string uri;
}
@ -88,6 +89,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
return;
scene.RegisterModuleInterface<IXmlRpcRouter>(this);
IScriptModule scriptEngine = scene.RequestModuleInterface<IScriptModule>();
if ( scriptEngine != null )
{
scriptEngine.OnScriptRemoved += this.ScriptRemoved;
scriptEngine.OnObjectRemoved += this.ObjectRemoved;
}
}
public void RegionLoaded(Scene scene)
@ -120,11 +129,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri)
{
if (!m_Channels.ContainsKey(itemID))
{
if (!m_Enabled)
return;
m_log.InfoFormat("[XMLRPC GRID ROUTER]: New receiver Obj: {0} Ch: {1} ID: {2} URI: {3}",
objectID.ToString(), channel.ToString(), itemID.ToString(), uri);
XmlRpcInfo info = new XmlRpcInfo();
info.channel = channel;
info.uri = uri;
info.item = itemID;
bool success = SynchronousRestObjectRequester.MakeRequest<XmlRpcInfo, bool>(
"POST", m_ServerURI+"/RegisterChannel/", info);
@ -135,7 +149,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
}
m_Channels[itemID] = channel;
}
public void UnRegisterReceiver(string channelID, UUID itemID)
{
if (!m_Enabled)
return;
RemoveChannel(itemID);
}
public void ScriptRemoved(UUID itemID)
@ -143,10 +166,33 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
if (!m_Enabled)
return;
if (m_Channels.ContainsKey(itemID))
RemoveChannel(itemID);
}
public void ObjectRemoved(UUID objectID)
{
bool success = SynchronousRestObjectRequester.MakeRequest<UUID, bool>(
"POST", m_ServerURI+"/RemoveChannel/", m_Channels[itemID]);
// m_log.InfoFormat("[XMLRPC GRID ROUTER]: Object Removed {0}",objectID.ToString());
}
private bool RemoveChannel(UUID itemID)
{
if(!m_Channels.ContainsKey(itemID))
{
m_log.InfoFormat("[XMLRPC GRID ROUTER]: Attempted to unregister non-existing Item: {0}", itemID.ToString());
return false;
}
XmlRpcInfo info = new XmlRpcInfo();
info.channel = m_Channels[itemID];
info.item = itemID;
info.uri = "http://0.0.0.0:00";
if (info != null)
{
bool success = SynchronousRestObjectRequester.MakeRequest<XmlRpcInfo, bool>(
"POST", m_ServerURI+"/RemoveChannel/", info);
if (!success)
{
@ -154,11 +200,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
}
m_Channels.Remove(itemID);
return true;
}
}
public void ObjectRemoved(UUID objectID)
{
return false;
}
}
}

View File

@ -101,12 +101,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule
scriptEngine.PostScriptEvent(itemID, "xmlrpc_uri", new Object[] {uri});
}
public void UnRegisterReceiver(string channelID, UUID itemID)
{
}
public void ScriptRemoved(UUID itemID)
{
System.Console.WriteLine("TEST Script Removed!");
}
public void ObjectRemoved(UUID objectID)
{
System.Console.WriteLine("TEST Obj Removed!");
}
}
}

View File

@ -6856,6 +6856,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llCloseRemoteDataChannel(string channel)
{
m_host.AddScriptLPS(1);
IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface<IXmlRpcRouter>();
if (xmlRpcRouter != null)
{
xmlRpcRouter.UnRegisterReceiver(channel, m_item.ItemID);
}
IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
xmlrpcMod.CloseXMLRPCChannel((UUID)channel);
ScriptSleep(1000);