aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Grid/Interregion
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Grid/Interregion')
-rw-r--r--OpenSim/Region/Environment/Modules/Grid/Interregion/IInterregionModule.cs30
-rw-r--r--OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs358
-rw-r--r--OpenSim/Region/Environment/Modules/Grid/Interregion/RemotingObject.cs98
3 files changed, 243 insertions, 243 deletions
diff --git a/OpenSim/Region/Environment/Modules/Grid/Interregion/IInterregionModule.cs b/OpenSim/Region/Environment/Modules/Grid/Interregion/IInterregionModule.cs
index ac4062b..95d22f0 100644
--- a/OpenSim/Region/Environment/Modules/Grid/Interregion/IInterregionModule.cs
+++ b/OpenSim/Region/Environment/Modules/Grid/Interregion/IInterregionModule.cs
@@ -1,16 +1,16 @@
1using OpenSim.Framework; 1using OpenSim.Framework;
2using OpenSim.Region.Environment.Modules.Communications.Interregion; 2using OpenSim.Region.Environment.Modules.Communications.Interregion;
3using OpenSim.Region.Environment.Scenes; 3using OpenSim.Region.Environment.Scenes;
4 4
5namespace OpenSim.Region.Environment.Modules.Grid.Interregion 5namespace OpenSim.Region.Environment.Modules.Grid.Interregion
6{ 6{
7 public interface IInterregionModule 7 public interface IInterregionModule
8 { 8 {
9 void RegisterMethod<T>(T e); 9 void RegisterMethod<T>(T e);
10 bool HasInterface<T>(Location loc); 10 bool HasInterface<T>(Location loc);
11 T RequestInterface<T>(Location loc); 11 T RequestInterface<T>(Location loc);
12 T[] RequestInterface<T>(); 12 T[] RequestInterface<T>();
13 Location GetLocationByDirection(Scene scene, InterregionModule.Direction dir); 13 Location GetLocationByDirection(Scene scene, InterregionModule.Direction dir);
14 void internal_CreateRemotingObjects(); 14 void internal_CreateRemotingObjects();
15 } 15 }
16} \ No newline at end of file 16} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs b/OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs
index 8307e50..651ed60 100644
--- a/OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs
+++ b/OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs
@@ -1,180 +1,180 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Runtime.Remoting; 3using System.Runtime.Remoting;
4using System.Runtime.Remoting.Channels; 4using System.Runtime.Remoting.Channels;
5using System.Runtime.Remoting.Channels.Tcp; 5using System.Runtime.Remoting.Channels.Tcp;
6using Nini.Config; 6using Nini.Config;
7using OpenSim.Framework; 7using OpenSim.Framework;
8using OpenSim.Region.Environment.Interfaces; 8using OpenSim.Region.Environment.Interfaces;
9using OpenSim.Region.Environment.Modules.Grid.Interregion; 9using OpenSim.Region.Environment.Modules.Grid.Interregion;
10using OpenSim.Region.Environment.Scenes; 10using OpenSim.Region.Environment.Scenes;
11 11
12namespace OpenSim.Region.Environment.Modules.Communications.Interregion 12namespace OpenSim.Region.Environment.Modules.Communications.Interregion
13{ 13{
14 public class InterregionModule : IInterregionModule, IRegionModule 14 public class InterregionModule : IInterregionModule, IRegionModule
15 { 15 {
16 #region Direction enum 16 #region Direction enum
17 17
18 public enum Direction 18 public enum Direction
19 { 19 {
20 North, 20 North,
21 NorthEast, 21 NorthEast,
22 East, 22 East,
23 SouthEast, 23 SouthEast,
24 South, 24 South,
25 SouthWest, 25 SouthWest,
26 West, 26 West,
27 NorthWest 27 NorthWest
28 } 28 }
29 29
30 #endregion 30 #endregion
31 31
32 private readonly Dictionary<Type, Object> m_interfaces = new Dictionary<Type, object>(); 32 private readonly Dictionary<Type, Object> m_interfaces = new Dictionary<Type, object>();
33 private readonly List<Location> m_myLocations = new List<Location>(); 33 private readonly List<Location> m_myLocations = new List<Location>();
34 34
35 private readonly Dictionary<Location, string[]> m_neighbourInterfaces = new Dictionary<Location, string[]>(); 35 private readonly Dictionary<Location, string[]> m_neighbourInterfaces = new Dictionary<Location, string[]>();
36 private readonly Dictionary<Location, RemotingObject> m_neighbourRemote = new Dictionary<Location, RemotingObject>(); 36 private readonly Dictionary<Location, RemotingObject> m_neighbourRemote = new Dictionary<Location, RemotingObject>();
37 private IConfigSource m_config; 37 private IConfigSource m_config;
38 private bool m_enabled = false; 38 private bool m_enabled = false;
39 39
40 private Object m_lockObject = new object(); 40 private Object m_lockObject = new object();
41 private RemotingObject m_myRemote; 41 private RemotingObject m_myRemote;
42 private TcpChannel m_tcpChannel; 42 private TcpChannel m_tcpChannel;
43 private int m_tcpPort = 10101; 43 private int m_tcpPort = 10101;
44 44
45 #region IInterregionModule Members 45 #region IInterregionModule Members
46 46
47 public void internal_CreateRemotingObjects() 47 public void internal_CreateRemotingObjects()
48 { 48 {
49 lock (m_lockObject) 49 lock (m_lockObject)
50 { 50 {
51 if (m_tcpChannel == null) 51 if (m_tcpChannel == null)
52 { 52 {
53 m_myRemote = new RemotingObject(m_interfaces, m_myLocations.ToArray()); 53 m_myRemote = new RemotingObject(m_interfaces, m_myLocations.ToArray());
54 m_tcpChannel = new TcpChannel(m_tcpPort); 54 m_tcpChannel = new TcpChannel(m_tcpPort);
55 55
56 ChannelServices.RegisterChannel(m_tcpChannel, false); 56 ChannelServices.RegisterChannel(m_tcpChannel, false);
57 RemotingServices.Marshal(m_myRemote, "OpenSimRemote2", typeof (RemotingObject)); 57 RemotingServices.Marshal(m_myRemote, "OpenSimRemote2", typeof (RemotingObject));
58 } 58 }
59 } 59 }
60 } 60 }
61 61
62 public void RegisterMethod<T>(T e) 62 public void RegisterMethod<T>(T e)
63 { 63 {
64 m_interfaces[typeof (T)] = e; 64 m_interfaces[typeof (T)] = e;
65 } 65 }
66 66
67 public bool HasInterface<T>(Location loc) 67 public bool HasInterface<T>(Location loc)
68 { 68 {
69 foreach (string val in m_neighbourInterfaces[loc]) 69 foreach (string val in m_neighbourInterfaces[loc])
70 { 70 {
71 if (val == typeof (T).FullName) 71 if (val == typeof (T).FullName)
72 { 72 {
73 return true; 73 return true;
74 } 74 }
75 } 75 }
76 return false; 76 return false;
77 } 77 }
78 78
79 public T RequestInterface<T>(Location loc) 79 public T RequestInterface<T>(Location loc)
80 { 80 {
81 if (m_neighbourRemote.ContainsKey(loc)) 81 if (m_neighbourRemote.ContainsKey(loc))
82 { 82 {
83 return m_neighbourRemote[loc].RequestInterface<T>(); 83 return m_neighbourRemote[loc].RequestInterface<T>();
84 } 84 }
85 else 85 else
86 { 86 {
87 throw new IndexOutOfRangeException("No neighbour availible at that location"); 87 throw new IndexOutOfRangeException("No neighbour availible at that location");
88 } 88 }
89 } 89 }
90 90
91 public T[] RequestInterface<T>() 91 public T[] RequestInterface<T>()
92 { 92 {
93 List<T> m_t = new List<T>(); 93 List<T> m_t = new List<T>();
94 foreach (RemotingObject remote in m_neighbourRemote.Values) 94 foreach (RemotingObject remote in m_neighbourRemote.Values)
95 { 95 {
96 try 96 try
97 { 97 {
98 m_t.Add(remote.RequestInterface<T>()); 98 m_t.Add(remote.RequestInterface<T>());
99 } 99 }
100 catch (NotSupportedException) 100 catch (NotSupportedException)
101 { 101 {
102 } 102 }
103 } 103 }
104 return m_t.ToArray(); 104 return m_t.ToArray();
105 } 105 }
106 106
107 public Location GetLocationByDirection(Scene scene, Direction dir) 107 public Location GetLocationByDirection(Scene scene, Direction dir)
108 { 108 {
109 return new Location(0, 0); 109 return new Location(0, 0);
110 } 110 }
111 111
112 #endregion 112 #endregion
113 113
114 //TODO: This prevents us from registering new scenes after PostInitialise if we want comms updated. 114 //TODO: This prevents us from registering new scenes after PostInitialise if we want comms updated.
115 115
116 #region IRegionModule Members 116 #region IRegionModule Members
117 117
118 public void Initialise(Scene scene, IConfigSource source) 118 public void Initialise(Scene scene, IConfigSource source)
119 { 119 {
120 if (m_enabled) 120 if (m_enabled)
121 { 121 {
122 m_myLocations.Add(new Location((int) scene.RegionInfo.RegionLocX, 122 m_myLocations.Add(new Location((int) scene.RegionInfo.RegionLocX,
123 (int) scene.RegionInfo.RegionLocY)); 123 (int) scene.RegionInfo.RegionLocY));
124 m_config = source; 124 m_config = source;
125 125
126 scene.RegisterModuleInterface<IInterregionModule>(this); 126 scene.RegisterModuleInterface<IInterregionModule>(this);
127 } 127 }
128 } 128 }
129 129
130 //TODO: This prevents us from registering new scenes after PostInitialise if we want comms updated. 130 //TODO: This prevents us from registering new scenes after PostInitialise if we want comms updated.
131 public void PostInitialise() 131 public void PostInitialise()
132 { 132 {
133 if (m_enabled) 133 if (m_enabled)
134 { 134 {
135 try 135 try
136 { 136 {
137 m_tcpPort = m_config.Configs["Comms"].GetInt("remoting_port", m_tcpPort); 137 m_tcpPort = m_config.Configs["Comms"].GetInt("remoting_port", m_tcpPort);
138 } 138 }
139 catch 139 catch
140 { 140 {
141 } 141 }
142 142
143 internal_CreateRemotingObjects(); 143 internal_CreateRemotingObjects();
144 } 144 }
145 } 145 }
146 146
147 public void Close() 147 public void Close()
148 { 148 {
149 ChannelServices.UnregisterChannel(m_tcpChannel); 149 ChannelServices.UnregisterChannel(m_tcpChannel);
150 } 150 }
151 151
152 public string Name 152 public string Name
153 { 153 {
154 get { return "InterregionModule"; } 154 get { return "InterregionModule"; }
155 } 155 }
156 156
157 public bool IsSharedModule 157 public bool IsSharedModule
158 { 158 {
159 get { return true; } 159 get { return true; }
160 } 160 }
161 161
162 #endregion 162 #endregion
163 163
164 public void RegisterRemoteRegion(string uri) 164 public void RegisterRemoteRegion(string uri)
165 { 165 {
166 RegisterRemotingInterface((RemotingObject) Activator.GetObject(typeof (RemotingObject), uri)); 166 RegisterRemotingInterface((RemotingObject) Activator.GetObject(typeof (RemotingObject), uri));
167 } 167 }
168 168
169 private void RegisterRemotingInterface(RemotingObject remote) 169 private void RegisterRemotingInterface(RemotingObject remote)
170 { 170 {
171 Location[] locs = remote.GetLocations(); 171 Location[] locs = remote.GetLocations();
172 string[] interfaces = remote.GetInterfaces(); 172 string[] interfaces = remote.GetInterfaces();
173 foreach (Location loc in locs) 173 foreach (Location loc in locs)
174 { 174 {
175 m_neighbourInterfaces[loc] = interfaces; 175 m_neighbourInterfaces[loc] = interfaces;
176 m_neighbourRemote[loc] = remote; 176 m_neighbourRemote[loc] = remote;
177 } 177 }
178 } 178 }
179 } 179 }
180} \ No newline at end of file 180} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Grid/Interregion/RemotingObject.cs b/OpenSim/Region/Environment/Modules/Grid/Interregion/RemotingObject.cs
index 2c72bb9..453a2b7 100644
--- a/OpenSim/Region/Environment/Modules/Grid/Interregion/RemotingObject.cs
+++ b/OpenSim/Region/Environment/Modules/Grid/Interregion/RemotingObject.cs
@@ -1,50 +1,50 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using OpenSim.Framework; 3using OpenSim.Framework;
4 4
5namespace OpenSim.Region.Environment.Modules.Grid.Interregion 5namespace OpenSim.Region.Environment.Modules.Grid.Interregion
6{ 6{
7 public class RemotingObject : MarshalByRefObject 7 public class RemotingObject : MarshalByRefObject
8 { 8 {
9 private readonly Location[] m_coords; 9 private readonly Location[] m_coords;
10 private readonly Dictionary<Type, Object> m_interfaces = new Dictionary<Type, object>(); 10 private readonly Dictionary<Type, Object> m_interfaces = new Dictionary<Type, object>();
11 11
12 public RemotingObject(Dictionary<Type, Object> myInterfaces, Location[] coords) 12 public RemotingObject(Dictionary<Type, Object> myInterfaces, Location[] coords)
13 { 13 {
14 m_interfaces = myInterfaces; 14 m_interfaces = myInterfaces;
15 m_coords = coords; 15 m_coords = coords;
16 } 16 }
17 17
18 public Location[] GetLocations() 18 public Location[] GetLocations()
19 { 19 {
20 return (Location[]) m_coords.Clone(); 20 return (Location[]) m_coords.Clone();
21 } 21 }
22 22
23 public string[] GetInterfaces() 23 public string[] GetInterfaces()
24 { 24 {
25 string[] interfaces = new string[m_interfaces.Count]; 25 string[] interfaces = new string[m_interfaces.Count];
26 int i = 0; 26 int i = 0;
27 27
28 foreach (KeyValuePair<Type, object> pair in m_interfaces) 28 foreach (KeyValuePair<Type, object> pair in m_interfaces)
29 { 29 {
30 interfaces[i++] = pair.Key.FullName; 30 interfaces[i++] = pair.Key.FullName;
31 } 31 }
32 32
33 return interfaces; 33 return interfaces;
34 } 34 }
35 35
36 /// <summary> 36 /// <summary>
37 /// Returns a registered interface availible to neighbouring regions. 37 /// Returns a registered interface availible to neighbouring regions.
38 /// </summary> 38 /// </summary>
39 /// <typeparam name="T">The type of interface you wish to request</typeparam> 39 /// <typeparam name="T">The type of interface you wish to request</typeparam>
40 /// <returns>A MarshalByRefObject inherited from this region inheriting the interface requested.</returns> 40 /// <returns>A MarshalByRefObject inherited from this region inheriting the interface requested.</returns>
41 /// <remarks>All registered interfaces <b>MUST</b> inherit from MarshalByRefObject and use only serialisable types.</remarks> 41 /// <remarks>All registered interfaces <b>MUST</b> inherit from MarshalByRefObject and use only serialisable types.</remarks>
42 public T RequestInterface<T>() 42 public T RequestInterface<T>()
43 { 43 {
44 if (m_interfaces.ContainsKey(typeof (T))) 44 if (m_interfaces.ContainsKey(typeof (T)))
45 return (T) m_interfaces[typeof (T)]; 45 return (T) m_interfaces[typeof (T)];
46 46
47 throw new NotSupportedException("No such interface registered."); 47 throw new NotSupportedException("No such interface registered.");
48 } 48 }
49 } 49 }
50} \ No newline at end of file 50} \ No newline at end of file