public SubscriberData GetSubscriberData()
        {
            SubscriberData data = new SubscriberData();

            data.information = "Subscriber information";

            return(data);
        }
예제 #2
0
 private void CreateSomeGlobalUnsubscriptions()
 {
     for (int index = 0; index < subscriberNames.Length; index++)
     {
         // some of them unsubscribe
         if (index % 10 == 0)
         {
             var subscriberData = SubscriberData.CreateFromFullName(subscriberNames[index]);
             CreateGlobalUnsubscription(subscriberData.Email);
         }
     }
 }
예제 #3
0
        private IList <SubscriberInfo> GenerateSubscribers()
        {
            var generatedSubscribers = new List <SubscriberInfo>();

            for (int i = 0; i < subscriberNames.Count(); i++)
            {
                var subscriberData = SubscriberData.CreateFromFullName(subscriberNames[i]);

                var contact    = CreateContact(subscriberData.FirstName, subscriberData.LastName, subscriberData.Email);
                var subscriber = CreateSubscriber(subscriberData.Email, subscriberData.FirstName, subscriberData.LastName, subscriberNames[i], contact);
                generatedSubscribers.Add(subscriber);
            }

            return(generatedSubscribers);
        }
 private void AddContactsToSubscribedContactGroup(ContactGroupInfo contactGroup)
 {
     for (var index = 0; index < _mSubscriberNames.Length; ++index)
     {
         if (index % 2 == 0)
         {
             var fromFullName = SubscriberData.CreateFromFullName(_mSubscriberNames[index]);
             AddContactToContactGroup(ContactInfoProvider.GetContactInfo(fromFullName.Email), contactGroup);
             if (index % 10 == 0)
             {
                 CreateGlobalUnsubscription(fromFullName.Email);
             }
         }
     }
 }
        private IList <SubscriberInfo> GenerateSubscribers()
        {
            var subscriberInfoList = new List <SubscriberInfo>();

            for (var index = 0; index < _mSubscriberNames.Length; ++index)
            {
                var fromFullName = SubscriberData.CreateFromFullName(_mSubscriberNames[index]);
                var contact      = CreateContact(fromFullName.FirstName, fromFullName.LastName, fromFullName.Email);
                var subscriber   = CreateSubscriber(fromFullName.Email, fromFullName.FirstName, fromFullName.LastName,
                                                    _mSubscriberNames[index], contact);
                subscriberInfoList.Add(subscriber);
            }

            return(subscriberInfoList);
        }
예제 #6
0
        public void AddSubscriber <DataType>(string topic, Subscriber <DataType> subscriber)
        {
            var bridgeType = Plugin.GetBridgeType <DataType>();

            if (bridgeType == null)
            {
                throw new Exception($"Unknown data type {typeof(DataType).Name} used for subscriber in {Plugin.Name} bridge");
            }

            SubscriberData.Add(new TopicData(topic, bridgeType));

            if (Subscribers.TryGetValue(topic, out var sub))
            {
                lock (sub)
                {
                    sub.Callbacks.Add(subscriber);
                }
                return;
            }

            sub = new SubscriberCallbacks();
            sub.Callbacks.Add(subscriber);

            var subCreator = Plugin.GetCreateSubscriber <DataType>();

            if (subCreator == null)
            {
                throw new NotSupportedException($"Subscriber on {topic} topic for for {typeof(DataType).Name} not supported by {Plugin.Name} bridge");
            }

            subCreator(Instance, topic, data =>
            {
                foreach (var s in SubscriberData)
                {
                    if (s.Topic == topic)
                    {
                        s.Count += 1;
                    }
                }

                lock (sub)
                {
                    sub.Callbacks.ForEach(cb => Actions.Enqueue(() => (cb as Subscriber <DataType>)(data)));
                }
            });

            Subscribers.Add(topic, sub);
        }
예제 #7
0
        public void Update()
        {
            if (Status != Status.Connected)
            {
                PublisherData.Clear();
                SubscriberData.Clear();

                while (Actions.TryDequeue(out var action))
                {
                }
            }

            foreach (var pub in PublisherData)
            {
                if (pub.ElapsedTime >= 1 && pub.Count > pub.StartCount)
                {
                    pub.Frequency   = (pub.Count - pub.StartCount) / pub.ElapsedTime;
                    pub.StartCount  = pub.Count;
                    pub.ElapsedTime = 0f;
                }
                else
                {
                    pub.ElapsedTime += Time.unscaledDeltaTime;
                }
            }

            foreach (var sub in SubscriberData)
            {
                if (sub.ElapsedTime >= 1 && sub.Count > sub.StartCount)
                {
                    sub.Frequency   = (sub.Count - sub.StartCount) / sub.ElapsedTime;
                    sub.StartCount  = sub.Count;
                    sub.ElapsedTime = 0f;
                }
                else
                {
                    sub.ElapsedTime += Time.unscaledDeltaTime;
                }
            }

            while (Actions.TryDequeue(out var action))
            {
                action();
            }
        }
예제 #8
0
 private static bool DontWorkSubscriber(SubscriberData sd)
 {
     return(!sd.subscriber.isWorking);
 }