Beispiel #1
0
        protected override void RunWebRequest(QueueManager qm)
        {
            RequestState requestState = new RequestState();

            requestState.OperationType = OperationType;

            string channels = "";

            if (ChannelsToUse != null)
            {
                channels = string.Join(",", ChannelsToUse.ToArray());
            }
            string channelGroups = "";

            if (ChannelGroupsToUse != null)
            {
                channelGroups = string.Join(",", ChannelGroupsToUse.ToArray());
            }

            if (string.IsNullOrEmpty(channels) && (string.IsNullOrEmpty(channelGroups)))
            {
                #if (ENABLE_PUBNUB_LOGGING)
                this.PubNubInstance.PNLog.WriteToLog(string.Format("Both ChannelGroupsToLeave and ChannelsToLeave are empty, running unsubscribe all"), PNLoggingMethod.LevelInfo);
                #endif

                channelGroups      = Helpers.GetNamesFromChannelEntities(this.PubNubInstance.SubscriptionInstance.AllChannelGroups, true);
                channels           = Helpers.GetNamesFromChannelEntities(this.PubNubInstance.SubscriptionInstance.AllChannels, false);
                ChannelsToUse      = Helpers.CreateListOfStringFromListOfChannelEntity(this.PubNubInstance.SubscriptionInstance.AllChannels);
                ChannelGroupsToUse = Helpers.CreateListOfStringFromListOfChannelEntity(this.PubNubInstance.SubscriptionInstance.AllChannelGroups);
            }

            List <ChannelEntity> subscribedChannels = this.PubNubInstance.SubscriptionInstance.AllSubscribedChannelsAndChannelGroups;

            List <ChannelEntity> newChannelEntities;
            this.PubNubInstance.SubscriptionInstance.TryRemoveDuplicatesCheckAlreadySubscribedAndGetChannels(
                OperationType,
                ChannelsToUse,
                ChannelGroupsToUse,
                true,
                out
                newChannelEntities
                );

            //Retrieve the current channels already subscribed previously and terminate them
            this.PubNubInstance.SubWorker.AbortPreviousRequest(subscribedChannels);

            if (!this.PubNubInstance.PNConfig.SuppressLeaveEvents)
            {
                Uri request = BuildRequests.BuildLeaveRequest(
                    channels,
                    channelGroups,
                    this.PubNubInstance
                    );
                base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
            }

            RemoveUnsubscribedChannelsAndDeleteUserState(newChannelEntities);


            //Get all the channels
            this.PubNubInstance.SubWorker.ContinueToSubscribeRestOfChannels();
        }