Beispiel #1
0
        public static TimetokenMetadata CreateTimetokenMetadata(object timeTokenDataObject, string whichTT, PNLoggingMethod pnLog)
        {
            Dictionary <string, object> timeTokenData = (Dictionary <string, object>)timeTokenDataObject;
            string log;
            long   timetoken;

            Utility.TryCheckKeyAndParseLong(timeTokenData, whichTT, "t", out log, out timetoken);
            TimetokenMetadata timetokenMetadata = new TimetokenMetadata(timetoken, (timeTokenData.ContainsKey("r")) ? timeTokenData["r"].ToString(): "");

            #if (ENABLE_PUBNUB_LOGGING)
            pnLog.WriteToLog(string.Format("TimetokenMetadata: {0} \nTimetoken: {1} \nRegion: {2}\nlog : {3}", whichTT, timetokenMetadata.Timetoken, timetokenMetadata.Region, log), PNLoggingMethod.LevelInfo);
            #endif

            return(timetokenMetadata);
        }
Beispiel #2
0
        }                             //JSON userMetadata

        internal SubscribeMessage(string shard, string subscriptionMatch, string channel, object payload,
                                  string flags, string issuingClientId, string subscribeKey, long sequenceNumber, TimetokenMetadata originatingTimetoken,
                                  TimetokenMetadata publishMetadata, object userMetadata
                                  )
        {
            this.a = shard;
            this.b = subscriptionMatch;
            this.c = channel;
            this.d = payload;
            this.f = flags;
            this.i = issuingClientId;
            this.k = subscribeKey;
            this.s = sequenceNumber;
            this.o = originatingTimetoken;
            this.p = publishMetadata;
            this.u = userMetadata;
        }
Beispiel #3
0
        public static bool TryAddToSubscribeMessageList(object dictObject, ref List <SubscribeMessage> subscribeMessages, PNLoggingMethod pnLog)
        {
            var dict = dictObject as IDictionary;

            if ((dict != null) && (dict.Count > 1))
            {
                string shard             = (dict.Contains("a")) ? dict ["a"].ToString() : "";
                string subscriptionMatch = (dict.Contains("b")) ? dict ["b"].ToString() : "";
                string channel           = (dict.Contains("c")) ? dict ["c"].ToString() : "";
                object payload           = (dict.Contains("d")) ? (object)dict ["d"] : null;
                string flags             = (dict.Contains("f")) ? dict ["f"].ToString() : "";
                string issuingClientId   = (dict.Contains("i")) ? dict ["i"].ToString() : "";
                string subscribeKey      = (dict.Contains("k")) ? dict ["k"].ToString() : "";
                string log;
                long   sequenceNumber;
                Utility.TryCheckKeyAndParseLong(dict, "sequenceNumber", "s", out log, out sequenceNumber);

                TimetokenMetadata originatingTimetoken = (dict.Contains("o")) ? Helpers.CreateTimetokenMetadata(dict ["o"], "Originating TT: ", pnLog) : null;
                TimetokenMetadata publishMetadata      = (dict.Contains("p")) ? Helpers.CreateTimetokenMetadata(dict ["p"], "Publish TT: ", pnLog) : null;
                object            userMetadata         = (dict.Contains("u")) ? (object)dict ["u"] : null;

                int messageType;
                Utility.TryCheckKeyAndParseInt(dict, "messageType", "e", out log, out messageType);

                SubscribeMessage subscribeMessage = new SubscribeMessage(
                    shard,
                    subscriptionMatch,
                    channel,
                    payload,
                    flags,
                    issuingClientId,
                    subscribeKey,
                    sequenceNumber,
                    originatingTimetoken,
                    publishMetadata,
                    userMetadata,
                    messageType
                    );
                #if (ENABLE_PUBNUB_LOGGING)
                pnLog.WriteToLog(string.Format("AddToSubscribeMessageList: \n" +
                                               "shard : {0},\n" +
                                               "subscriptionMatch: {1},\n" +
                                               "channel: {2},\n" +
                                               "payload: {3},\n" +
                                               "flags: {4},\n" +
                                               "issuingClientId: {5},\n" +
                                               "subscribeKey: {6},\n" +
                                               "sequenceNumber: {7},\n" +
                                               "originatingTimetoken tt: {8},\n" +
                                               "originatingTimetoken region: {9},\n" +
                                               "publishMetadata tt: {10},\n" +
                                               "publishMetadata region: {11},\n" +
                                               "userMetadata {12} \n" +
                                               "log {13} \n",
                                               "messageType {14}\n",

                                               shard,
                                               subscriptionMatch,
                                               channel,
                                               payload.ToString(),
                                               flags,
                                               issuingClientId,
                                               subscribeKey,
                                               sequenceNumber,
                                               (originatingTimetoken != null) ? originatingTimetoken.Timetoken.ToString() : "",
                                               (originatingTimetoken != null) ? originatingTimetoken.Region : "",
                                               (publishMetadata != null) ? publishMetadata.Timetoken.ToString() : "",
                                               (publishMetadata != null) ? publishMetadata.Region : "",
                                               (userMetadata != null) ? userMetadata.ToString() : "null",
                                               log,
                                               messageType),
                                 PNLoggingMethod.LevelInfo);
                #endif

                subscribeMessages.Add(subscribeMessage);
                return(true);
            }
            #if (ENABLE_PUBNUB_LOGGING)
            else
            {
                pnLog.WriteToLog(string.Format("AddToSubscribeMessageList: CreateListOfSubscribeMessage create SubscribeMessage failed. dictObject type: {0}, dict type : {1}", dictObject.ToString(), dict.ToString()), PNLoggingMethod.LevelInfo);
            }
            #endif
            return(false);
        }