mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-02-28 07:22:52 +00:00
Remove SocketSharp from Jellyfin.Server and some other cleanup
This commit is contained in:
@@ -791,7 +791,8 @@ namespace Emby.Server.Implementations
|
||||
_configuration,
|
||||
NetworkManager,
|
||||
JsonSerializer,
|
||||
XmlSerializer);
|
||||
XmlSerializer,
|
||||
CreateHttpListener());
|
||||
|
||||
HttpServer.GlobalResponse = LocalizationManager.GetLocalizedString("StartupEmbyServerIsLoading");
|
||||
serviceCollection.AddSingleton(HttpServer);
|
||||
@@ -1125,8 +1126,6 @@ namespace Emby.Server.Implementations
|
||||
|
||||
HttpServer.Init(GetExports<IService>(false), GetExports<IWebSocketListener>());
|
||||
|
||||
//StartServer();
|
||||
|
||||
LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(),
|
||||
GetExports<IItemResolver>(),
|
||||
GetExports<IIntroProvider>(),
|
||||
@@ -1239,45 +1238,7 @@ namespace Emby.Server.Implementations
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract IHttpListener CreateHttpListener();
|
||||
|
||||
/// <summary>
|
||||
/// Starts the server.
|
||||
/// </summary>
|
||||
private void StartServer()
|
||||
{
|
||||
try
|
||||
{
|
||||
((HttpListenerHost)HttpServer).StartServer(GetUrlPrefixes().ToArray(), CreateHttpListener());
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var msg = string.Equals(ex.GetType().Name, "SocketException", StringComparison.OrdinalIgnoreCase)
|
||||
? "The http server is unable to start due to a Socket error. This can occasionally happen when the operating system takes longer than usual to release the IP bindings from the previous session. This can take up to five minutes. Please try waiting or rebooting the system."
|
||||
: "Error starting Http Server";
|
||||
|
||||
Logger.LogError(ex, msg);
|
||||
|
||||
if (HttpPort == ServerConfiguration.DefaultHttpPort)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
HttpPort = ServerConfiguration.DefaultHttpPort;
|
||||
|
||||
try
|
||||
{
|
||||
((HttpListenerHost)HttpServer).StartServer(GetUrlPrefixes().ToArray(), CreateHttpListener());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error starting http server");
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
protected IHttpListener CreateHttpListener() => new WebSocketSharpListener(Logger);
|
||||
|
||||
private CertificateInfo GetCertificateInfo(bool generateCertificate)
|
||||
{
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
private readonly IServerApplicationHost _appHost;
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
private readonly IXmlSerializer _xmlSerializer;
|
||||
private readonly IHttpListener _socketListener;
|
||||
private readonly Func<Type, Func<string, object>> _funcParseFn;
|
||||
|
||||
public Action<IRequest, IResponse, object>[] ResponseFilters { get; set; }
|
||||
@@ -61,7 +62,8 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
IConfiguration configuration,
|
||||
INetworkManager networkManager,
|
||||
IJsonSerializer jsonSerializer,
|
||||
IXmlSerializer xmlSerializer)
|
||||
IXmlSerializer xmlSerializer,
|
||||
IHttpListener socketListener)
|
||||
{
|
||||
_appHost = applicationHost;
|
||||
_logger = loggerFactory.CreateLogger("HttpServer");
|
||||
@@ -70,15 +72,13 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
_networkManager = networkManager;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_xmlSerializer = xmlSerializer;
|
||||
_socketListener = socketListener;
|
||||
_socketListener.WebSocketConnected = OnWebSocketConnected;
|
||||
|
||||
_funcParseFn = t => s => JsvReader.GetParseFn(t)(s);
|
||||
|
||||
Instance = this;
|
||||
ResponseFilters = Array.Empty<Action<IRequest, IResponse, object>>();
|
||||
_websocketlistener = new WebSocketSharpListener(_logger)
|
||||
{
|
||||
WebSocketConnected = OnWebSocketConnected
|
||||
};
|
||||
}
|
||||
|
||||
public string GlobalResponse { get; set; }
|
||||
@@ -770,7 +770,8 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
|
||||
public Task ProcessWebSocketRequest(HttpContext context)
|
||||
{
|
||||
return _websocketlistener.ProcessWebSocketRequest(context);
|
||||
// TODO
|
||||
return ((WebSocketSharpListener)_socketListener).ProcessWebSocketRequest(context);
|
||||
}
|
||||
//TODO Add Jellyfin Route Path Normalizer
|
||||
|
||||
@@ -867,8 +868,6 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
_listener.WebSocketConnected = OnWebSocketConnected;
|
||||
_listener.ErrorHandler = ErrorHandler;
|
||||
_listener.RequestHandler = RequestHandler;
|
||||
|
||||
_listener.Start(UrlPrefixes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user