diff options
Diffstat (limited to 'OpenSim/Grid/MessagingServer/Main.cs')
-rw-r--r-- | OpenSim/Grid/MessagingServer/Main.cs | 127 |
1 files changed, 95 insertions, 32 deletions
diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs index 2f63ee9..f09d360 100644 --- a/OpenSim/Grid/MessagingServer/Main.cs +++ b/OpenSim/Grid/MessagingServer/Main.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.IO; | 30 | using System.IO; |
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using log4net; | 32 | using log4net; |
@@ -38,13 +39,18 @@ namespace OpenSim.Grid.MessagingServer | |||
38 | { | 39 | { |
39 | /// <summary> | 40 | /// <summary> |
40 | /// </summary> | 41 | /// </summary> |
41 | public class OpenMessage_Main : BaseOpenSimServer | 42 | public class OpenMessage_Main : BaseOpenSimServer , IUGAIMCore |
42 | { | 43 | { |
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | 45 | ||
45 | private MessageServerConfig Cfg; | 46 | private MessageServerConfig Cfg; |
46 | private MessageService msgsvc; | 47 | private MessageService msgsvc; |
47 | 48 | ||
49 | private MessageRegionModule m_regionModule; | ||
50 | private MessageUserServerModule m_userServerModule; | ||
51 | |||
52 | private UserDataBaseService m_userDataBaseService; | ||
53 | |||
48 | // private UUID m_lastCreatedUser = UUID.Random(); | 54 | // private UUID m_lastCreatedUser = UUID.Random(); |
49 | 55 | ||
50 | public static void Main(string[] args) | 56 | public static void Main(string[] args) |
@@ -77,7 +83,7 @@ namespace OpenSim.Grid.MessagingServer | |||
77 | 83 | ||
78 | private void registerWithUserServer() | 84 | private void registerWithUserServer() |
79 | { | 85 | { |
80 | if (msgsvc.registerWithUserServer()) | 86 | if (m_userServerModule.registerWithUserServer()) |
81 | { | 87 | { |
82 | m_log.Info("[SERVER]: Starting HTTP process"); | 88 | m_log.Info("[SERVER]: Starting HTTP process"); |
83 | m_httpServer = new BaseHttpServer(Cfg.HttpPort); | 89 | m_httpServer = new BaseHttpServer(Cfg.HttpPort); |
@@ -85,12 +91,13 @@ namespace OpenSim.Grid.MessagingServer | |||
85 | m_httpServer.AddXmlRPCHandler("login_to_simulator", msgsvc.UserLoggedOn); | 91 | m_httpServer.AddXmlRPCHandler("login_to_simulator", msgsvc.UserLoggedOn); |
86 | m_httpServer.AddXmlRPCHandler("logout_of_simulator", msgsvc.UserLoggedOff); | 92 | m_httpServer.AddXmlRPCHandler("logout_of_simulator", msgsvc.UserLoggedOff); |
87 | m_httpServer.AddXmlRPCHandler("get_presence_info_bulk", msgsvc.GetPresenceInfoBulk); | 93 | m_httpServer.AddXmlRPCHandler("get_presence_info_bulk", msgsvc.GetPresenceInfoBulk); |
88 | m_httpServer.AddXmlRPCHandler("region_startup", msgsvc.RegionStartup); | ||
89 | m_httpServer.AddXmlRPCHandler("region_shutdown", msgsvc.RegionShutdown); | ||
90 | m_httpServer.AddXmlRPCHandler("process_region_shutdown", msgsvc.ProcessRegionShutdown); | 94 | m_httpServer.AddXmlRPCHandler("process_region_shutdown", msgsvc.ProcessRegionShutdown); |
91 | m_httpServer.AddXmlRPCHandler("agent_location", msgsvc.AgentLocation); | 95 | m_httpServer.AddXmlRPCHandler("agent_location", msgsvc.AgentLocation); |
92 | m_httpServer.AddXmlRPCHandler("agent_leaving", msgsvc.AgentLeaving); | 96 | m_httpServer.AddXmlRPCHandler("agent_leaving", msgsvc.AgentLeaving); |
93 | 97 | ||
98 | m_httpServer.AddXmlRPCHandler("region_startup", m_regionModule.RegionStartup); | ||
99 | m_httpServer.AddXmlRPCHandler("region_shutdown", m_regionModule.RegionShutdown); | ||
100 | |||
94 | m_httpServer.Start(); | 101 | m_httpServer.Start(); |
95 | m_log.Info("[SERVER]: Userserver registration was successful"); | 102 | m_log.Info("[SERVER]: Userserver registration was successful"); |
96 | } | 103 | } |
@@ -103,7 +110,7 @@ namespace OpenSim.Grid.MessagingServer | |||
103 | 110 | ||
104 | private void deregisterFromUserServer() | 111 | private void deregisterFromUserServer() |
105 | { | 112 | { |
106 | msgsvc.deregisterWithUserServer(); | 113 | m_userServerModule.deregisterWithUserServer(); |
107 | if (m_httpServer != null) | 114 | if (m_httpServer != null) |
108 | { | 115 | { |
109 | // try a completely fresh registration, with fresh handlers, too | 116 | // try a completely fresh registration, with fresh handlers, too |
@@ -117,9 +124,24 @@ namespace OpenSim.Grid.MessagingServer | |||
117 | { | 124 | { |
118 | Cfg = new MessageServerConfig("MESSAGING SERVER", (Path.Combine(Util.configDir(), "MessagingServer_Config.xml"))); | 125 | Cfg = new MessageServerConfig("MESSAGING SERVER", (Path.Combine(Util.configDir(), "MessagingServer_Config.xml"))); |
119 | 126 | ||
120 | msgsvc = new MessageService(Cfg); | 127 | m_userDataBaseService = new UserDataBaseService(); |
128 | m_userDataBaseService.AddPlugin(Cfg.DatabaseProvider, Cfg.DatabaseConnect); | ||
129 | |||
130 | m_userServerModule = new MessageUserServerModule(Cfg, this); | ||
131 | m_userServerModule.Initialise(); | ||
132 | |||
133 | msgsvc = new MessageService(Cfg, this, m_userDataBaseService); | ||
134 | msgsvc.Initialise(); | ||
135 | |||
136 | m_regionModule = new MessageRegionModule(Cfg, this); | ||
137 | m_regionModule.Initialise(); | ||
138 | |||
121 | registerWithUserServer(); | 139 | registerWithUserServer(); |
122 | 140 | ||
141 | m_userServerModule.PostInitialise(); | ||
142 | msgsvc.PostInitialise(); | ||
143 | m_regionModule.PostInitialise(); | ||
144 | |||
123 | m_log.Info("[SERVER]: Messageserver 0.5 - Startup complete"); | 145 | m_log.Info("[SERVER]: Messageserver 0.5 - Startup complete"); |
124 | 146 | ||
125 | base.StartupSpecific(); | 147 | base.StartupSpecific(); |
@@ -135,35 +157,35 @@ namespace OpenSim.Grid.MessagingServer | |||
135 | 157 | ||
136 | public void do_create(string what) | 158 | public void do_create(string what) |
137 | { | 159 | { |
138 | switch (what) | 160 | //switch (what) |
139 | { | 161 | //{ |
140 | case "user": | 162 | // case "user": |
141 | try | 163 | // try |
142 | { | 164 | // { |
143 | //userID = | 165 | // //userID = |
144 | //m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); | 166 | // //m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); |
145 | } catch (Exception ex) | 167 | // } catch (Exception ex) |
146 | { | 168 | // { |
147 | m_console.Error("[SERVER]: Error creating user: {0}", ex.ToString()); | 169 | // m_console.Error("[SERVER]: Error creating user: {0}", ex.ToString()); |
148 | } | 170 | // } |
149 | 171 | ||
150 | try | 172 | // try |
151 | { | 173 | // { |
152 | //RestObjectPoster.BeginPostObject<Guid>(m_userManager._config.InventoryUrl + "CreateInventory/", | 174 | // //RestObjectPoster.BeginPostObject<Guid>(m_userManager._config.InventoryUrl + "CreateInventory/", |
153 | //userID.Guid); | 175 | // //userID.Guid); |
154 | } | 176 | // } |
155 | catch (Exception ex) | 177 | // catch (Exception ex) |
156 | { | 178 | // { |
157 | m_console.Error("[SERVER]: Error creating inventory for user: {0}", ex.ToString()); | 179 | // m_console.Error("[SERVER]: Error creating inventory for user: {0}", ex.ToString()); |
158 | } | 180 | // } |
159 | // m_lastCreatedUser = userID; | 181 | // // m_lastCreatedUser = userID; |
160 | break; | 182 | // break; |
161 | } | 183 | //} |
162 | } | 184 | } |
163 | 185 | ||
164 | private void HandleClearCache(string module, string[] cmd) | 186 | private void HandleClearCache(string module, string[] cmd) |
165 | { | 187 | { |
166 | int entries = msgsvc.ClearRegionCache(); | 188 | int entries = m_regionModule.ClearRegionCache(); |
167 | m_console.Notice("Region cache cleared! Cleared " + | 189 | m_console.Notice("Region cache cleared! Cleared " + |
168 | entries.ToString() + " entries"); | 190 | entries.ToString() + " entries"); |
169 | } | 191 | } |
@@ -176,7 +198,48 @@ namespace OpenSim.Grid.MessagingServer | |||
176 | 198 | ||
177 | public override void ShutdownSpecific() | 199 | public override void ShutdownSpecific() |
178 | { | 200 | { |
179 | msgsvc.deregisterWithUserServer(); | 201 | m_userServerModule.deregisterWithUserServer(); |
202 | } | ||
203 | |||
204 | #region IUGAIMCore | ||
205 | private readonly Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>(); | ||
206 | |||
207 | /// <summary> | ||
208 | /// Register an Module interface. | ||
209 | /// </summary> | ||
210 | /// <typeparam name="T"></typeparam> | ||
211 | /// <param name="iface"></param> | ||
212 | public void RegisterInterface<T>(T iface) | ||
213 | { | ||
214 | lock (m_moduleInterfaces) | ||
215 | { | ||
216 | if (!m_moduleInterfaces.ContainsKey(typeof(T))) | ||
217 | { | ||
218 | m_moduleInterfaces.Add(typeof(T), iface); | ||
219 | } | ||
220 | } | ||
221 | } | ||
222 | |||
223 | public bool TryGet<T>(out T iface) | ||
224 | { | ||
225 | if (m_moduleInterfaces.ContainsKey(typeof(T))) | ||
226 | { | ||
227 | iface = (T)m_moduleInterfaces[typeof(T)]; | ||
228 | return true; | ||
229 | } | ||
230 | iface = default(T); | ||
231 | return false; | ||
232 | } | ||
233 | |||
234 | public T Get<T>() | ||
235 | { | ||
236 | return (T)m_moduleInterfaces[typeof(T)]; | ||
237 | } | ||
238 | |||
239 | public BaseHttpServer GetHttpServer() | ||
240 | { | ||
241 | return m_httpServer; | ||
180 | } | 242 | } |
243 | #endregion | ||
181 | } | 244 | } |
182 | } | 245 | } |