Beispiel #1
0
        SubscribeEnvelope ParseReceiedJSONV2(string jsonString)
        {
            if (!string.IsNullOrEmpty(jsonString))
            {
                #if (ENABLE_PUBNUB_LOGGING)
                this.PubNubInstance.PNLog.WriteToLog(string.Format("ParseReceiedJSONV2: jsonString = {0}", jsonString), PNLoggingMethod.LevelInfo);
                #endif

                //this doesnt work on JSONFx for Unity in case a string is passed in an variable of type object
                //SubscribeEnvelope resultSubscribeEnvelope = jsonPluggableLibrary.Deserialize<SubscribeEnvelope>(jsonString);
                object            resultSubscribeEnvelope = PubNubInstance.JsonLibrary.DeserializeToObject(jsonString);
                SubscribeEnvelope subscribeEnvelope       = new SubscribeEnvelope();

                if (resultSubscribeEnvelope is Dictionary <string, object> )
                {
                    Dictionary <string, object> message = (Dictionary <string, object>)resultSubscribeEnvelope;
                    subscribeEnvelope.TimetokenMeta = Helpers.CreateTimetokenMetadata(message ["t"], "Subscribe TT: ", this.PubNubInstance.PNLog);
                    subscribeEnvelope.Messages      = Helpers.CreateListOfSubscribeMessage(message ["m"], this.PubNubInstance.PNLog);

                    return(subscribeEnvelope);
                }
                else
                {
                    #if (ENABLE_PUBNUB_LOGGING)
                    this.PubNubInstance.PNLog.WriteToLog(string.Format("ParseReceiedJSONV2: resultSubscribeEnvelope is not dict"), PNLoggingMethod.LevelError);
                    #endif

                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }