Example #1
0
        internal void FindChannelEntityAndCallback(SubscribeMessage subscribeMessage, ChannelIdentity ci)
        {
            bool isPresenceChannel = Utility.IsPresenceChannel(subscribeMessage.Channel);

            PNStatus pns = new PNStatus();

            pns.Error = false;
            SubscribeEventEventArgs mea = new SubscribeEventEventArgs();

            mea.Status = pns;

            if (((subscribeMessage.SubscriptionMatch.Contains(".*")) && isPresenceChannel) || (isPresenceChannel))
            {
                #if (ENABLE_PUBNUB_LOGGING)
                this.PubNubInstance.PNLog.WriteToLog("Raising presence message event ", PNLoggingMethod.LevelInfo);
                #endif

                PNPresenceEventResult subMessageResult;
                CreatePNPresenceEventResult(subscribeMessage, out subMessageResult);
                mea.PresenceEventResult = subMessageResult;
                PubNubInstance.RaiseEvent(mea);
            }
            else
            {
                PNMessageResult subMessageResult;
                CreatePNMessageResult(subscribeMessage, out subMessageResult);
                #if (ENABLE_PUBNUB_LOGGING)
                this.PubNubInstance.PNLog.WriteToLog("Raising message event ", PNLoggingMethod.LevelInfo);
                #endif

                if (!string.IsNullOrEmpty(this.PubNubInstance.PNConfig.CipherKey) && (this.PubNubInstance.PNConfig.CipherKey.Length > 0))
                {
                    subMessageResult.Payload = Helpers.DecodeMessage(PubNubInstance.PNConfig.CipherKey, subMessageResult.Payload, PNOperationType.PNSubscribeOperation, this.PubNubInstance);
                }
                mea.MessageResult = subMessageResult;
                PubNubInstance.RaiseEvent(mea);
            }
        }