openClient method
Piggyback Capture's openClient and use parameters and interfaces unique to http connections Implement JSON Rpc protocols.
Implementation
@override
/// Piggyback Capture's openClient and use parameters and interfaces unique to http connections
/// Implement JSON Rpc protocols.
Future<int> openClient(
String host, AppInfo appInfo, Function notification) async {
var jsonRpc = JRpcRequest(this._getJsonRpcId(), 'openclient', appInfo);
RegExp exp = RegExp(r'(http|ftp|https):');
this.host = host + '/Capture/v1/api';
this.hostWebsocket = host.replaceAll(exp, 'ws:');
this.onEventNotification = notification;
try {
JRpcResponse response = await this.sendRequest(jsonRpc);
dynamic r = json.decode(response.result);
if (r['result'] != null && r['result']['handle'] != null) {
return r['result']['handle'];
} else {
throw CaptureException(SktErrors.ESKT_NOERROR, "No error.");
}
} on CaptureException {
rethrow;
} catch (ex) {
throw CaptureException(SktErrors.ESKT_COMMUNICATIONERROR, 'There was an error during communication.', ex.toString());
}
}