diff options
author | Adam Frisby | 2008-04-30 21:16:36 +0000 |
---|---|---|
committer | Adam Frisby | 2008-04-30 21:16:36 +0000 |
commit | f5c312bc3c2567449c7268a54a08a54119f58d53 (patch) | |
tree | 424668a4bbec6873ebc5b8256f3671db102f5e9c /OpenSim/Region/Environment/Modules/Communications | |
parent | * Adds the AuthbuyerID field to sqlite and makes use of it. (diff) | |
download | opensim-SC-f5c312bc3c2567449c7268a54a08a54119f58d53.zip opensim-SC-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.gz opensim-SC-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.bz2 opensim-SC-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.xz |
* Refactored Environment/Modules directory - modules now reside in their own directory with any associated module-specific classes.
* Each module directory is currently inside one of the following category folders: Agent (Anything relating to do with Client<->Server communications.), Avatar (Anything to do with the avatar or presence inworld), Framework (Classes modules can use), Grid (Grid traffic, new OGS2 grid comms), Scripting (Scripting functions, etc), World (The enrivonment/scene, IE Sun/Tree modules.)
* This should be moved into a seperate project file.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Communications')
3 files changed, 0 insertions, 239 deletions
diff --git a/OpenSim/Region/Environment/Modules/Communications/Interregion/IInterregionModule.cs b/OpenSim/Region/Environment/Modules/Communications/Interregion/IInterregionModule.cs deleted file mode 100644 index 713b46a..0000000 --- a/OpenSim/Region/Environment/Modules/Communications/Interregion/IInterregionModule.cs +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | using OpenSim.Framework; | ||
2 | using OpenSim.Region.Environment.Scenes; | ||
3 | |||
4 | namespace OpenSim.Region.Environment.Modules.Communications.Interregion | ||
5 | { | ||
6 | public interface IInterregionModule | ||
7 | { | ||
8 | void RegisterMethod<T>(T e); | ||
9 | bool HasInterface<T>(Location loc); | ||
10 | T RequestInterface<T>(Location loc); | ||
11 | T[] RequestInterface<T>(); | ||
12 | Location GetLocationByDirection(Scene scene, InterregionModule.Direction dir); | ||
13 | void internal_CreateRemotingObjects(); | ||
14 | } | ||
15 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Environment/Modules/Communications/Interregion/InterregionModule.cs b/OpenSim/Region/Environment/Modules/Communications/Interregion/InterregionModule.cs deleted file mode 100644 index 8d040c4..0000000 --- a/OpenSim/Region/Environment/Modules/Communications/Interregion/InterregionModule.cs +++ /dev/null | |||
@@ -1,174 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Runtime.Remoting; | ||
4 | using System.Runtime.Remoting.Channels; | ||
5 | using System.Runtime.Remoting.Channels.Tcp; | ||
6 | using Nini.Config; | ||
7 | using OpenSim.Framework; | ||
8 | using OpenSim.Region.Environment.Interfaces; | ||
9 | using OpenSim.Region.Environment.Scenes; | ||
10 | |||
11 | namespace OpenSim.Region.Environment.Modules.Communications.Interregion | ||
12 | { | ||
13 | public class InterregionModule : IInterregionModule, IRegionModule | ||
14 | { | ||
15 | #region Direction enum | ||
16 | |||
17 | public enum Direction | ||
18 | { | ||
19 | North, | ||
20 | NorthEast, | ||
21 | East, | ||
22 | SouthEast, | ||
23 | South, | ||
24 | SouthWest, | ||
25 | West, | ||
26 | NorthWest | ||
27 | } | ||
28 | |||
29 | #endregion | ||
30 | |||
31 | private readonly Dictionary<Type, Object> m_interfaces = new Dictionary<Type, object>(); | ||
32 | private readonly List<Location> m_myLocations = new List<Location>(); | ||
33 | |||
34 | private readonly Dictionary<Location, string[]> m_neighbourInterfaces = new Dictionary<Location, string[]>(); | ||
35 | private readonly Dictionary<Location, RemotingObject> m_neighbourRemote = new Dictionary<Location, RemotingObject>(); | ||
36 | private IConfigSource m_config; | ||
37 | private RemotingObject m_myRemote; | ||
38 | |||
39 | private Object m_lockObject = new object(); | ||
40 | private TcpChannel m_tcpChannel; | ||
41 | private int m_tcpPort = 10101; | ||
42 | private bool m_enabled = false; | ||
43 | |||
44 | #region IRegionModule Members | ||
45 | |||
46 | //TODO: This prevents us from registering new scenes after PostInitialise if we want comms updated. | ||
47 | public void Initialise(Scene scene, IConfigSource source) | ||
48 | { | ||
49 | if (m_enabled) | ||
50 | { | ||
51 | m_myLocations.Add(new Location((int) scene.RegionInfo.RegionLocX, | ||
52 | (int) scene.RegionInfo.RegionLocY)); | ||
53 | m_config = source; | ||
54 | |||
55 | scene.RegisterModuleInterface<IInterregionModule>(this); | ||
56 | } | ||
57 | } | ||
58 | |||
59 | //TODO: This prevents us from registering new scenes after PostInitialise if we want comms updated. | ||
60 | public void PostInitialise() | ||
61 | { | ||
62 | if (m_enabled) | ||
63 | { | ||
64 | try | ||
65 | { | ||
66 | m_tcpPort = m_config.Configs["Comms"].GetInt("remoting_port", m_tcpPort); | ||
67 | } | ||
68 | catch | ||
69 | { | ||
70 | } | ||
71 | |||
72 | internal_CreateRemotingObjects(); | ||
73 | } | ||
74 | } | ||
75 | |||
76 | public void Close() | ||
77 | { | ||
78 | ChannelServices.UnregisterChannel(m_tcpChannel); | ||
79 | } | ||
80 | |||
81 | public string Name | ||
82 | { | ||
83 | get { return "InterregionModule"; } | ||
84 | } | ||
85 | |||
86 | public bool IsSharedModule | ||
87 | { | ||
88 | get { return true; } | ||
89 | } | ||
90 | |||
91 | #endregion | ||
92 | |||
93 | public void internal_CreateRemotingObjects() | ||
94 | { | ||
95 | lock (m_lockObject) | ||
96 | { | ||
97 | if (m_tcpChannel == null) | ||
98 | { | ||
99 | m_myRemote = new RemotingObject(m_interfaces, m_myLocations.ToArray()); | ||
100 | m_tcpChannel = new TcpChannel(m_tcpPort); | ||
101 | |||
102 | ChannelServices.RegisterChannel(m_tcpChannel, false); | ||
103 | RemotingServices.Marshal(m_myRemote, "OpenSimRemote2", typeof (RemotingObject)); | ||
104 | } | ||
105 | } | ||
106 | } | ||
107 | |||
108 | public void RegisterRemoteRegion(string uri) | ||
109 | { | ||
110 | RegisterRemotingInterface((RemotingObject) Activator.GetObject(typeof (RemotingObject), uri)); | ||
111 | } | ||
112 | |||
113 | private void RegisterRemotingInterface(RemotingObject remote) | ||
114 | { | ||
115 | Location[] locs = remote.GetLocations(); | ||
116 | string[] interfaces = remote.GetInterfaces(); | ||
117 | foreach (Location loc in locs) | ||
118 | { | ||
119 | m_neighbourInterfaces[loc] = interfaces; | ||
120 | m_neighbourRemote[loc] = remote; | ||
121 | } | ||
122 | } | ||
123 | |||
124 | public void RegisterMethod<T>(T e) | ||
125 | { | ||
126 | m_interfaces[typeof (T)] = e; | ||
127 | } | ||
128 | |||
129 | public bool HasInterface<T>(Location loc) | ||
130 | { | ||
131 | foreach (string val in m_neighbourInterfaces[loc]) | ||
132 | { | ||
133 | if (val == typeof (T).FullName) | ||
134 | { | ||
135 | return true; | ||
136 | } | ||
137 | } | ||
138 | return false; | ||
139 | } | ||
140 | |||
141 | public T RequestInterface<T>(Location loc) | ||
142 | { | ||
143 | if (m_neighbourRemote.ContainsKey(loc)) | ||
144 | { | ||
145 | return m_neighbourRemote[loc].RequestInterface<T>(); | ||
146 | } | ||
147 | else | ||
148 | { | ||
149 | throw new IndexOutOfRangeException("No neighbour availible at that location"); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | public T[] RequestInterface<T>() | ||
154 | { | ||
155 | List<T> m_t = new List<T>(); | ||
156 | foreach (RemotingObject remote in m_neighbourRemote.Values) | ||
157 | { | ||
158 | try | ||
159 | { | ||
160 | m_t.Add(remote.RequestInterface<T>()); | ||
161 | } | ||
162 | catch (NotSupportedException) | ||
163 | { | ||
164 | } | ||
165 | } | ||
166 | return m_t.ToArray(); | ||
167 | } | ||
168 | |||
169 | public Location GetLocationByDirection(Scene scene, Direction dir) | ||
170 | { | ||
171 | return new Location(0, 0); | ||
172 | } | ||
173 | } | ||
174 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Environment/Modules/Communications/Interregion/RemotingObject.cs b/OpenSim/Region/Environment/Modules/Communications/Interregion/RemotingObject.cs deleted file mode 100644 index a735677..0000000 --- a/OpenSim/Region/Environment/Modules/Communications/Interregion/RemotingObject.cs +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using OpenSim.Framework; | ||
4 | |||
5 | namespace OpenSim.Region.Environment.Modules.Communications.Interregion | ||
6 | { | ||
7 | public class RemotingObject : MarshalByRefObject | ||
8 | { | ||
9 | private readonly Location[] m_coords; | ||
10 | private readonly Dictionary<Type, Object> m_interfaces = new Dictionary<Type, object>(); | ||
11 | |||
12 | public RemotingObject(Dictionary<Type, Object> myInterfaces, Location[] coords) | ||
13 | { | ||
14 | m_interfaces = myInterfaces; | ||
15 | m_coords = coords; | ||
16 | } | ||
17 | |||
18 | public Location[] GetLocations() | ||
19 | { | ||
20 | return (Location[]) m_coords.Clone(); | ||
21 | } | ||
22 | |||
23 | public string[] GetInterfaces() | ||
24 | { | ||
25 | string[] interfaces = new string[m_interfaces.Count]; | ||
26 | int i = 0; | ||
27 | |||
28 | foreach (KeyValuePair<Type, object> pair in m_interfaces) | ||
29 | { | ||
30 | interfaces[i++] = pair.Key.FullName; | ||
31 | } | ||
32 | |||
33 | return interfaces; | ||
34 | } | ||
35 | |||
36 | /// <summary> | ||
37 | /// Returns a registered interface availible to neighbouring regions. | ||
38 | /// </summary> | ||
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> | ||
41 | /// <remarks>All registered interfaces <b>MUST</b> inherit from MarshalByRefObject and use only serialisable types.</remarks> | ||
42 | public T RequestInterface<T>() | ||
43 | { | ||
44 | if (m_interfaces.ContainsKey(typeof (T))) | ||
45 | return (T) m_interfaces[typeof (T)]; | ||
46 | |||
47 | throw new NotSupportedException("No such interface registered."); | ||
48 | } | ||
49 | } | ||
50 | } \ No newline at end of file | ||