Esempio n. 1
0
        /// <summary>
        /// Initializes a new <see cref="MulticastSubscriptionTrackingService"/> based on
        /// the specified <paramref name="configuration"/> and wrapping the supplied
        /// <paramref name="inner"/> subscription tracking service.
        /// </summary>
        /// <param name="configuration">The multicast configuration</param>
        /// <param name="inner">The subscription tracking service that is being wrapped
        /// by the multicast subscription tracking service</param>
        /// <returns></returns>
        public Task <ISubscriptionTrackingService> InitSubscriptionTrackingService(MulticastElement configuration,
                                                                                   ISubscriptionTrackingService inner)
        {
            if (configuration == null || !configuration.Enabled)
            {
                return(Task.FromResult(inner));
            }

            var multicastTrackingService = new MulticastSubscriptionTrackingService(
                inner, configuration.Address, configuration.Port);

            return(Task.FromResult <ISubscriptionTrackingService>(multicastTrackingService));
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new <see cref="MulticastSubscriptionTrackingService"/> based on
        /// the specified <paramref name="configuration"/> and wrapping the supplied
        /// <paramref name="inner"/> subscription tracking service.
        /// </summary>
        /// <param name="configuration">The multicast configuration</param>
        /// <param name="inner">The subscription tracking service that is being wrapped
        /// by the multicast subscription tracking service</param>
        /// <returns></returns>
        public Task <ISubscriptionTrackingService> InitSubscriptionTrackingService(IConfiguration configuration,
                                                                                   ISubscriptionTrackingService inner)
        {
            var multicastSection = configuration?.GetSection("multicast");
            var multicastEnabled = multicastSection?.GetValue <bool>("enabled") ?? false;

            if (!multicastEnabled)
            {
                return(Task.FromResult(inner));
            }

            var ipAddress = multicastSection.GetValue("address", IPAddress.Parse(MulticastDefaults.Address));
            var port      = multicastSection.GetValue("port", MulticastDefaults.Port);
            var multicastTrackingService = new MulticastSubscriptionTrackingService(inner, ipAddress, port);

            return(Task.FromResult <ISubscriptionTrackingService>(multicastTrackingService));
        }