2016-11-12 23:33:51 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Reflection;
|
2018-09-12 13:26:21 -04:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
//using Emby.Server.CinemaMode;
|
2016-11-18 16:06:00 -05:00
|
|
|
|
using Emby.Server.Implementations;
|
2018-12-10 19:27:54 -05:00
|
|
|
|
using Emby.Server.Implementations.Library;
|
2018-09-12 13:26:21 -04:00
|
|
|
|
using Emby.Server.Implementations.HttpServer;
|
|
|
|
|
using Emby.Server.Implementations.Net;
|
2017-02-20 15:50:58 -05:00
|
|
|
|
using MediaBrowser.Controller.Connect;
|
2018-09-12 13:26:21 -04:00
|
|
|
|
using MediaBrowser.Controller.Net;
|
2017-02-23 14:13:07 -05:00
|
|
|
|
using MediaBrowser.Controller.Sync;
|
2018-11-06 11:24:06 -05:00
|
|
|
|
using IsoMounter;
|
2016-11-12 23:33:51 -05:00
|
|
|
|
using MediaBrowser.Model.IO;
|
|
|
|
|
using MediaBrowser.Model.Logging;
|
2018-09-12 13:26:21 -04:00
|
|
|
|
using MediaBrowser.Model.Services;
|
2016-11-12 23:33:51 -05:00
|
|
|
|
using MediaBrowser.Model.System;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Server.Mono
|
|
|
|
|
{
|
|
|
|
|
public class MonoAppHost : ApplicationHost
|
|
|
|
|
{
|
2017-08-17 16:19:02 -04:00
|
|
|
|
public MonoAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, MediaBrowser.Common.Net.INetworkManager networkManager) : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, networkManager)
|
2016-11-12 23:33:51 -05:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool CanSelfRestart
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
// A restart script must be provided
|
2017-10-13 01:42:12 -04:00
|
|
|
|
return StartupOptions.ContainsOption("-restartpath");
|
2016-11-12 23:33:51 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 13:26:21 -04:00
|
|
|
|
//protected override ISyncManager CreateSyncManager()
|
|
|
|
|
//{
|
|
|
|
|
// return new SyncManager();
|
|
|
|
|
//}
|
2017-02-23 14:13:07 -05:00
|
|
|
|
|
2016-11-12 23:33:51 -05:00
|
|
|
|
protected override void RestartInternal()
|
|
|
|
|
{
|
2017-08-28 14:19:23 -04:00
|
|
|
|
MainClass.Restart();
|
2016-11-12 23:33:51 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override List<Assembly> GetAssembliesWithPartsInternal()
|
|
|
|
|
{
|
|
|
|
|
var list = new List<Assembly>();
|
|
|
|
|
|
|
|
|
|
list.Add(GetType().Assembly);
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ShutdownInternal()
|
|
|
|
|
{
|
|
|
|
|
MainClass.Shutdown();
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-19 00:52:49 -05:00
|
|
|
|
protected override bool SupportsDualModeSockets
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return GetMonoVersion() >= new Version(4, 6);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Version GetMonoVersion()
|
|
|
|
|
{
|
|
|
|
|
Type type = Type.GetType("Mono.Runtime");
|
|
|
|
|
if (type != null)
|
|
|
|
|
{
|
|
|
|
|
MethodInfo displayName = type.GetTypeInfo().GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
|
|
|
|
var displayNameValue = displayName.Invoke(null, null).ToString().Trim().Split(' ')[0];
|
|
|
|
|
|
|
|
|
|
Version version;
|
|
|
|
|
if (Version.TryParse(displayNameValue, out version))
|
|
|
|
|
{
|
|
|
|
|
return version;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Version(1, 0);
|
|
|
|
|
}
|
2018-09-12 13:26:21 -04:00
|
|
|
|
|
|
|
|
|
protected override IHttpListener CreateHttpListener()
|
|
|
|
|
{
|
|
|
|
|
return new EmbyServer.SocketSharp.WebSocketSharpListener(LogManager.GetLogger("HttpServer"),
|
|
|
|
|
Certificate,
|
|
|
|
|
StreamHelper,
|
|
|
|
|
TextEncoding,
|
|
|
|
|
NetworkManager,
|
|
|
|
|
SocketFactory,
|
|
|
|
|
CryptographyProvider,
|
|
|
|
|
SupportsDualModeSockets,
|
|
|
|
|
FileSystemManager,
|
|
|
|
|
EnvironmentInfo);
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-12 23:33:51 -05:00
|
|
|
|
}
|
|
|
|
|
}
|