// Token: 0x0600051B RID: 1307 RVA: 0x000210DC File Offset: 0x0001F2DC
        public string Subscribe(string subscribeQuery, INotificationSubscriber notificationSubscriber)
        {
            if (string.IsNullOrEmpty(subscribeQuery))
            {
                throw new ArgumentException("subscribeQuery");
            }
            if (notificationSubscriber == null)
            {
                throw new ArgumentNullException("notificationSubscriber");
            }
            ServiceHost serviceHost = new ServiceHost(notificationSubscriber, Array.Empty <Uri>());

            serviceHost.AddServiceEndpoint(typeof(INotificationSubscriber), new NetTcpBinding
            {
                PortSharingEnabled = true
            }, this.netObjectOperationEndpoint);
            serviceHost.Open();
            PropertyBag propertyBag = new PropertyBag();

            propertyBag.Add("Query", subscribeQuery);
            propertyBag.Add("EndpointAddress", this.netObjectOperationEndpoint);
            PropertyBag propertyBag2 = propertyBag;
            string      text         = this.swisProxy.Create("System.Subscription", propertyBag2);

            this.subscriptionUriList.Add(text);
            this.log.DebugFormat("Swis subscribed with subscriptionUri: {0}", text);
            this.log.DebugFormat("Swis subscribed with query: {0}", subscribeQuery);
            return(text);
        }
 public NotificationCenterSender(IMessengerProvider messengerProvider, INotificationSubscriber subscriber, IDbContextFetcher dbContextFetcher, EmailSender emailSender)
 {
     this._messengerProvider = messengerProvider;
     this._subscriber        = subscriber;
     this._context           = dbContextFetcher.FetchDbContext <INotificationCenterDbContext>();
     this._emailSender       = emailSender;
 }
        public void AddNotificationSubscriber(string region, INotificationSubscriber subscriber)
        {
            if (string.IsNullOrWhiteSpace(region))
            {
                throw new ArgumentNullException(nameof(region));
            }

            if (!_subscribersByRegionAndQueue.TryGetValue(region, out var subscribersForRegion))
            {
                subscribersForRegion = new Dictionary <string, INotificationSubscriber>();
                _subscribersByRegionAndQueue.Add(region, subscribersForRegion);
            }

            if (subscribersForRegion.ContainsKey(subscriber.Queue))
            {
                // TODO - no, we don't need to create a new notification subsrciber per queue
                // JustSaying is creating subscribers per-topic per-region, but
                // we want to have that per-queue per-region, not
                // per-topic per-region.
                // Just re-use existing subscriber instead.
                return;
            }
            subscribersForRegion[subscriber.Queue] = subscriber;

            AddSubscribersToInterrogationResponse(subscriber);
        }
        public string Subscribe(string subscribeQuery, INotificationSubscriber notificationSubscriber)
        {
            if (string.IsNullOrEmpty(subscribeQuery))
            {
                throw new ArgumentException(nameof(subscribeQuery));
            }
            if (notificationSubscriber == null)
            {
                throw new ArgumentNullException(nameof(notificationSubscriber));
            }
            ServiceHost serviceHost = new ServiceHost((object)notificationSubscriber, Array.Empty <Uri>());

            System.Type   implementedContract = typeof(INotificationSubscriber);
            NetTcpBinding netTcpBinding       = new NetTcpBinding();

            netTcpBinding.PortSharingEnabled = true;
            string operationEndpoint = this.netObjectOperationEndpoint;

            serviceHost.AddServiceEndpoint(implementedContract, (Binding)netTcpBinding, operationEndpoint);
            serviceHost.Open();
            PropertyBag propertyBag = new PropertyBag();

            ((Dictionary <string, object>)propertyBag).Add("Query", (object)subscribeQuery);
            ((Dictionary <string, object>)propertyBag).Add("EndpointAddress", (object)this.netObjectOperationEndpoint);
            string str = this.swisProxy.Create("System.Subscription", propertyBag);

            this.subscriptionUriList.Add(str);
            this.log.DebugFormat("Swis subscribed with subscriptionUri: {0}", (object)str);
            this.log.DebugFormat("Swis subscribed with query: {0}", (object)subscribeQuery);
            return(str);
        }
 protected override void Given()
 {
     base.Given();
     _subscriber = Substitute.For<INotificationSubscriber>();
     _handler1 = Substitute.For<IHandlerAsync<Message>>();
     _handler2 = Substitute.For<IHandlerAsync<Message2>>();
     _region = "west-1";
 }
示例#6
0
 protected override void Given()
 {
     base.Given();
     _subscriber1 = Substitute.For<INotificationSubscriber>();
     _subscriber1.Queue.Returns("queue1");
     _subscriber2 = Substitute.For<INotificationSubscriber>();
     _subscriber2.Queue.Returns("queue2");
 }
示例#7
0
 protected override void Given()
 {
     base.Given();
     _subscriber = Substitute.For <INotificationSubscriber>();
     _handler1   = Substitute.For <IHandler <Message> >();
     _handler2   = Substitute.For <IHandler <Message> >();
     _topic      = "message"; //same as message name
 }
示例#8
0
 protected override void Given()
 {
     base.Given();
     _subscriber = Substitute.For <INotificationSubscriber>();
     _handler1   = Substitute.For <IHandlerAsync <Message> >();
     _handler2   = Substitute.For <IHandlerAsync <Message2> >();
     _region     = "west-1";
 }
示例#9
0
 protected override void Given()
 {
     base.Given();
     _subscriber1 = Substitute.For <INotificationSubscriber>();
     _subscriber1.Queue.Returns("queue1");
     _subscriber2 = Substitute.For <INotificationSubscriber>();
     _subscriber2.Queue.Returns("queue2");
 }
 protected override void Given()
 {
     base.Given();
     _subscriber = Substitute.For<INotificationSubscriber>();
     _handler1 = Substitute.For<IHandler<Message>>();
     _handler2 = Substitute.For<IHandler<Message2>>();
     _topic = "message"; //same as message name
     _topic2 = "message2"; //same as message name
 }
示例#11
0
        public SubscriptionServiceHost(INotificationSubscriber subscriber)
        {
            this.subscriber = subscriber;

            var processId = Process.GetCurrentProcess().Id;
            netTcpAddress = string.Format("net.tcp://{0}:17777/SolarWinds/SwqlStudio/{1}", ResolveLocalIPAddress(), processId);

            httpAddress = string.Format("https://{0}:17778/SolarWinds/SwqlStudio/{1}", Utility.GetFqdn(), processId);
        }
示例#12
0
        public INotificationUnsubscriber Subscribe(INotificationSubscriber notificationSubscriber)
        {
            if (!_notificationSubscribersList.Contains(notificationSubscriber))
            {
                _notificationSubscribersList.Add(notificationSubscriber);
            }

            return(new DefaultNotificationUnsubscriber(_notificationSubscribersList, notificationSubscriber));
        }
示例#13
0
        internal NotificationDeliveryServiceProxy CreateActiveListenerProxy(INotificationSubscriber listener)
        {
            if (!_infoServiceType.SupportsActiveSubscriber)
            {
                throw new InvalidOperationException("This connection type doesn't support active subscriptions");
            }

            return(_infoServiceType.CreateNotificationDeliveryServiceProxy(_server, listener));
        }
        public void RemoveSubscriber(INotificationSubscriber subscriber)
        {
            if (subscriber == null)
            {
                throw new ArgumentNullException(nameof(subscriber));
            }

            subscribers.Remove(subscriber);
        }
示例#15
0
        public SubscriptionServiceHost(INotificationSubscriber subscriber)
        {
            this.subscriber = subscriber;

            var processId = Process.GetCurrentProcess().Id;

            netTcpAddress = string.Format("net.tcp://{0}:17777/SolarWinds/SwqlStudio/{1}", ResolveLocalIPAddress(), processId);

            httpAddress = string.Format("https://{0}:17778/SolarWinds/SwqlStudio/{1}", Utility.GetFqdn(), processId);
        }
示例#16
0
        public override NotificationDeliveryServiceProxy CreateNotificationDeliveryServiceProxy(string server, INotificationSubscriber notificationSubscriber)
        {
            var endpointAddress = new EndpointAddress(string.Format("net.tcp://{0}:17777/SolarWinds/InformationService/v3/Orion/IndicationDelivery", server));
            var context = new InstanceContext(notificationSubscriber);
            
            var proxy = new NotificationDeliveryServiceProxy(context, (NetTcpBinding)_binding, endpointAddress);
            _credentials.ApplyTo(proxy.ChannelFactory);

            return proxy;
        }
示例#17
0
 public void Unsubscribe(INotificationSubscriber subscriber)
 {
     lock (busSync)
     {
         if (subscribers.Contains(subscriber))
         {
             subscribers.Remove(subscriber);
         }
     }
 }
示例#18
0
 public void Subscribe(INotificationSubscriber subscriber)
 {
     lock (busSync)
     {
         if (!subscribers.Contains(subscriber))
         {
             subscribers.Add(subscriber);
         }
     }
 }
        protected override async Task Given()
        {
            await base.Given();

            _futureHandler1 = () => _handler1;
            _futureHandler2 = () => _handler2;
            _subscriber     = Substitute.For <INotificationSubscriber>();
            _handler1       = Substitute.For <IHandlerAsync <Message> >();
            _handler2       = Substitute.For <IHandlerAsync <Message2> >();
            _region         = "west-1";
        }
        public void AddSubscriber(INotificationSubscriber sub)
        {
            if (sub == null)
            {
                throw new ArgumentNullException($"{nameof(sub)} is null");
            }

            this.subscribers.Add(sub);
            this.UserAdded   += sub.UserAdded;
            this.UserRemoved += sub.UserRemoved;
        }
 /// <summary>
 /// Stop listening to notifications for specified topics
 /// </summary>
 /// <param name="subscriber"></param>
 /// <param name="topics"></param>
 public void Unsubscribe(INotificationSubscriber subscriber, params Notification.Topic[] topics)
 {
     if (subscriber == null)
     {
         return;
     }
     foreach (var topic in topics)
     {
         m_SubscribersByTopic[topic].Remove(subscriber);
     }
 }
        /// <summary>
        /// Subscribe to specified topics to listen to notifications
        /// </summary>
        /// <param name="subscriber"></param>
        /// <param name="topics"></param>
        /// <returns>The list of current notifications for the specified topics</returns>
        public IEnumerable <Notification> Subscribe(INotificationSubscriber subscriber, params Notification.Topic[] topics)
        {
            if (subscriber == null)
            {
                return(new List <Notification>());
            }
            foreach (var topic in topics)
            {
                m_SubscribersByTopic[topic].Add(subscriber);
            }

            return(GetNotificationsForTopics(topics));
        }
 protected override void Given()
 {
     base.Given();
     _subscriber1 = Substitute.For<INotificationSubscriber>();
     _subscriber1.Queue.Returns("queue1");
     _subscriber1.Subscribers.Returns(new Collection<ISubscriber>
     {
         new Subscriber(typeof (OrderAccepted)),
         new Subscriber(typeof (OrderRejected))
     });
     _subscriber2 = Substitute.For<INotificationSubscriber>();
     _subscriber2.Queue.Returns("queue2");
     _subscriber2.Subscribers.Returns(new Collection<ISubscriber> {new Subscriber(typeof (GenericMessage))});
 }
 protected override void Given()
 {
     base.Given();
     _subscriber1 = Substitute.For<INotificationSubscriber>();
     _subscriber1.Queue.Returns("queue1");
     _subscriber1.Subscribers.Returns(new Collection<ISubscriber>
     {
         new Subscriber(typeof (OrderAccepted)),
         new Subscriber(typeof (OrderRejected))
     });
     _subscriber2 = Substitute.For<INotificationSubscriber>();
     _subscriber2.Queue.Returns("queue2");
     _subscriber2.Subscribers.Returns(new Collection<ISubscriber> {new Subscriber(typeof (SimpleMessage))});
 }
        public void RemoveSubscriber(INotificationSubscriber sub)
        {
            if (sub == null)
            {
                throw new ArgumentNullException($"{nameof(sub)} is null");
            }

            if (!this.subscribers.Contains(sub))
            {
                throw new InvalidOperationException("No such subscruber was found");
            }

            this.subscribers.Remove(sub);
            this.UserAdded   -= sub.UserAdded;
            this.UserRemoved -= sub.UserRemoved;
        }
示例#26
0
        public void AddNotificationTopicSubscriber(string topic, INotificationSubscriber subscriber)
        {
            if (string.IsNullOrWhiteSpace(topic))
            {
                throw new ArgumentNullException("topic");
            }

            try
            {
                _notificationSubscribers.Add(topic, subscriber);
            }
            catch (ArgumentException)
            {
                throw new ArgumentException("You cannot declare more than one subscriber service for the same topic per component. Topic: {0}", topic);
            }
        }
示例#27
0
        public void AddNotificationTopicSubscriber(string topic, INotificationSubscriber subscriber)
        {
            if (string.IsNullOrWhiteSpace(topic))
            {
                throw new ArgumentNullException("topic");
            }

            IList <INotificationSubscriber> subscribersForTopic;

            if (!_subscribersByTopic.TryGetValue(topic, out subscribersForTopic))
            {
                subscribersForTopic = new List <INotificationSubscriber>();
                _subscribersByTopic.Add(topic, subscribersForTopic);
            }

            subscribersForTopic.Add(subscriber);
        }
示例#28
0
        private void CreateSubscriptionListener <T>(string region, SqsQueueBase queue)
            where T : Message
        {
            INotificationSubscriber subscriber = CreateSubscriber(queue);

            subscriber.Subscribers.Add(new Subscriber(typeof(T)));

            Bus.AddNotificationSubscriber(region, subscriber);

            // TODO Concrete type check for backwards compatibility for now.
            // Refactor the interface for v7 to allow this to be done against the interface.
            if (subscriber is SqsNotificationListener sqsSubscriptionListener)
            {
                if (_subscriptionConfig.MaxAllowedMessagesInFlight.HasValue)
                {
                    sqsSubscriptionListener.WithMaximumConcurrentLimitOnMessagesInFlightOf(_subscriptionConfig.MaxAllowedMessagesInFlight.Value);
                }

                if (_subscriptionConfig.MessageProcessingStrategy != null)
                {
                    sqsSubscriptionListener.WithMessageProcessingStrategy(_subscriptionConfig.MessageProcessingStrategy);
                }
            }
        }
示例#29
0
 public DefaultNotificationUnsubscriber(IList <INotificationSubscriber> notificationSubscribers, INotificationSubscriber notificationSubscriber)
 {
     _notificationSubscribers = notificationSubscribers;
     _notificationSubscriber  = notificationSubscriber;
 }
 public ChatHeadListViewModel(INotificationSubscriber notificationSubscriber, IMapping mapping)
 {
     _mapping = mapping;
     notificationSubscriber.Subscribe(this);
 }
示例#31
0
        public override NotificationDeliveryServiceProxy CreateNotificationDeliveryServiceProxy(string server, INotificationSubscriber notificationSubscriber)
        {
            var endpointAddress = new EndpointAddress(string.Format("net.tcp://{0}:17777/SolarWinds/InformationService/v3/Orion/IndicationDelivery", server));
            var context         = new InstanceContext(notificationSubscriber);

            var proxy = new NotificationDeliveryServiceProxy(context, (NetTcpBinding)_binding, endpointAddress);

            _credentials.ApplyTo(proxy.ChannelFactory);

            return(proxy);
        }
示例#32
0
 protected override void Given()
 {
     base.Given();
     _subscriber1 = Substitute.For <INotificationSubscriber>();
     _subscriber2 = Substitute.For <INotificationSubscriber>();
 }
示例#33
0
 public ChatHeadItemViewModel(INotificationSubscriber notificationSubscriber)
 {
     notificationSubscriber.Subscribe(this);
 }
示例#34
0
 public virtual NotificationDeliveryServiceProxy CreateNotificationDeliveryServiceProxy(string server, INotificationSubscriber notificationSubscriber)
 {
     throw new NotSupportedException();
 }
示例#35
0
 public SubscriptionsController(UserManager <MoxUser> userManager, INotificationSubscriber notificationSubscriber)
 {
     this._userManager            = userManager;
     this._notificationSubscriber = notificationSubscriber;
 }
示例#36
0
 public virtual NotificationDeliveryServiceProxy CreateNotificationDeliveryServiceProxy(string server, INotificationSubscriber notificationSubscriber)
 {
     throw new NotSupportedException();
 }
示例#37
0
 protected override void Given()
 {
     base.Given();
     _subscriber1 = Substitute.For<INotificationSubscriber>();
     _subscriber2 = Substitute.For<INotificationSubscriber>();
 }
 /// <summary>
 /// Helper method to simplify unsubscribe from everything
 /// </summary>
 /// <param name="subscriber"></param>
 public void UnsubscribeFromAllTopics(INotificationSubscriber subscriber)
 {
     Unsubscribe(subscriber, (Notification.Topic[])Enum.GetValues(typeof(Notification.Topic)));
 }