waitForResponse method
Waits for a response matching the given action ID.
Implementation
@override
Future<AmiResponse> waitForResponse(
String actionId, {
Duration? timeout,
}) async {
final completer = Completer<AmiResponse>();
_pendingResponses[actionId] = completer;
try {
if (timeout != null) {
return await completer.future.timeout(
timeout,
onTimeout: () {
_pendingResponses.remove(actionId);
throw AmiException.timeout(actionId);
},
);
}
return await completer.future;
} catch (e) {
_pendingResponses.remove(actionId);
rethrow;
}
}