aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/OptionalModules/Grid/Interregion/IInterregionModule.cs43
-rw-r--r--OpenSim/Region/OptionalModules/Grid/Interregion/InterregionModule.cs199
-rw-r--r--OpenSim/Region/OptionalModules/Grid/Interregion/RemotingObject.cs77
3 files changed, 0 insertions, 319 deletions
diff --git a/OpenSim/Region/OptionalModules/Grid/Interregion/IInterregionModule.cs b/OpenSim/Region/OptionalModules/Grid/Interregion/IInterregionModule.cs
deleted file mode 100644
index d8ab7b2..0000000
--- a/OpenSim/Region/OptionalModules/Grid/Interregion/IInterregionModule.cs
+++ /dev/null
@@ -1,43 +0,0 @@
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 OpenSimulator 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
28using OpenSim.Framework;
29using OpenSim.Region.Framework.Scenes;
30
31namespace OpenSim.Region.CoreModules.Grid.Interregion
32{
33 public interface IInterregionModule
34 {
35 void RegisterMethod<T>(T e);
36 bool HasInterface<T>(Location loc);
37 T RequestInterface<T>(Location loc);
38 T[] RequestInterface<T>();
39 Location GetLocationByDirection(Scene scene, InterregionModule.Direction dir);
40 void internal_CreateRemotingObjects();
41 void RegisterRemoteRegion(string uri);
42 }
43} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Grid/Interregion/InterregionModule.cs b/OpenSim/Region/OptionalModules/Grid/Interregion/InterregionModule.cs
deleted file mode 100644
index b6ac0db..0000000
--- a/OpenSim/Region/OptionalModules/Grid/Interregion/InterregionModule.cs
+++ /dev/null
@@ -1,199 +0,0 @@
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 OpenSimulator 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
28using System;
29using System.Collections.Generic;
30using System.Runtime.Remoting;
31using System.Runtime.Remoting.Channels;
32using System.Runtime.Remoting.Channels.Tcp;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37
38namespace OpenSim.Region.CoreModules.Grid.Interregion
39{
40 public class InterregionModule : IInterregionModule, IRegionModule
41 {
42 #region Direction enum
43
44 public enum Direction
45 {
46 North,
47 NorthEast,
48 East,
49 SouthEast,
50 South,
51 SouthWest,
52 West,
53 NorthWest
54 }
55
56 #endregion
57
58 private readonly Dictionary<Type, Object> m_interfaces = new Dictionary<Type, object>();
59 private readonly Object m_lockObject = new object();
60 private readonly List<Location> m_myLocations = new List<Location>();
61
62 private readonly Dictionary<Location, string[]> m_neighbourInterfaces = new Dictionary<Location, string[]>();
63 private readonly Dictionary<Location, RemotingObject> m_neighbourRemote = new Dictionary<Location, RemotingObject>();
64 // private IConfigSource m_config;
65 private const bool m_enabled = false;
66
67 private RemotingObject m_myRemote;
68 private TcpChannel m_tcpChannel;
69 private int m_tcpPort = 10101;
70
71 #region IInterregionModule Members
72
73 public void internal_CreateRemotingObjects()
74 {
75 lock (m_lockObject)
76 {
77 if (m_tcpChannel == null)
78 {
79 m_myRemote = new RemotingObject(m_interfaces, m_myLocations.ToArray());
80 m_tcpChannel = new TcpChannel(m_tcpPort);
81
82 ChannelServices.RegisterChannel(m_tcpChannel, false);
83 RemotingServices.Marshal(m_myRemote, "OpenSimRemote2", typeof (RemotingObject));
84 }
85 }
86 }
87
88 public void RegisterMethod<T>(T e)
89 {
90 m_interfaces[typeof (T)] = e;
91 }
92
93 public bool HasInterface<T>(Location loc)
94 {
95 foreach (string val in m_neighbourInterfaces[loc])
96 {
97 if (val == typeof (T).FullName)
98 {
99 return true;
100 }
101 }
102 return false;
103 }
104
105 public T RequestInterface<T>(Location loc)
106 {
107 if (m_neighbourRemote.ContainsKey(loc))
108 {
109 return m_neighbourRemote[loc].RequestInterface<T>();
110 }
111 throw new IndexOutOfRangeException("No neighbour availible at that location");
112 }
113
114 public T[] RequestInterface<T>()
115 {
116 List<T> m_t = new List<T>();
117 foreach (RemotingObject remote in m_neighbourRemote.Values)
118 {
119 try
120 {
121 m_t.Add(remote.RequestInterface<T>());
122 }
123 catch (NotSupportedException)
124 {
125 }
126 }
127 return m_t.ToArray();
128 }
129
130 public Location GetLocationByDirection(Scene scene, Direction dir)
131 {
132 return new Location(0, 0);
133 }
134
135 public void RegisterRemoteRegion(string uri)
136 {
137 RegisterRemotingInterface((RemotingObject) Activator.GetObject(typeof (RemotingObject), uri));
138 }
139
140 #endregion
141
142 #region IRegionModule Members
143
144 public void Initialise(Scene scene, IConfigSource source)
145 {
146 m_myLocations.Add(new Location((int) scene.RegionInfo.RegionLocX,
147 (int) scene.RegionInfo.RegionLocY));
148 // m_config = source;
149
150 scene.RegisterModuleInterface<IInterregionModule>(this);
151 }
152
153 public void PostInitialise()
154 {
155 // Commenting out to remove 'unreachable code' warning since m_enabled is never true
156// if (m_enabled)
157// {
158// try
159// {
160// m_tcpPort = m_config.Configs["Comms"].GetInt("remoting_port", m_tcpPort);
161// }
162// catch
163// {
164// }
165//
166// internal_CreateRemotingObjects();
167// }
168 }
169
170 public void Close()
171 {
172 if (null != m_tcpChannel)
173 ChannelServices.UnregisterChannel(m_tcpChannel);
174 }
175
176 public string Name
177 {
178 get { return "InterregionModule"; }
179 }
180
181 public bool IsSharedModule
182 {
183 get { return true; }
184 }
185
186 #endregion
187
188 private void RegisterRemotingInterface(RemotingObject remote)
189 {
190 Location[] locs = remote.GetLocations();
191 string[] interfaces = remote.GetInterfaces();
192 foreach (Location loc in locs)
193 {
194 m_neighbourInterfaces[loc] = interfaces;
195 m_neighbourRemote[loc] = remote;
196 }
197 }
198 }
199}
diff --git a/OpenSim/Region/OptionalModules/Grid/Interregion/RemotingObject.cs b/OpenSim/Region/OptionalModules/Grid/Interregion/RemotingObject.cs
deleted file mode 100644
index c6fee03..0000000
--- a/OpenSim/Region/OptionalModules/Grid/Interregion/RemotingObject.cs
+++ /dev/null
@@ -1,77 +0,0 @@
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 OpenSimulator 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
28using System;
29using System.Collections.Generic;
30using OpenSim.Framework;
31
32namespace OpenSim.Region.CoreModules.Grid.Interregion
33{
34 public class RemotingObject : MarshalByRefObject
35 {
36 private readonly Location[] m_coords;
37 private readonly Dictionary<Type, Object> m_interfaces = new Dictionary<Type, object>();
38
39 public RemotingObject(Dictionary<Type, Object> myInterfaces, Location[] coords)
40 {
41 m_interfaces = myInterfaces;
42 m_coords = coords;
43 }
44
45 public Location[] GetLocations()
46 {
47 return (Location[]) m_coords.Clone();
48 }
49
50 public string[] GetInterfaces()
51 {
52 string[] interfaces = new string[m_interfaces.Count];
53 int i = 0;
54
55 foreach (KeyValuePair<Type, object> pair in m_interfaces)
56 {
57 interfaces[i++] = pair.Key.FullName;
58 }
59
60 return interfaces;
61 }
62
63 /// <summary>
64 /// Returns a registered interface availible to neighbouring regions.
65 /// </summary>
66 /// <typeparam name="T">The type of interface you wish to request</typeparam>
67 /// <returns>A MarshalByRefObject inherited from this region inheriting the interface requested.</returns>
68 /// <remarks>All registered interfaces <b>MUST</b> inherit from MarshalByRefObject and use only serialisable types.</remarks>
69 public T RequestInterface<T>()
70 {
71 if (m_interfaces.ContainsKey(typeof (T)))
72 return (T) m_interfaces[typeof (T)];
73
74 throw new NotSupportedException("No such interface registered.");
75 }
76 }
77}