public List <OutContent> ProcessSubscription(string uri, string dialogId, BatchSubscribe batchSubs, uint expires, string endpointId, object param)
        {
            Rlmi rlmi = null;
            List <Categories> categories;
            List <OutContent> multipart = null;

            lock (sync)
            {
                try
                {
                    Subscription subscription;
                    if (subscriptions.TryGetValue(dialogId, out subscription) == false)
                    {
                        subscription = new Subscription(uri, endpointId, param);
                        subscriptions.Add(dialogId, subscription);
                    }

                    subscription.Process(batchSubs, expireList, expires, out rlmi, out categories);

                    if (rlmi != null)
                    {
                        multipart = new List <OutContent>();

                        multipart.Add(new OutContent(rlmi, this.sync));

                        if (categories != null)
                        {
                            categories.ForEach(item => multipart.Add(new OutContent(item, this.sync)));
                        }
                    }

                    return(multipart);
                }
                catch (Exception e)
                {
                    throw new EnhancedPresenceException("ProcessSubscription failed", e);
                }
                finally
                {
                    if (rlmi != null)
                    {
                        rlmi.Dispose();
                    }
                }
            }
        }
Beispiel #2
0
        public void Process(BatchSubscribe batchSubs, ExpiresList expireList, uint expires, out Rlmi rlmi, out List <Categories> categories)
        {
            rlmi       = null;
            categories = null;

            if (batchSubs == null && expires == 0)
            {
                List <SubscriptionResource> resources = new List <SubscriptionResource>(Resources.Values);

                foreach (SubscriptionResource resource in resources)
                {
                    resource.Destroy();
                }
            }

            else if (batchSubs.Action == BatchSubscribeAction.Unsubscribe || expires == 0)
            {
                rlmi = Rlmi.Create(this.Uri);

                foreach (string uri in batchSubs.Resources)
                {
                    SubscriptionResource resource;

                    if (Resources.TryGetValue(uri, out resource))
                    {
                        resource.Destroy();
                    }
                }
            }

            else if (batchSubs.Action == BatchSubscribeAction.Subscribe && expires > 0)
            {
                rlmi       = Rlmi.Create(this.Uri);
                categories = new List <Categories>();

                foreach (string uri in batchSubs.Resources)
                {
                    SubscriptionResource resource;
                    if (Resources.TryGetValue(uri, out resource))
                    {
                        resource.SubsCategories = batchSubs.Сategories;
                        resource.Expires        = expires;
                    }
                    else
                    {
                        Publication publication = null;
                        if (ResolvePublicationEvent != null)
                        {
                            publication = ResolvePublicationEvent(uri);
                        }

                        if (publication != null)
                        {
                            resource = new SubscriptionResource(this, publication, batchSubs.Сategories, expireList, expires);
                        }
                        else
                        {
                            rlmi.AddResubscribe(uri);
                        }
                    }

                    if (resource != null)
                    {
                        categories.Add(
                            resource.EndSubscribeProccessing()
                            );
                    }
                }
            }
        }
Beispiel #3
0
		public void Process(BatchSubscribe batchSubs, ExpiresList expireList, uint expires, out Rlmi rlmi, out List<Categories> categories)
        {
			rlmi = null;
			categories = null;

			if (batchSubs == null && expires == 0)
			{
				List<SubscriptionResource> resources = new List<SubscriptionResource>(Resources.Values);

				foreach (SubscriptionResource resource in resources)
					resource.Destroy();
			}

			else if (batchSubs.Action == BatchSubscribeAction.Unsubscribe || expires == 0)
			{
				rlmi = Rlmi.Create(this.Uri);

				foreach (string uri in batchSubs.Resources)
				{
					SubscriptionResource resource;

					if (Resources.TryGetValue(uri, out resource))
					{
						resource.Destroy();
					}
				}
			}

			else if (batchSubs.Action == BatchSubscribeAction.Subscribe && expires > 0)
			{
				rlmi = Rlmi.Create(this.Uri);
				categories = new List<Categories>();

				foreach (string uri in batchSubs.Resources)
				{
					SubscriptionResource resource;
					if (Resources.TryGetValue(uri, out resource))
					{
						resource.SubsCategories = batchSubs.Сategories;
						resource.Expires = expires;
					}
					else
					{
						Publication publication = null;
						if (ResolvePublicationEvent != null)
							publication = ResolvePublicationEvent(uri);

						if (publication != null)
						{
							resource = new SubscriptionResource(this, publication, batchSubs.Сategories, expireList, expires);
						}
						else
						{
							rlmi.AddResubscribe(uri);
						}
					}

					if (resource != null)
					{
						categories.Add(
							resource.EndSubscribeProccessing()
						);
					}
				}
			}
        }