openDevice method

  1. @override
Future<int> openDevice(
  1. int clientHandle,
  2. String guid
)
override

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

Implementation

@override

/// Piggyback Capture's openDevice and use parameters and interfaces unique to http connections
/// Implement JSON Rpc protocols.
Future<int> openDevice(int clientHandle, String guid) async {
  final JRpcRequest openRequest = JRpcRequest(
      id: _getJsonRpcId(),
      method: 'opendevice',
      params: Params(handle: clientHandle, guid: guid));

  try {
    final JRpcResponse response = await sendRequest(openRequest);
    return response.captureResult?.handle ??
        (throw Exception('Invalid JSON RPC response'));
  } on CaptureException {
    rethrow;
  } catch (ex) {
    throw CaptureException(-32602, 'Something went wrong.', ex.toString());
  }
}