mirror of
https://github.com/opensim/opensim.git
synced 2026-05-16 11:46:04 +08:00
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.
This commit is contained in:
@@ -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,22 +129,36 @@ 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);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
XmlRpcInfo info = new XmlRpcInfo();
|
||||
info.channel = channel;
|
||||
info.uri = uri;
|
||||
|
||||
bool success = SynchronousRestObjectRequester.MakeRequest<XmlRpcInfo, bool>(
|
||||
"POST", m_ServerURI+"/RegisterChannel/", info);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
m_log.Error("[XMLRPC GRID ROUTER] Error contacting server");
|
||||
}
|
||||
|
||||
m_Channels[itemID] = channel;
|
||||
m_log.Error("[XMLRPC GRID ROUTER] Error contacting server");
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// m_log.InfoFormat("[XMLRPC GRID ROUTER]: Object Removed {0}",objectID.ToString());
|
||||
}
|
||||
|
||||
private bool RemoveChannel(UUID itemID)
|
||||
{
|
||||
if(!m_Channels.ContainsKey(itemID))
|
||||
{
|
||||
bool success = SynchronousRestObjectRequester.MakeRequest<UUID, bool>(
|
||||
"POST", m_ServerURI+"/RemoveChannel/", m_Channels[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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user