| 32 |
using System.Net; |
using System.Net; |
| 33 |
using System.IO; |
using System.IO; |
| 34 |
using System.Xml; |
using System.Xml; |
| 35 |
|
using System.Reflection; |
| 36 |
|
using ExtensionLoader; |
| 37 |
using OpenMetaverse; |
using OpenMetaverse; |
| 38 |
using OpenMetaverse.Capabilities; |
using OpenMetaverse.Capabilities; |
| 39 |
using OpenMetaverse.StructuredData; |
using OpenMetaverse.StructuredData; |
| 45 |
public int HttpPort = 9001; |
public int HttpPort = 9001; |
| 46 |
public HttpServer HttpServer; |
public HttpServer HttpServer; |
| 47 |
|
|
| 48 |
|
public IMetadataProvider MethodMetadata; |
| 49 |
|
public IDataProvider MethodData; |
| 50 |
|
public ICreateAssetProvider MethodCreateAsset; |
| 51 |
|
|
| 52 |
public AssetServer() |
public AssetServer() |
| 53 |
{ |
{ |
| 54 |
} |
} |
| 57 |
{ |
{ |
| 58 |
HttpPort = port; |
HttpPort = port; |
| 59 |
|
|
| 60 |
InitHttpServer(HttpPort, ssl); |
try |
| 61 |
|
{ |
| 62 |
|
// Load all of the extensions |
| 63 |
|
List<string> references = new List<string>(); |
| 64 |
|
references.Add("OpenMetaverseTypes.dll"); |
| 65 |
|
references.Add("OpenMetaverse.dll"); |
| 66 |
|
references.Add("AssetServer.exe"); |
| 67 |
|
|
| 68 |
|
Dictionary<Type, FieldInfo> assignables = GetInterfaces(); |
| 69 |
|
ExtensionLoader<AssetServer>.LoadAllExtensions(Assembly.GetExecutingAssembly(), |
| 70 |
|
AppDomain.CurrentDomain.BaseDirectory, this, references, |
| 71 |
|
"AssetServer.*.dll", "AssetServer.*.cs", this, assignables); |
| 72 |
|
} |
| 73 |
|
catch (ExtensionException ex) |
| 74 |
|
{ |
| 75 |
|
Logger.Log("Interface loading failed, shutting down: " + ex.Message, Helpers.LogLevel.Error); |
| 76 |
|
Stop(); |
| 77 |
|
return false; |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
InitHttpServer(HttpPort, ssl); |
| 81 |
return true; |
return true; |
| 82 |
} |
} |
| 83 |
|
|
| 86 |
HttpServer.Stop(); |
HttpServer.Stop(); |
| 87 |
} |
} |
| 88 |
|
|
| 89 |
|
Dictionary<Type, FieldInfo> GetInterfaces() |
| 90 |
|
{ |
| 91 |
|
Dictionary<Type, FieldInfo> interfaces = new Dictionary<Type, FieldInfo>(); |
| 92 |
|
|
| 93 |
|
foreach (FieldInfo field in this.GetType().GetFields()) |
| 94 |
|
{ |
| 95 |
|
if (field.FieldType.IsInterface) |
| 96 |
|
interfaces.Add(field.FieldType, field); |
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
return interfaces; |
| 100 |
|
} |
| 101 |
|
|
| 102 |
void InitHttpServer(int port, bool ssl) |
void InitHttpServer(int port, bool ssl) |
| 103 |
{ |
{ |
| 104 |
HttpServer = new HttpServer(HttpPort, ssl); |
HttpServer = new HttpServer(HttpPort, ssl); |