Esempio n. 1
0
        // Creates a new instance of UdpServer
        public static UdpServer Create()
        {
            var configuration = NetworkServerConfiguration.CreateFromEnviromentVariables();

            var loRaDeviceAPIService         = new LoRaDeviceAPIService(configuration, new ServiceFacadeHttpClientProvider(configuration, ApiVersion.LatestVersion));
            var frameCounterStrategyProvider = new LoRaDeviceFrameCounterUpdateStrategyProvider(configuration.GatewayID, loRaDeviceAPIService);
            var deduplicationStrategyFactory = new DeduplicationStrategyFactory(loRaDeviceAPIService);
            var adrStrategyProvider          = new LoRaADRStrategyProvider();
            var cache = new MemoryCache(new MemoryCacheOptions());
            var dataHandlerImplementation = new DefaultLoRaDataRequestHandler(configuration, frameCounterStrategyProvider, new LoRaPayloadDecoder(), deduplicationStrategyFactory, adrStrategyProvider, new LoRAADRManagerFactory(loRaDeviceAPIService), new FunctionBundlerProvider(loRaDeviceAPIService));
            var connectionManager         = new LoRaDeviceClientConnectionManager(cache);
            var loRaDeviceFactory         = new LoRaDeviceFactory(configuration, dataHandlerImplementation, connectionManager);
            var loRaDeviceRegistry        = new LoRaDeviceRegistry(configuration, cache, loRaDeviceAPIService, loRaDeviceFactory);

            var messageDispatcher = new MessageDispatcher(configuration, loRaDeviceRegistry, frameCounterStrategyProvider);
            var udpServer         = new UdpServer(configuration, messageDispatcher, loRaDeviceAPIService, loRaDeviceRegistry);

            // TODO: review dependencies
            var classCMessageSender = new DefaultClassCDevicesMessageSender(configuration, loRaDeviceRegistry, udpServer, frameCounterStrategyProvider);

            dataHandlerImplementation.SetClassCMessageSender(classCMessageSender);

            udpServer.SetClassCMessageSender(classCMessageSender);
            return(udpServer);
        }
        // Creates a new instance of UdpServer
        public static UdpServer Create()
        {
            var configuration = NetworkServerConfiguration.CreateFromEnviromentVariables();

            var loRaDeviceFactory           = new LoRaDeviceFactory(configuration);
            var loRaDeviceAPIService        = new LoRaDeviceAPIService(configuration, new ServiceFacadeHttpClientProvider(configuration, ApiVersion.LatestVersion));
            var loRaDeviceRegistry          = new LoRaDeviceRegistry(configuration, new MemoryCache(new MemoryCacheOptions()), loRaDeviceAPIService, loRaDeviceFactory);
            var frameCounterStrategyFactory = new LoRaDeviceFrameCounterUpdateStrategyFactory(configuration.GatewayID, loRaDeviceAPIService);
            var messageProcessor            = new MessageProcessor(configuration, loRaDeviceRegistry, frameCounterStrategyFactory, new LoRaPayloadDecoder());

            return(new UdpServer(configuration, messageProcessor, loRaDeviceAPIService, loRaDeviceRegistry));
        }