123456789101112131415161718192021222324252627282930313233343536373839 |
- using EVCB_OCPP.WSServer.Service;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Logging;
- using OCPPServer.Protocol;
- using SuperWebSocket.SubProtocol;
- using System;
- using System.Collections.Generic;
- namespace EVCB_OCPP.WSServer.SuperSocket;
- public interface IOCPPWSServerFactory
- {
- OCPPWSServer Create(IEnumerable<ISubProtocol<ClientData>> subProtocols);
- }
- public class OCPPWSServerFactory : IOCPPWSServerFactory
- {
- public OCPPWSServerFactory(
- IConfiguration configuration,
- IMainDbService mainDbService,
- ILoggerFactory loggerFactory,
- IServiceProvider serviceProvider)
- {
- this.loggerFactory = loggerFactory;
- this.serviceProvider = serviceProvider;
- }
- public OCPPWSServer Create(IEnumerable<ISubProtocol<ClientData>> subProtocols)
- {
- var logger = loggerFactory.CreateLogger<OCPPWSServer>();
- var server = serviceProvider.GetRequiredService<OCPPWSServer>();
- server.RegisterSubProtocol(subProtocols);
- return server;
- }
- private readonly ILoggerFactory loggerFactory;
- private readonly IServiceProvider serviceProvider;
- }
|