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();
            }
        }
Exemple #2
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);
        }