diff options
author | Jeff Ames | 2008-05-01 14:31:30 +0000 |
---|---|---|
committer | Jeff Ames | 2008-05-01 14:31:30 +0000 |
commit | d51ce47b2d7635b17f3dd429158e8f59b78b83aa (patch) | |
tree | d3595bd5194199184059aa398b91a51dc6c799cf /OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs | |
parent | * Looks like I had the bamboo build right in the first place - it was just th... (diff) | |
download | opensim-SC-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.zip opensim-SC-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.gz opensim-SC-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.bz2 opensim-SC-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.xz |
Update svn properties. Minor formatting cleanup.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs | 358 |
1 files changed, 179 insertions, 179 deletions
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 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Runtime.Remoting; | 3 | using System.Runtime.Remoting; |
4 | using System.Runtime.Remoting.Channels; | 4 | using System.Runtime.Remoting.Channels; |
5 | using System.Runtime.Remoting.Channels.Tcp; | 5 | using System.Runtime.Remoting.Channels.Tcp; |
6 | using Nini.Config; | 6 | using Nini.Config; |
7 | using OpenSim.Framework; | 7 | using OpenSim.Framework; |
8 | using OpenSim.Region.Environment.Interfaces; | 8 | using OpenSim.Region.Environment.Interfaces; |
9 | using OpenSim.Region.Environment.Modules.Grid.Interregion; | 9 | using OpenSim.Region.Environment.Modules.Grid.Interregion; |
10 | using OpenSim.Region.Environment.Scenes; | 10 | using OpenSim.Region.Environment.Scenes; |
11 | 11 | ||
12 | namespace OpenSim.Region.Environment.Modules.Communications.Interregion | 12 | namespace 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 |