Exemple #1
0
        public static void handle(JsonParser parser, JsonMessageHandler[] handlers)
        {
            parser.skipDelimiter('{');
            string key;

            parser.readKeyFromJson(out key);
            if (key != "msgid")
            {
                throw new Exception(); // bad format
            }
            ulong msgID;

            parser.parseUnsignedInteger(out msgID);
            parser.skipSpacesEtc();
            parser.skipDelimiter(',');
            parser.readKeyFromJson(out key);
            if (key != "msgbody")
            {
                throw new Exception(); // bad format
            }
            JsonMessageHandler handler = find_handler(msgID, handlers);

            if (handler != null)
            {
                handler._delegate(parser, msgID);
                //parser.skipDelimiter('}');
            }
            else
            {
                throw new Exception();
            }
        }
 public void parseKey(String expectedName)
 {
     if (!String.IsNullOrEmpty(expectedName))
     {
         String key;
         p.readKeyFromJson(out key);
         if (key != expectedName)
         {
             throw new Exception(); // bad format
         }
     }
 }
Exemple #3
0
        public static ulong parseMsgBegin(JsonParser parser)
        {
            parser.skipDelimiter('{');
            string key;

            parser.readKeyFromJson(out key);
            if (key != "msgid")
            {
                throw new Exception(); // bad format
            }
            ulong msgID;

            parser.parseUnsignedInteger(out msgID);
            parser.skipSpacesEtc();
            parser.skipDelimiter(',');
            parser.readKeyFromJson(out key);
            if (key != "msgbody")
            {
                throw new Exception(); // bad format
            }
            return(msgID);
        }