Esempio n. 1
0
        /// <summary>
        /// This method Unsubscribe
        /// </summary>
        public void Unsubscribe(Guid id)
        {
            // if the value for HasSubscribers is true
            if ((HasSubscribers) && (Subscribers.Count > 0))
            {
                // attempt to find this callback
                SubscriberCallback callback = Subscribers.FirstOrDefault(x => x.Id == id);

                // If the callback object exists
                if (NullHelper.Exists(callback))
                {
                    // Remove this item
                    Subscribers.Remove(callback);

                    // create a new message
                    SubscriberMessage message = new SubscriberMessage();

                    // set the message return properties
                    message.FromId          = ServerId;
                    message.FromName        = "Subscriber Service";
                    message.Text            = callback.Name + " has left the conversation.";
                    message.ToId            = Guid.Empty;
                    message.ToName          = "Room";
                    message.IsSystemMessage = true;

                    // Broadcast the message to everyone
                    BroadcastMessage(message);
                }
            }
        }
Esempio n. 2
0
        public void RemoveFromSubscribers(Guid subscribeId)
        {
            var subscription = Subscribers.FirstOrDefault(s => s.SubscriberId == subscribeId);

            if (subscription == null)
            {
                throw new Exception("This user is not subscribe to you");
            }

            Subscribers.Remove(subscription);
        }
Esempio n. 3
0
        /// <summary>
        /// This method returns the Subscriber
        /// </summary>
        public SubscriberCallback FindSubscriber(Guid id)
        {
            // initial value
            SubscriberCallback subscriber = null;

            // if the id Guid is set and the Subscribers exist
            if ((id != Guid.Empty) && (HasSubscribers))
            {
                // Set the return value
                subscriber = Subscribers.FirstOrDefault(x => x.Id == id);
            }

            // return value
            return(subscriber);
        }
Esempio n. 4
0
 public SampleSubscribersViewModel()
 {
     Subscribers        = _sampleSubscribers;
     SelectedSubscriber = Subscribers.FirstOrDefault();
 }