Пример #1
0
 public ServerSentEventsKeepaliveService(TServerSentEventsService serverSentEventsService, IOptions <ServerSentEventsServiceOptions <TServerSentEventsService> > options, ILogger <ServerSentEventsKeepaliveService <TServerSentEventsService> > logger)
 {
     _options = options?.Value ?? throw new ArgumentNullException(nameof(options));
     _serverSentEventsService = serverSentEventsService;
     _logger = logger;
     _logger.LogDebug($"Constructor: _options.KeepaliveMode: {_options.KeepaliveMode}");
     _logger.LogDebug($"Constructor: _isBehindAncm: {_isBehindAncm}");
 }
        /// <summary>
        /// Initializes new instance of <see cref="ServerSentEventsService"/>.
        /// </summary>
        /// <param name="options">The options for the instance.</param>
        public ServerSentEventsService(IOptions <ServerSentEventsServiceOptions <ServerSentEventsService> > options)
        {
            ServerSentEventsServiceOptions <ServerSentEventsService> serviceOptions = options?.Value;

            if ((serviceOptions != null) && ((serviceOptions.OnClientConnected != null) || (serviceOptions.OnClientDisconnected != null)))
            {
                if (serviceOptions.OnClientConnected != null)
                {
                    ClientConnected += (sender, args) => serviceOptions.OnClientConnected((IServerSentEventsService)sender, args);
                }

                if (serviceOptions.OnClientDisconnected != null)
                {
                    ClientDisconnected += (sender, args) => serviceOptions.OnClientDisconnected((IServerSentEventsService)sender, args);
                }
            }
        }