Ejemplo n.º 1
0
        public void AddListener(Action <PNStatus> callback, Action <PNMessageResult> callback2, Action <PNPresenceEventResult> callback3)
        {
            SusbcribeCallback += (object sender, EventArgs e) => {
                SusbcribeEventEventArgs mea = e as SusbcribeEventEventArgs;

                #if (ENABLE_PUBNUB_LOGGING)
                this.PNLog.WriteToLog("AddListener SusbcribeCallback", PNLoggingMethod.LevelInfo);
                #endif

                if (mea != null)
                {
                    if (mea.Status != null)
                    {
                        callback(mea.Status);
                    }
                    if (mea.MessageResult != null)
                    {
                        callback2(mea.MessageResult);
                    }
                    if (mea.PresenceEventResult != null)
                    {
                        callback3(mea.PresenceEventResult);
                    }
                }
            };
        }
Ejemplo n.º 2
0
        public void CreateEventArgsAndRaiseEvent(PNStatus pnStatus)
        {
            SusbcribeEventEventArgs mea = new SusbcribeEventEventArgs();

            mea.Status = pnStatus;

            PubNubInstance.RaiseEvent(mea);
        }
Ejemplo n.º 3
0
        private void PubNubUnityInitializationAfterCleanup()
        {
            if (cleanedUp)
            {
                pnUnity = new PubNubUnity(PNConfig, gameObj, jsonLibrary);

                pnUnity.SusbcribeCallback += (sender, e) => {
                    SusbcribeEventEventArgs mea = e as SusbcribeEventEventArgs;
                    #if (ENABLE_PUBNUB_LOGGING)
                    this.pnUnity.PNLog.WriteToLog("SusbcribeCallback PN", PNLoggingMethod.LevelInfo);
                    #endif
                    RaiseEvent(mea);
                };

                cleanedUp = false;
            }
        }
Ejemplo n.º 4
0
        internal void FindChannelEntityAndCallback(SubscribeMessage subscribeMessage, ChannelIdentity ci)
        {
            bool isPresenceChannel = Utility.IsPresenceChannel(subscribeMessage.Channel);

            PNStatus pns = new PNStatus();

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

            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);
            }
        }