Example #1
0
 public void dispose()
 {
     if (_cacheJson != null)
     _cacheJson.Dispose();
       _cacheJson = null;
 }
Example #2
0
        public YRETCODE requestAPI(ref TJsonParser apires, ref string errmsg)
        {
            TJsonParser j = null;      string buffer = "";
              int res = 0;

              // Check if we have a valid cache value
              if ((_cacheStamp > YAPI.GetTickCount()))
              {
            apires = _cacheJson;
            return YAPI.SUCCESS;
              }
              res = HTTPRequest("GET /api.json HTTP/1.1\r\n\r\n", ref buffer, ref errmsg);
              if (YAPI.YISERR(res))
              {
            // make sure a device scan does not solve the issue
            res = YAPI.yapiUpdateDeviceList(1, ref errmsg);
            if (YAPI.YISERR(res))
            {
              return res;
            }
            res = HTTPRequest("GET /api.json HTTP/1.1\r\n\r\n", ref buffer, ref errmsg);
            if (YAPI.YISERR(res))
            {
              return res;
            }
              }

              try
              {
            j = new TJsonParser(buffer);
              }
              catch (Exception E)
              {
            errmsg = "unexpected JSON structure: " + E.Message;
            return YAPI.IO_ERROR;
              }

              // store result in cache
              _cacheJson = j;
              apires = j;
              _cacheStamp = YAPI.GetTickCount() + YAPI.DefaultCacheValidity;

              return YAPI.SUCCESS;
        }
Example #3
0
 public YDevice(YDEV_DESCR devdesc)
 {
     _devdescr = devdesc;
       _cacheStamp = 0;
       _cacheJson = null;
 }