getProperty method

  1. @override
Future<CaptureProperty> getProperty(
  1. int? clientOrDeviceHandle,
  2. CaptureProperty property
)
override

Piggyback Capture's getProperty and use parameters and interfaces unique to http connections Implement JSON Rpc protocols.

Implementation

@override
/// Piggyback Capture's getProperty and use parameters and interfaces unique to http connections
/// Implement JSON Rpc protocols.
Future<CaptureProperty> getProperty(
    int? clientOrDeviceHandle, CaptureProperty property) async {
  var newParams =
      Params(clientOrDeviceHandle, property: property.toJson()).toJson();
  var getRequest =
      JRpcRequest(this._getJsonRpcId(), 'getproperty', newParams);

  try {
    dynamic response = await this.sendRequest(getRequest);
    Map<String, dynamic> res =
        json.decode(response.toJson()['result'])['result'];
    if (clientOrDeviceHandle != res['handle']) {
      throw CaptureException(
          SktErrors.ESKT_INVALIDHANDLE,
          'The provided handle is invalid',
          'The response handle does not match with the handle of the request');
    }
    return CaptureProperty(res['property']['id'], res['property']['type'],
        res['property']['value']);
  } on CaptureException {
    rethrow;
  } catch (e) {
    throw CaptureException(-32602, 'Something went wrong.', e.toString());
  }
}