コード例 #1
0
        public void UpdateIsAwaitingConnectCallbacksOfEntity(List <ChannelEntity> channelEntity, bool isAwaitingConnectCallback)
        {
            foreach (ChannelEntity ce in channelEntity)
            {
                if (channelEntitiesDictionary.ContainsKey(ce.ChannelID))
                {
                    channelEntitiesDictionary [ce.ChannelID].IsAwaitingConnectCallback = isAwaitingConnectCallback;
                    #if (ENABLE_PUBNUB_LOGGING)
                    this.PubNubInstance.PNLog.WriteToLog(string.Format("UpdateIsAwaitingConnectCallbacksOfEntity key/val1 {0} {1}", ce.ChannelID.ChannelOrChannelGroupName, ce.ChannelID.IsChannelGroup.ToString()), PNLoggingMethod.LevelInfo);
                    #endif
                }
                #if (ENABLE_PUBNUB_LOGGING)
                else
                {
                    this.PubNubInstance.PNLog.WriteToLog(string.Format("UpdateIsAwaitingConnectCallbacksOfEntity not found key/val1 {0} {1}}", ce.ChannelID.ChannelOrChannelGroupName, ce.ChannelID.IsChannelGroup.ToString()), PNLoggingMethod.LevelInfo);
                    LogChannelEntitiesDictionary();
                }
                #endif
            }

            bool connectCallbackSent = true;

            ChannelsAndChannelGroupsAwaitingConnectCallback.Clear();
            foreach (var ci in channelEntitiesDictionary)
            {
                if (ci.Value.IsAwaitingConnectCallback)
                {
                    connectCallbackSent = false;
                    ChannelsAndChannelGroupsAwaitingConnectCallback.Add(new ChannelEntity(ci.Key, ci.Value));
                }
            }

            ConnectCallbackSent = connectCallbackSent;
        }
コード例 #2
0
 public void CleanUp()
 {
     ConnectCallbackSent = false;
     ChannelsAndChannelGroupsAwaitingConnectCallback.Clear();
     channelEntitiesDictionary.Clear();
     AllPresenceChannelsOrChannelGroups.Clear();
     AllNonPresenceChannelsOrChannelGroups.Clear();
     AllChannels.Clear();
     AllChannelGroups.Clear();
     AllSubscribedChannelsAndChannelGroups.Clear();
     CompiledUserState = String.Empty;
     CurrentSubscribedChannelsCount      = 0;
     CurrentSubscribedChannelGroupsCount = 0;
     HasChannelGroups           = false;
     HasChannels                = false;
     HasChannelsOrChannelGroups = false;
     HasPresenceChannels        = false;
 }
コード例 #3
0
        public void ResetChannelsAndChannelGroupsAndBuildState()
        {
            AllPresenceChannelsOrChannelGroups.Clear();
            AllNonPresenceChannelsOrChannelGroups.Clear();
            ChannelsAndChannelGroupsAwaitingConnectCallback.Clear();
            AllChannels.Clear();
            AllChannelGroups.Clear();
            AllSubscribedChannelsAndChannelGroups.Clear();
            HasChannelGroups                    = false;
            HasChannels                         = false;
            HasPresenceChannels                 = false;
            HasChannelsOrChannelGroups          = false;
            CurrentSubscribedChannelsCount      = 0;
            CurrentSubscribedChannelGroupsCount = 0;

            foreach (var ci in channelEntitiesDictionary)
            {
                if (ci.Value.IsSubscribed)
                {
                    if (ci.Key.IsChannelGroup)
                    {
                        CurrentSubscribedChannelGroupsCount++;
                        AllChannelGroups.Add(new ChannelEntity(ci.Key, ci.Value));
                    }
                    else
                    {
                        CurrentSubscribedChannelsCount++;
                        AllChannels.Add(new ChannelEntity(ci.Key, ci.Value));
                    }
                    AllSubscribedChannelsAndChannelGroups.Add(new ChannelEntity(ci.Key, ci.Value));

                    if (ci.Key.IsPresenceChannel)
                    {
                        AllPresenceChannelsOrChannelGroups.Add(new ChannelEntity(ci.Key, ci.Value));
                    }
                    else
                    {
                        AllNonPresenceChannelsOrChannelGroups.Add(new ChannelEntity(ci.Key, ci.Value));
                    }

                    if (ci.Value.IsAwaitingConnectCallback)
                    {
                        ChannelsAndChannelGroupsAwaitingConnectCallback.Add(new ChannelEntity(ci.Key, ci.Value));
                    }
                }
                #if (ENABLE_PUBNUB_LOGGING)
                this.PubNubInstance.PNLog.WriteToLog(string.Format("ResetChannelsAndChannelGroupsAndBuildState: channelEntities subscription key/val {0} {1}", ci.Key.ChannelOrChannelGroupName, ci.Value.IsSubscribed), PNLoggingMethod.LevelInfo);
                #endif
            }
            if (CurrentSubscribedChannelGroupsCount > 0)
            {
                HasChannelGroups = true;
            }
            if (CurrentSubscribedChannelsCount > 0)
            {
                HasChannels = true;
            }
            if (AllPresenceChannelsOrChannelGroups.Count > 0)
            {
                HasPresenceChannels = true;
            }
            if (HasChannels || HasChannelGroups)
            {
                HasChannelsOrChannelGroups = true;
            }
            #if (ENABLE_PUBNUB_LOGGING)
            this.PubNubInstance.PNLog.WriteToLog(string.Format("PrevCompiledUserState: {0}", CompiledUserState), PNLoggingMethod.LevelInfo);
            #endif

            CompiledUserState = Helpers.BuildJsonUserState(AllSubscribedChannelsAndChannelGroups);

            #if (ENABLE_PUBNUB_LOGGING)
            this.PubNubInstance.PNLog.WriteToLog(string.Format("CompiledUserState: {0}", CompiledUserState), PNLoggingMethod.LevelInfo);
            #endif
        }