using NewLife.IoT.Models;
using NewLife.Remoting.Extensions;
using NewLife.Remoting.Extensions.Models;
using NewLife.Remoting.Extensions.Services;
using NewLife.Remoting.Models;
namespace IoTZero.Services;
public static class IoTExtensions
{
public static IServiceCollection AddIoT(this IServiceCollection services, ITokenSetting setting)
{
ArgumentNullException.ThrowIfNull(setting);
services.AddSingleton<ThingService>();
services.AddSingleton<DataService>();
services.AddSingleton<QueueService>();
services.AddSingleton<IDeviceService, MyDeviceService>();
services.AddTransient<ILoginRequest, LoginInfo>();
services.AddTransient<IPingRequest, PingInfo>();
services.AddRemoting(setting);
services.AddHostedService<ShardTableService>();
services.AddHostedService<DeviceOnlineService>();
return services;
}
public static void UseIoT(this IApplicationBuilder app)
{
app.UseRemoting();
}
}
|