You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.3 KiB
C#

using Admin.Core.Common;
using Admin.Core.Socket;
using Admin.Core.Socket.TSocket;
using log4net;
using Microsoft.AspNetCore.Builder;
using System;
using System.Collections.Generic;
using System.Text;
using TouchSocket.Core;
using TouchSocket.Http;
using TouchSocket.Sockets;
namespace Admin.Core.Extensions
{
public static class TouchSocketMildd
{
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(TouchSocketMildd));
public static void UseTouchSocketMildd(this IApplicationBuilder app, ITouchSocketService touchSocketService, IHttpService httpService)
{
if (app == null) throw new ArgumentNullException(nameof(app));
try
{
if (Appsettings.app("Middleware", "TouchSocket", "Enabled").ObjToBool())
{
//服务器
touchSocketService.AddTouchSocketAsync(httpService);
}
else
{
Console.WriteLine("Socket 配置未启用,请启用!");
}
}
catch (Exception e)
{
log.Error($"An error was reported when starting the job service.\n{e.Message}");
throw;
}
}
}
}