aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMW2007-10-03 07:50:07 +0000
committerMW2007-10-03 07:50:07 +0000
commit652654176a9f410cbdb0afced0297dc1997f5bb5 (patch)
treee5cc5ece9a76e13ffe7a47603aef37ad0fa5956b
parentSome continuation of lbsa71's refactoring of the CommunicationsManager. (diff)
downloadopensim-SC-652654176a9f410cbdb0afced0297dc1997f5bb5.zip
opensim-SC-652654176a9f410cbdb0afced0297dc1997f5bb5.tar.gz
opensim-SC-652654176a9f410cbdb0afced0297dc1997f5bb5.tar.bz2
opensim-SC-652654176a9f410cbdb0afced0297dc1997f5bb5.tar.xz
more refactoring
-rw-r--r--OpenSim/Region/Application/OpenSimMain.cs15
-rw-r--r--OpenSim/Region/Communications/Local/CommunicationsLocal.cs26
-rw-r--r--OpenSim/Region/Communications/Local/LocalUserServices.cs1
-rw-r--r--OpenSim/Region/Environment/ModuleLoader.cs284
-rw-r--r--OpenSim/Region/Examples/SimpleApp/Program.cs13
5 files changed, 166 insertions, 173 deletions
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index 04b8dce..637246e 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -159,17 +159,24 @@ namespace OpenSim
159 159
160 if (m_sandbox) 160 if (m_sandbox)
161 { 161 {
162 CommunicationsLocal.LocalSettings settings = new CommunicationsLocal.LocalSettings(standaloneWelcomeMessage, standaloneAuthenticate);
163
164 LocalInventoryService inventoryService = new LocalInventoryService(); 162 LocalInventoryService inventoryService = new LocalInventoryService();
165 inventoryService.AddPlugin(standaloneInventoryPlugin); 163 inventoryService.AddPlugin(standaloneInventoryPlugin);
166 164
167 LocalUserServices userService = new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, m_networkServersInfo.DefaultHomeLocY, inventoryService ); 165 LocalUserServices userService = new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, m_networkServersInfo.DefaultHomeLocY, inventoryService );
168 userService.AddPlugin( standaloneUserPlugin ); 166 userService.AddPlugin( standaloneUserPlugin );
169 167
170 CommunicationsLocal localComms = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, settings, userService, inventoryService); 168 LocalBackEndServices backendService = new LocalBackEndServices();
169
170 CommunicationsLocal localComms = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, userService, inventoryService, backendService, backendService);
171 m_commsManager = localComms; 171 m_commsManager = localComms;
172 172
173
174 LocalLoginService loginService = new LocalLoginService(userService, standaloneWelcomeMessage, localComms, m_networkServersInfo, standaloneAuthenticate);
175 loginService.OnLoginToRegion += backendService.AddNewSession;
176
177 m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod);
178
179
173 if (standaloneAuthenticate) 180 if (standaloneAuthenticate)
174 { 181 {
175 this.CreateAccount = localComms.doCreate; 182 this.CreateAccount = localComms.doCreate;
diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
index f51f564..7a00c5a 100644
--- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
+++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
@@ -39,34 +39,14 @@ namespace OpenSim.Region.Communications.Local
39{ 39{
40 public class CommunicationsLocal : CommunicationsManager 40 public class CommunicationsLocal : CommunicationsManager
41 { 41 {
42 public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, LocalSettings settings, LocalUserServices userService, LocalInventoryService inventoryService) 42 public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, LocalUserServices userService, LocalInventoryService inventoryService, IInterRegionCommunications interRegionService, IGridServices gridService)
43 : base(serversInfo, httpServer, assetCache) 43 : base(serversInfo, httpServer, assetCache)
44 { 44 {
45 m_inventoryService = inventoryService; 45 m_inventoryService = inventoryService;
46 m_userService = userService; 46 m_userService = userService;
47 m_gridService = gridService;
48 m_interRegion = interRegionService;
47 49
48 LocalBackEndServices backendService = new LocalBackEndServices();
49 m_gridService = backendService;
50 m_interRegion = backendService;
51
52 LocalLoginService loginService = new LocalLoginService(userService, settings.WelcomeMessage, this, serversInfo, settings.AccountAuthentication);
53 loginService.OnLoginToRegion += backendService.AddNewSession;
54
55 httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod);
56 }
57
58
59
60 public class LocalSettings
61 {
62 public string WelcomeMessage;
63 public bool AccountAuthentication = false;
64
65 public LocalSettings(string welcomeMessage, bool accountsAuthenticate)
66 {
67 WelcomeMessage = welcomeMessage;
68 AccountAuthentication = accountsAuthenticate;
69 }
70 } 50 }
71 51
72 } 52 }
diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs
index 9e81fb8..4e75eb0 100644
--- a/OpenSim/Region/Communications/Local/LocalUserServices.cs
+++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs
@@ -22,6 +22,7 @@ namespace OpenSim.Region.Communications.Local
22 m_defaultHomeY = defaultHomeLocY; 22 m_defaultHomeY = defaultHomeLocY;
23 23
24 m_inventoryService = inventoryService; 24 m_inventoryService = inventoryService;
25
25 } 26 }
26 27
27 public override UserProfileData SetupMasterUser(string firstName, string lastName) 28 public override UserProfileData SetupMasterUser(string firstName, string lastName)
diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs
index 34cc383..2b18949 100644
--- a/OpenSim/Region/Environment/ModuleLoader.cs
+++ b/OpenSim/Region/Environment/ModuleLoader.cs
@@ -6,151 +6,151 @@ using OpenSim.Region.Environment.Interfaces;
6using OpenSim.Region.Environment.Modules; 6using OpenSim.Region.Environment.Modules;
7using OpenSim.Region.Environment.Scenes; 7using OpenSim.Region.Environment.Scenes;
8 8
9namespace OpenSim.Region.Environment 9namespace OpenSim.Region.Environment
10{ 10{
11 public class ModuleLoader 11 public class ModuleLoader
12 { 12 {
13 public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>(); 13 public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>();
14 14
15 public List<IRegionModule> LoadedModules = new List<IRegionModule>(); 15 public List<IRegionModule> LoadedModules = new List<IRegionModule>();
16 public Dictionary<string, IRegionModule> LoadedSharedModules = new Dictionary<string, IRegionModule>(); 16 public Dictionary<string, IRegionModule> LoadedSharedModules = new Dictionary<string, IRegionModule>();
17 17
18 public ModuleLoader() 18 public ModuleLoader()
19 {
20 }
21
22 /// <summary>
23 /// Should have a module factory?
24 /// </summary>
25 /// <param name="scene"></param>
26 public void CreateDefaultModules(Scene scene, string exceptModules)
19 { 27 {
20 } 28 IRegionModule module = new XferModule();
21 29 InitialiseModule(module, scene);
22 /// <summary> 30
23 /// Should have a module factory? 31 module = new ChatModule();
24 /// </summary> 32 InitialiseModule(module, scene);
25 /// <param name="scene"></param> 33
26 public void CreateDefaultModules(Scene scene, string exceptModules) 34 module = new AvatarProfilesModule();
27 { 35 InitialiseModule(module, scene);
28 IRegionModule module = new XferModule(); 36
29 InitialiseModule(module, scene); 37 LoadRegionModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene);
30 38
31 module = new ChatModule(); 39 string lslPath = Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine.DotNetEngine.dll");
32 InitialiseModule(module, scene);
33
34 module = new AvatarProfilesModule();
35 InitialiseModule(module, scene);
36
37 LoadRegionModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene);
38
39 string lslPath = Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine.DotNetEngine.dll");
40 LoadRegionModule(lslPath, "LSLScriptingModule", scene); 40 LoadRegionModule(lslPath, "LSLScriptingModule", scene);
41 } 41 }
42 42
43 43
44 public void LoadDefaultSharedModules(string exceptModules) 44 public void LoadDefaultSharedModules(string exceptModules)
45 { 45 {
46 DynamicTextureModule dynamicModule = new DynamicTextureModule(); 46 DynamicTextureModule dynamicModule = new DynamicTextureModule();
47 LoadedSharedModules.Add(dynamicModule.GetName(), dynamicModule); 47 LoadedSharedModules.Add(dynamicModule.GetName(), dynamicModule);
48 } 48 }
49 49
50 public void InitialiseSharedModules(Scene scene) 50 public void InitialiseSharedModules(Scene scene)
51 { 51 {
52 foreach (IRegionModule module in LoadedSharedModules.Values) 52 foreach (IRegionModule module in LoadedSharedModules.Values)
53 { 53 {
54 module.Initialise(scene); 54 module.Initialise(scene);
55 scene.AddModule(module.GetName(), module); //should be doing this? 55 scene.AddModule(module.GetName(), module); //should be doing this?
56 } 56 }
57 } 57 }
58 58
59 private void InitialiseModule(IRegionModule module, Scene scene) 59 private void InitialiseModule(IRegionModule module, Scene scene)
60 { 60 {
61 module.Initialise(scene); 61 module.Initialise(scene);
62 scene.AddModule(module.GetName(), module); 62 scene.AddModule(module.GetName(), module);
63 LoadedModules.Add(module); 63 LoadedModules.Add(module);
64 } 64 }
65 65
66 /// <summary> 66 /// <summary>
67 /// Loads/initialises a Module instance that can be used by mutliple Regions 67 /// Loads/initialises a Module instance that can be used by mutliple Regions
68 /// </summary> 68 /// </summary>
69 /// <param name="dllName"></param> 69 /// <param name="dllName"></param>
70 /// <param name="moduleName"></param> 70 /// <param name="moduleName"></param>
71 /// <param name="scene"></param> 71 /// <param name="scene"></param>
72 public void LoadSharedModule(string dllName, string moduleName) 72 public void LoadSharedModule(string dllName, string moduleName)
73 { 73 {
74 IRegionModule module = LoadModule(dllName, moduleName); 74 IRegionModule module = LoadModule(dllName, moduleName);
75 if (module != null) 75 if (module != null)
76 { 76 {
77 LoadedSharedModules.Add(module.GetName(), module); 77 LoadedSharedModules.Add(module.GetName(), module);
78 } 78 }
79 } 79 }
80 80
81 public void LoadRegionModule(string dllName, string moduleName, Scene scene) 81 public void LoadRegionModule(string dllName, string moduleName, Scene scene)
82 { 82 {
83 IRegionModule module = LoadModule(dllName, moduleName); 83 IRegionModule module = LoadModule(dllName, moduleName);
84 if (module != null) 84 if (module != null)
85 { 85 {
86 InitialiseModule(module, scene); 86 InitialiseModule(module, scene);
87 } 87 }
88 } 88 }
89 89
90 /// <summary> 90 /// <summary>
91 /// Loads a external Module (if not already loaded) and creates a new instance of it. 91 /// Loads a external Module (if not already loaded) and creates a new instance of it.
92 /// </summary> 92 /// </summary>
93 /// <param name="dllName"></param> 93 /// <param name="dllName"></param>
94 /// <param name="moduleName"></param> 94 /// <param name="moduleName"></param>
95 /// <param name="scene"></param> 95 /// <param name="scene"></param>
96 public IRegionModule LoadModule(string dllName, string moduleName) 96 public IRegionModule LoadModule(string dllName, string moduleName)
97 { 97 {
98 Assembly pluginAssembly = null; 98 Assembly pluginAssembly = null;
99 if (LoadedAssemblys.ContainsKey(dllName)) 99 if (LoadedAssemblys.ContainsKey(dllName))
100 { 100 {
101 pluginAssembly = LoadedAssemblys[dllName]; 101 pluginAssembly = LoadedAssemblys[dllName];
102 } 102 }
103 else 103 else
104 { 104 {
105 pluginAssembly = Assembly.LoadFrom(dllName); 105 pluginAssembly = Assembly.LoadFrom(dllName);
106 LoadedAssemblys.Add(dllName, pluginAssembly); 106 LoadedAssemblys.Add(dllName, pluginAssembly);
107 } 107 }
108 108
109 IRegionModule module = null; 109 IRegionModule module = null;
110 foreach (Type pluginType in pluginAssembly.GetTypes()) 110 foreach (Type pluginType in pluginAssembly.GetTypes())
111 { 111 {
112 if (pluginType.IsPublic) 112 if (pluginType.IsPublic)
113 { 113 {
114 if (!pluginType.IsAbstract) 114 if (!pluginType.IsAbstract)
115 { 115 {
116 Type typeInterface = pluginType.GetInterface("IRegionModule", true); 116 Type typeInterface = pluginType.GetInterface("IRegionModule", true);
117 117
118 if (typeInterface != null) 118 if (typeInterface != null)
119 { 119 {
120 module = 120 module =
121 (IRegionModule) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 121 (IRegionModule) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
122 break; 122 break;
123 } 123 }
124 typeInterface = null; 124 typeInterface = null;
125 } 125 }
126 } 126 }
127 } 127 }
128 pluginAssembly = null; 128 pluginAssembly = null;
129 129
130 if ((module != null) || (module.GetName() == moduleName)) 130 if ((module != null) || (module.GetName() == moduleName))
131 { 131 {
132 return module; 132 return module;
133 } 133 }
134 134
135 return null; 135 return null;
136 } 136 }
137 137
138 public void PostInitialise() 138 public void PostInitialise()
139 { 139 {
140 foreach (IRegionModule module in LoadedSharedModules.Values) 140 foreach (IRegionModule module in LoadedSharedModules.Values)
141 { 141 {
142 module.PostInitialise(); 142 module.PostInitialise();
143 } 143 }
144 144
145 foreach (IRegionModule module in LoadedModules) 145 foreach (IRegionModule module in LoadedModules)
146 { 146 {
147 module.PostInitialise(); 147 module.PostInitialise();
148 } 148 }
149 } 149 }
150 150
151 public void ClearCache() 151 public void ClearCache()
152 { 152 {
153 LoadedAssemblys.Clear(); 153 LoadedAssemblys.Clear();
154 } 154 }
155 } 155 }
156} \ No newline at end of file 156} \ No newline at end of file
diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs
index 5f39413..e05ce87 100644
--- a/OpenSim/Region/Examples/SimpleApp/Program.cs
+++ b/OpenSim/Region/Examples/SimpleApp/Program.cs
@@ -40,13 +40,18 @@ namespace SimpleApp
40 public void Run() 40 public void Run()
41 { 41 {
42 base.StartUp(); 42 base.StartUp();
43 43
44 CommunicationsLocal.LocalSettings settings = new CommunicationsLocal.LocalSettings("", false);
45
46 LocalInventoryService inventoryService = new LocalInventoryService(); 44 LocalInventoryService inventoryService = new LocalInventoryService();
47 LocalUserServices userService = new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, m_networkServersInfo.DefaultHomeLocY, inventoryService); 45 LocalUserServices userService = new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, m_networkServersInfo.DefaultHomeLocY, inventoryService);
46 LocalBackEndServices backendService = new LocalBackEndServices();
47
48 CommunicationsLocal localComms = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, userService, inventoryService, backendService, backendService);
49 m_commsManager = localComms;
50
51 LocalLoginService loginService = new LocalLoginService(userService, "", localComms, m_networkServersInfo, false);
52 loginService.OnLoginToRegion += backendService.AddNewSession;
48 53
49 m_commsManager = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, settings, userService, inventoryService ); 54 m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod);
50 55
51 m_log.Notice(m_log.LineInfo); 56 m_log.Notice(m_log.LineInfo);
52 57