verify static method

Future<int> verify(
  1. String appid,
  2. String secret, {
  3. DynamicLibrary? nativeLib,
})

Implementation

static Future<int> verify(String appid, String secret,
    {DynamicLibrary? nativeLib}) async {
  final client = HttpClient();
  try {
    final req = await client.getUrl(
        Uri.parse('http://sdk.hicling.com:8062/sdk/verify?appid=$appid'));
    req.headers.contentType =
        ContentType('application', 'json', charset: 'utf-8');
    final res = await req.close();
    if (res.statusCode == 200) {
      final dataStr = await res.transform(utf8.decoder).join();
      final data = jsonDecode(dataStr);
      if (data is Map && data['status_code'] == '200') {
        final code = data['data']?['code'];
        if (code is String) {
          final fdll = File('clingwinsdklib.dll');
          if (!fdll.existsSync()) {
            final dll = await rootBundle
                .load('packages/clingwinsdk/assets/clingwinsdklib.dll');

            if (dll.lengthInBytes > 0) {
              fdll.writeAsBytesSync(dll.buffer.asUint8List());
            }
          }
          return _verify(appid, secret, code);
        }
      }
    }
  } catch (e) {
    slog('verify failed: $e');
  }
  return -1;
}