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 {
  final Map<String, dynamic> newParams =
      Params(handle: clientOrDeviceHandle, property: property).toJson();
  final JRpcRequest getRequest = JRpcRequest(
      id: _getJsonRpcId(), method: 'getproperty', params: newParams);

  try {
    final JRpcResponse response = await sendRequest(getRequest);
    final CaptureResult? result = response.captureResult;
    if (clientOrDeviceHandle != result?.handle) {
      throw CaptureException(
          SktErrors.ESKT_INVALIDHANDLE,
          'The provided handle is invalid',
          'The response handle does not match with the handle of the request');
    }
    return result?.property ??
        (throw Exception('Missing property in response'));
  } on CaptureException {
    rethrow;
  } catch (e) {
    throw CaptureException(-32602, 'Something went wrong.', e.toString());
  }
}