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.
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using SlnMesnac.Config;
|
|
|
|
|
using TouchSocket.Sockets;
|
|
|
|
|
|
|
|
|
|
namespace SlnMesnac.TouchSocket
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 注册服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class TouchSocketSetup
|
|
|
|
|
{
|
|
|
|
|
public static void AddTouchSocketSetup(this IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
services.AddSingleton<TcpService>();//注册TouchSocket的服务
|
|
|
|
|
services.AddSingleton<TcpServer>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static IApplicationBuilder UseTouchSocketExtensions(this IApplicationBuilder app)
|
|
|
|
|
{
|
|
|
|
|
var appConfig = app.ApplicationServices.GetService<AppConfig>();
|
|
|
|
|
var _server = app.ApplicationServices.GetService<TcpServer>();
|
|
|
|
|
_server.Init(appConfig.listernPort);
|
|
|
|
|
return app;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|