diff options
author | Melanie Thielker | 2009-04-10 22:05:37 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-04-10 22:05:37 +0000 |
commit | 3307f217067f0194832a7484b89e45c2e3d37320 (patch) | |
tree | 3c6e1e94986fd0f36f338212a43eb3659ddb7e0b /OpenSim/Region/OptionalModules/Scripting | |
parent | Make the scrpt engines ignore any script that begins with //MRM: (diff) | |
download | opensim-SC_OLD-3307f217067f0194832a7484b89e45c2e3d37320.zip opensim-SC_OLD-3307f217067f0194832a7484b89e45c2e3d37320.tar.gz opensim-SC_OLD-3307f217067f0194832a7484b89e45c2e3d37320.tar.bz2 opensim-SC_OLD-3307f217067f0194832a7484b89e45c2e3d37320.tar.xz |
Add XmlRpcGridRouter, a module that communicates URIs for XMLRPC channels
to a central server via REST, for centralized XMLRPC routing.
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting')
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs new file mode 100644 index 0000000..6e23f65 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs | |||
@@ -0,0 +1,143 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | |||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using OpenMetaverse; | ||
35 | |||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Framework.Servers; | ||
39 | using OpenSim.Framework.Client; | ||
40 | using OpenSim.Region.Framework.Interfaces; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | |||
43 | namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | ||
44 | { | ||
45 | public class XmlRpcInfo | ||
46 | { | ||
47 | public UUID channel; | ||
48 | public string uri; | ||
49 | } | ||
50 | |||
51 | public class XmlRpcGridRouter : IRegionModule, IXmlRpcRouter | ||
52 | { | ||
53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
54 | |||
55 | private Dictionary<UUID, UUID> m_Channels = | ||
56 | new Dictionary<UUID, UUID>(); | ||
57 | |||
58 | private bool m_Enabled = false; | ||
59 | private string m_ServerURI = String.Empty; | ||
60 | |||
61 | public void Initialise(Scene scene, IConfigSource config) | ||
62 | { | ||
63 | IConfig startupConfig = config.Configs["Startup"]; | ||
64 | if (startupConfig == null) | ||
65 | return; | ||
66 | |||
67 | if (startupConfig.GetString("XmlRpcRouterModule", | ||
68 | "XmlRpcRouterModule") == "XmlRpcGridRouterModule") | ||
69 | { | ||
70 | m_ServerURI = startupConfig.GetString("XmlRpcHubURI", String.Empty); | ||
71 | if (m_ServerURI == String.Empty) | ||
72 | { | ||
73 | m_log.Error("[XMLRPC GRID ROUTER] Module configured but no URI given. Disabling"); | ||
74 | return; | ||
75 | } | ||
76 | |||
77 | scene.RegisterModuleInterface<IXmlRpcRouter>(this); | ||
78 | m_Enabled = true; | ||
79 | } | ||
80 | } | ||
81 | |||
82 | public void PostInitialise() | ||
83 | { | ||
84 | } | ||
85 | |||
86 | public void Close() | ||
87 | { | ||
88 | } | ||
89 | |||
90 | public string Name | ||
91 | { | ||
92 | get { return "XmlRpcGridRouterModule"; } | ||
93 | } | ||
94 | |||
95 | public bool IsSharedModule | ||
96 | { | ||
97 | get { return false; } | ||
98 | } | ||
99 | |||
100 | public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) | ||
101 | { | ||
102 | if (!m_Channels.ContainsKey(itemID)) | ||
103 | { | ||
104 | XmlRpcInfo info = new XmlRpcInfo(); | ||
105 | info.channel = channel; | ||
106 | info.uri = uri; | ||
107 | |||
108 | bool success = SynchronousRestObjectPoster.BeginPostObject<XmlRpcInfo, bool>( | ||
109 | "POST", m_ServerURI+"/RegisterChannel/", info); | ||
110 | |||
111 | if (!success) | ||
112 | { | ||
113 | m_log.Error("[XMLRPC GRID ROUTER] Error contacting server"); | ||
114 | } | ||
115 | |||
116 | m_Channels[itemID] = channel; | ||
117 | } | ||
118 | } | ||
119 | |||
120 | public void ScriptRemoved(UUID itemID) | ||
121 | { | ||
122 | if (!m_Enabled) | ||
123 | return; | ||
124 | |||
125 | if (m_Channels.ContainsKey(itemID)) | ||
126 | { | ||
127 | bool success = SynchronousRestObjectPoster.BeginPostObject<UUID, bool>( | ||
128 | "POST", m_ServerURI+"/RemoveChannel/", m_Channels[itemID]); | ||
129 | |||
130 | if (!success) | ||
131 | { | ||
132 | m_log.Error("[XMLRPC GRID ROUTER] Error contacting server"); | ||
133 | } | ||
134 | |||
135 | m_Channels.Remove(itemID); | ||
136 | } | ||
137 | } | ||
138 | |||
139 | public void ObjectRemoved(UUID objectID) | ||
140 | { | ||
141 | } | ||
142 | } | ||
143 | } | ||