*/
public class ActiveSubscriptions {
+ private final Supplier<UnsubscribeUskCommand> unsubscribeUskCommandSupplier;
private final Map<String, RemoteUskSubscription> subscriptions = Collections.synchronizedMap(new HashMap<>());
+ public ActiveSubscriptions(Supplier<UnsubscribeUskCommand> unsubscribeUskCommandSupplier) {
+ this.unsubscribeUskCommandSupplier = unsubscribeUskCommandSupplier;
+ }
+
public void renew(Consumer<FcpListener> fcpEventSender, Supplier<SubscribeUskCommand> subscribeUskCommandSupplier)
throws ExecutionException, InterruptedException {
fcpEventSender.accept(createFcpListener());
return remoteUskSubscription;
}
- private static class RemoteUskSubscription implements UskSubscription {
+ private class RemoteUskSubscription implements UskSubscription {
private final String identifier;
private final String uri;
}
}
+ public void cancel() throws ExecutionException, InterruptedException {
+ unsubscribeUskCommandSupplier.get().identifier(identifier).execute().get();
+ subscriptions.remove(identifier);
+ }
+
}
}