コード例 #1
0
 public SubscriberRequestCollection(IEnumerable <SubscriberItem> subscribers)
 {
     foreach (var subscriber in subscribers)
     {
         Subscribers.Add(subscriber);
     }
 }
コード例 #2
0
 /// <summary>
 /// Subscribes the specified subscriber.
 /// </summary>
 /// <param name="subscriber">The subscriber.</param>
 public void Subscribe(ISubscriber <StorageSite> subscriber)
 {
     if (!Subscribers.Contains(subscriber))
     {
         Subscribers.Add(subscriber);
     }
 }
コード例 #3
0
        private void addSubBtn_Click(object sender, EventArgs e)
        {
            Subscriber sub = new Subscriber(subTB.Text);

            Subscribers.Add(sub);
            subLB.Items.Add(sub);
        }
コード例 #4
0
        private void addSubBtn_Click(object sender, EventArgs e)
        {
            Subscriber sub = new Subscriber(subTB.Text);

            Subscribers.Add(sub);
            RefreshSubscribers();
        }
コード例 #5
0
ファイル: SubscribeManager.cs プロジェクト: zhangbo27/fireasy
 internal void AddSubscriber(ISubscriber subscriber)
 {
     if (!Subscribers.Contains(subscriber))
     {
         Subscribers.Add(subscriber);
     }
 }
コード例 #6
0
 /// <summary>
 /// Registers new subscriber to the list of subscribers - when notify is called
 /// then all currently registered subscribers are called.
 /// </summary>
 /// <param name="subscriber"></param>
 public void Attach(CalendarSubscriber subscriber)
 {
     if (!Subscribers.Contains(subscriber))
     {
         Subscribers.Add(subscriber);
     }
 }
コード例 #7
0
        public SubscribeResponseMessage Subscribe(SubscribeRequestMessage request)
        {
            var deliverTo = request.Body.Delivery.NotifyTo.ToEndpointAddress().Uri;
            var id        = Guid.NewGuid();

            var subscription = new Tuple <Uri, DateTime>(deliverTo, DateTime.UtcNow.AddMinutes(5));

            Subscribers.Add(id, subscription);

            Console.WriteLine("\tSubscription request for {0}", deliverTo);
            Console.WriteLine("\tSubscription ID {0}", id);
            Console.WriteLine("\tSubscription Expires {0}", subscription.Item2);

            // We're going to run the event source as the Subscription Manager as
            //  well so the endpoint will be the same. Because they have the same
            //  EPA.To, Event subscriber identification will be handled via the
            //  wse:Identifier header element and will be a reference header in
            //  the EPA for the subscription manager endpoint.
            var manager = new SubscriptionManager(OperationContext.Current.IncomingMessageHeaders.To);

            var response = new SubscribeResponseMessage(manager, new Expires(subscription.Item2));

            response.Identifier = id; // This will insert the wse:Identifier address header to the EPA we return to the subscriber

            return(response);
        }
コード例 #8
0
        /// <summary>
        /// method returns a message with their id
        /// </summary>
        public SubscriberMessage Subscribe(SubscriberCallback subscriber)
        {
            // initial value
            SubscriberMessage message = null;

            // If the subscriber object exists
            if ((NullHelper.Exists(subscriber)) && (HasSubscribers))
            {
                // Add this item
                Subscribers.Add(subscriber);

                // return a test message for now
                message = new SubscriberMessage();

                // set the message return properties
                message.FromName = "Subscriber Service";
                message.FromId   = ServerId;
                message.ToName   = subscriber.Name;
                message.ToId     = subscriber.Id;
                message.Data     = Subscribers.Count.ToString();
                message.Text     = "Subscribed";
            }

            // return value
            return(message);
        }
コード例 #9
0
 public SubscriberRequestCollection(IEnumerable <Uri> subscribers)
 {
     foreach (Uri subscriber in subscribers)
     {
         Subscribers.Add(subscriber);
     }
 }
コード例 #10
0
 /// <summary>
 /// Registers new subscriber to the list of subscribers - when notify is called
 /// then all currently registered subscribers are called.
 /// </summary>
 /// <param name="subscriber">New subscriber that is registered.</param>
 public void Attach(SettingsSubscriber subscriber)
 {
     if (!Subscribers.Contains(subscriber))
     {
         Subscribers.Add(subscriber);
     }
 }
コード例 #11
0
        public void AddMessageHandler <T>(Func <IHandler <T> > futureHandler) where T : Message
        {
            List <Func <Message, bool> > handlers;

            if (!_handlers.TryGetValue(typeof(T), out handlers))
            {
                handlers = new List <Func <Message, bool> >();
                _handlers.Add(typeof(T), handlers);
            }
            var handlerInstance    = futureHandler();
            var guaranteedDelivery = new GuaranteedOnceDelivery <T>(handlerInstance);

            IHandler <T> handler = new FutureHandler <T>(futureHandler);

            if (guaranteedDelivery.Enabled)
            {
                if (_messageLock == null)
                {
                    throw new Exception("IMessageLock is null. You need to specify an implementation for IMessageLock.");
                }

                handler = new ExactlyOnceHandler <T>(handler, _messageLock, guaranteedDelivery.TimeOut, handlerInstance.GetType().FullName.ToLower());
            }
            var executionTimeMonitoring = _messagingMonitor as IMeasureHandlerExecutionTime;

            if (executionTimeMonitoring != null)
            {
                handler = new StopwatchHandler <T>(handler, executionTimeMonitoring);
            }

            Subscribers.Add(new Subscriber(typeof(T)));
            handlers.Add(message => handler.Handle((T)message));
        }
コード例 #12
0
        public void AddMessageHandler <T>(Func <IHandlerAsync <T> > futureHandler) where T : Message
        {
            Subscribers.Add(new Subscriber(typeof(T)));

            var handlerFunc = _messageHandlerWrapper.WrapMessageHandler(futureHandler);

            _handlerMap.Add(typeof(T), handlerFunc);
        }
コード例 #13
0
        public static void Subscribe(ReadingSubscriber subscriber)
        {
            Logger.Debug("Adding subscriber " + subscriber.Name);

            lock (AddSubscriberLock)
            {
                Subscribers.Add(subscriber);
            }
        }
コード例 #14
0
        /// <summary>
        /// Spawns a subscriber to this controller's state
        /// </summary>
        /// <returns>State subscriber that will receive updates to this controller's state</returns>
        internal AbstractStateSubscriber SpawnSubscriber()
        {
            var sub = new AbstractStateSubscriber();

            Subscribers.Add(sub);

            sub.AbstractState = AbstractCloneState();
            return(sub);
        }
コード例 #15
0
        /// <summary>
        /// Subscribe an action for string key.
        /// </summary>
        /// <param name="key">String key for subscribe action name.</param>
        /// <param name="action">Action to call</param>
        public static void Subscribe(string key, Action action)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key), "KEY argument should have value");
            }

            Subscribers?.Add(new Tuple <string, Action>(key, action));
        }
コード例 #16
0
ファイル: Request.cs プロジェクト: ly12530/lotus-server
        public bool Subscribe(User user)
        {
            if (IsOpen)
            {
                Subscribers.Add(user);
                return(true); // Succes
            }

            return(false); // Not authorized
        }
コード例 #17
0
        public void Subscribe(IReader reader)
        {
            if (Subscribers.Contains(reader))
            {
                return;
            }

            Subscribers.Add(reader);
            Console.WriteLine($"{reader.Name} subscribed for the {Name}'s event");
        }
コード例 #18
0
 public IDisposable Subscribe(IObserver <SubscriberLogEntry> subscriber)
 {
     SubscriberLog.Unsubscriber unsub = null;
     if (!Subscribers.Contains(subscriber))
     {
         Subscribers.Add(subscriber);
         unsub = new SubscriberLog.Unsubscriber(subscriber, Subscribers);
     }
     return(unsub);
 }
コード例 #19
0
        /// <summary>
        /// Add a subscriber to the list of subscribers
        /// </summary>
        /// <param name="subscriber"></param>
        /// <returns>True if added successfully or false otherwise</returns>
        public bool AddSubscriber(ILogSubscriber subscriber)
        {
            // Add subscriber only if it doesn't exist
            Type subType = subscriber.GetType();

            if (Subscribers.All(c => c.GetType() != subType))
            {
                Subscribers.Add(subscriber);
                return(true);
            }
            return(false);
        }
コード例 #20
0
ファイル: Store.cs プロジェクト: mitrydan/identity-service
        public void Subscribe(string page, Action handler)
        {
            Debug.WriteLine($"Subscribe {page}");

            if (Subscribers.ContainsKey(page))
            {
                Subscribers[page] = handler;
            }
            else
            {
                Subscribers.Add(page, handler);
            }
        }
コード例 #21
0
ファイル: WorkItem.cs プロジェクト: skush/ODataServer
        public WorkItem(Project project, User creator, Priority priority)
        {
            Project = project;
            Creator = creator;
            // By default the Creator is added as a Subscriber to the WorkItem.
            Subscribers.Add(creator);

            Priority = priority;
            Status   = Status.Open;
            Created  = DateTime.Now;

            Project.WorkItems.Add(this);
        }
コード例 #22
0
 /// <summary>SubscribersResponse constructor.</summary>
 /// <param name="json"></param>
 public SubscribersResponse(JToken json)
 {
     if (json.SelectToken("subscriptions") != null)
     {
         foreach (JToken sub in json.SelectToken("subscriptions"))
         {
             Subscribers.Add(new Subscription(sub));
         }
     }
     if (json.SelectToken("_total") != null)
     {
         TotalSubscriberCount = int.Parse(json.SelectToken("_total").ToString());
     }
 }
コード例 #23
0
        private void EnsureConnected(TcpClientWrapper client)
        {
            Subscribers.Add(client);
            Subscribed?.Invoke(client);

            Task.Factory.StartNew(() =>
            {
                while (client.State != TcpState.Closed)
                {
                    ;
                }
                Subscribers.Remove(client);
            });
        }
コード例 #24
0
        public void AddMessageHandler <T>(Func <IHandlerAsync <T> > futureHandler) where T : Message
        {
            if (_handlerMap.ContainsKey(typeof(T)))
            {
                throw new NotSupportedException(
                          $"The handler for '{typeof(T)}' messages on this queue has already been registered.");
            }

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

            var handlerFunc = _messageHandlerWrapper.WrapMessageHandler(futureHandler);

            _handlerMap.Add(typeof(T), handlerFunc);
        }
コード例 #25
0
    public static void Subscribe(object receiver, string key, Action action)
    {
        if (key == null || receiver == null)
        {
            throw new ArgumentNullException(nameof(key), "KEY and RECEIVER argument should have value");
        }

        var listOfSubs = Subscribers?.Where(k => k.Item1 == receiver && k.Item2 == key).FirstOrDefault();

        if (listOfSubs != null)
        {
            throw new Exception("reciever already subscribed");
        }

        Subscribers?.Add(new Tuple <object, string, Action>(receiver, key, action));
    }
コード例 #26
0
        public async Task SubscribeAsync(IMqttSubscriber subscriber, string topic, MqttQualityOfServiceLevel mqttQosLevel)
        {
            if (!Subscribers.Any(e => e.Key == topic))
            {
                Subscribers.Add(new KeyValuePair <string, List <IMqttSubscriber> >(topic, new List <IMqttSubscriber>()));
            }

            var topicSubscribers = Subscribers.First(e => e.Key == topic).Value;

            // client already subscribed to this topic
            if (!topicSubscribers.Contains(subscriber))
            {
                await MqttClient.SubscribeAsync(topic, mqttQosLevel);

                topicSubscribers.Add(subscriber);
            }
        }
コード例 #27
0
        protected override void ObservableSubscriberConnectCompleted(object sender, AsyncCompletedEventArgs e)
        {
            var subscriber = sender as IObservableSubscriber <T>;

            if (subscriber != null)
            {
                if (e.Error == null)
                {
                    subscriber.DataUpdated += SubscriberDataUpdated;
                    Subscribers.Add(subscriber);
                }
                else
                {
                    OnMassage("Variable: " + subscriber.BrowserItem.Name + " failed to subscribe");
                }
            }
        }
コード例 #28
0
        public async void Subscribe(AbstractCommand command)
        {
            if (this.IsConnected)
            {
                await this._mqttClient.SubscribeAsync(((CommandDiscoveryConfigModel)command.GetAutoDiscoveryConfig()).Command_topic);
            }
            else
            {
                while (this.IsConnected == false)
                {
                    await Task.Delay(5500);
                }

                await this._mqttClient.SubscribeAsync(((CommandDiscoveryConfigModel)command.GetAutoDiscoveryConfig()).Command_topic);
            }

            Subscribers.Add(command);
        }
コード例 #29
0
 public void Subscribe(string uniqueKey, string tableName)
 {
     try
     {
         IEventNotificationCallback callback = OperationContext.Current.GetCallbackChannel <IEventNotificationCallback>();
         lock (locker)
         {
             Subscriber subscriber = new Subscriber();
             subscriber.Id = uniqueKey;
             subscriber.TableInterested = tableName;
             Subscribers.Add(subscriber, callback);
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex, ex.Message);
         throw;
     }
 }
コード例 #30
0
        public PubSubViewModel()
        {
            PublishCommand = new ActionCommand()
            {
                CanExecuteFunction = e => { return(Publishers.Count > 0); },
                ExecuteAction      = e => {
                    if (serviceCalls != null)
                    {
                        serviceCalls.Terminator.Cancel();
                    }
                    serviceCalls = new PublicationPump(() => {
                        Parallel.ForEach(Publishers, x => x.Publish());
                    }, new TimeSpan(0, 0, 0, 0, 200));
                    Task.Run(() => serviceCalls.Prime());
                }
            };

            AddSubscriberCommand = new ActionCommand()
            {
                CanExecuteFunction = e => { return(true); },
                ExecuteAction      = e =>
                {
                    List <string> channels = new List <string>();
                    Publishers.ToList().ForEach(x => channels.Add(x.Channel));
                    Subscribers.Add(new SubscriberExample(channels.ToArray()));
                    OnPropertyChanged(x => x.Subscribers);
                }
            };

            AddPublisherCommand = new ActionCommand()
            {
                CanExecuteFunction = e => { return(true); },
                ExecuteAction      = e =>
                {
                    Publishers.Add(new ImagePublisherExample()
                    {
                        Channel = $"channel{Publishers.Count}"
                    });
                    OnPropertyChanged(x => x.Publishers);
                }
            };
        }