clockwerk-opensim – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27  
28 using System;
29 using System.Collections.Generic;
30 using System.Net;
31 using System.Reflection;
32 using log4net;
33 using Nini.Config;
34 using OpenSim.Framework;
35  
36 namespace OpenSim.Region.ClientStack
37 {
38 public class ClientStackManager
39 {
40 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41  
42 private List<Type> plugin = new List<Type>();
43 private List<Assembly> pluginAssembly = new List<Assembly>();
44  
45 public ClientStackManager(string pDllName)
46 {
47 List<string> clientstacks = new List<string>();
48 if (pDllName.Contains(","))
49 {
50 clientstacks = new List<string>(pDllName.Split(','));
51 }
52 else
53 {
54 clientstacks.Add(pDllName);
55 }
56 foreach (string dllName in clientstacks)
57 {
58 m_log.Info("[CLIENTSTACK]: Attempting to load " + dllName);
59  
60 try
61 {
62 //plugin = null;
63 Assembly itemAssembly = Assembly.LoadFrom(dllName);
64 pluginAssembly.Add(itemAssembly);
65  
66 foreach (Type pluginType in itemAssembly.GetTypes())
67 {
68 if (pluginType.IsPublic)
69 {
70 Type typeInterface = pluginType.GetInterface("IClientNetworkServer", true);
71  
72 if (typeInterface != null)
73 {
74 m_log.Info("[CLIENTSTACK]: Added IClientNetworkServer Interface");
75 plugin.Add(pluginType);
76 break;
77 }
78 }
79 }
80 }
81 catch (ReflectionTypeLoadException e)
82 {
83 foreach (Exception e2 in e.LoaderExceptions)
84 {
85 m_log.Error(e2.ToString());
86 }
87 throw e;
88 }
89 }
90 }
91  
92 /// <summary>
93 /// Create a server that can set up sessions for virtual world client <-> server communications
94 /// </summary>
95 /// <param name="_listenIP"></param>
96 /// <param name="port"></param>
97 /// <param name="proxyPortOffset"></param>
98 /// <param name="allow_alternate_port"></param>
99 /// <param name="assetCache"></param>
100 /// <param name="authenticateClass"></param>
101 /// <returns></returns>
102 public List<IClientNetworkServer> CreateServers(
103 IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port,
104 AgentCircuitManager authenticateClass)
105 {
106 return CreateServers(
107 _listenIP, ref port, proxyPortOffset, allow_alternate_port, null, authenticateClass);
108 }
109  
110 /// <summary>
111 /// Create a server that can set up sessions for virtual world client <-> server communications
112 /// </summary>
113 /// <param name="_listenIP"></param>
114 /// <param name="port"></param>
115 /// <param name="proxyPortOffset"></param>
116 /// <param name="allow_alternate_port"></param>
117 /// <param name="configSource">
118 /// Can be null, in which case default values are used
119 /// </param>
120 /// <param name="assetCache"></param>
121 /// <param name="authenticateClass"></param>
122 /// <returns></returns>
123 public List<IClientNetworkServer> CreateServers(
124 IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, IConfigSource configSource,
125 AgentCircuitManager authenticateClass)
126 {
127 List<IClientNetworkServer> servers = new List<IClientNetworkServer>();
128 if (plugin != null)
129 {
130 for (int i = 0; i < plugin.Count; i++)
131 {
132 IClientNetworkServer server =
133 (IClientNetworkServer) Activator.CreateInstance(pluginAssembly[i].GetType(plugin[i].ToString()));
134  
135 server.Initialise(
136 _listenIP, ref port, proxyPortOffset, allow_alternate_port,
137 configSource, authenticateClass);
138 servers.Add(server);
139 }
140 return servers;
141 }
142  
143 m_log.Error("[CLIENTSTACK]: Couldn't initialize a new server");
144 return null;
145 }
146 }
147 }