Added Socket support

This commit is contained in:
2024-12-18 23:58:13 +02:00
parent 424bf2196f
commit c79c792c43
14 changed files with 251 additions and 11 deletions

View File

@@ -4,6 +4,8 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
using DiscordBotCore.API;
using DiscordBotCore.API.Endpoints;
using DiscordBotCore.API.Sockets;
using DiscordBotCore.Bot;
using DiscordBotCore.Interfaces.Logger;
using DiscordBotCore.Online;
@@ -46,7 +48,8 @@ namespace DiscordBotCore
public InternalActionManager InternalActionManager { get; private set; } = null!;
public PluginManager PluginManager { get; private set; } = null!;
public ILogger Logger { get; private set; } = null!;
public ApiManager? ApiManager { get; private set; }
internal ApiManager? ApiManager { get; private set; }
internal SocketManager? SocketManager { get; private set; }
/// <summary>
/// Create the application. This method is used to initialize the application. Can not initialize multiple times.
@@ -113,9 +116,24 @@ namespace DiscordBotCore
CurrentApplication.ApiManager = new ApiManager();
CurrentApplication.ApiManager.AddBaseEndpoints();
Thread apiThread = new Thread(() => _ = CurrentApplication.ApiManager.InitializeApi());
apiThread.Start();
CurrentApplication.ApiManager.InitializeApi();
}
public static void InitializeThreadedSockets()
{
if (CurrentApplication is null)
{
return;
}
if(CurrentApplication.SocketManager is not null)
{
return;
}
CurrentApplication.SocketManager = new SocketManager(new ConnectionDetails("localhost", 5055));
CurrentApplication.SocketManager.RegisterBaseSockets();
CurrentApplication.SocketManager.Start();
}
public static string GetResourceFullPath(string path)