(Map<String, Object> params, Event<X> event, Consumer<X> handler)
| 126 | // later: it is unique regardless of whether the subscription was scoped to events, contexts, or |
| 127 | // user contexts, so there is no need to separately track how a listener was subscribed. |
| 128 | private <X> String subscribe(Map<String, Object> params, Event<X> event, Consumer<X> handler) { |
| 129 | return whileHoldingSubscriptionLock(() -> { |
| 130 | Map<String, Object> result = send(new Command<>("session.subscribe", params, Map.class)); |
| 131 | Object subscriptionId = result.get("subscription"); |
| 132 | if (!(subscriptionId instanceof String) || ((String) subscriptionId).isEmpty()) { |
| 133 | throw new BiDiException( |
| 134 | "session.subscribe did not return a valid subscription id: " + result); |
| 135 | } |
| 136 | connection.addListener((String) subscriptionId, event, handler); |
| 137 | return (String) subscriptionId; |
| 138 | }); |
| 139 | } |
| 140 | |
| 141 | public <X> void clearListener(Set<String> browsingContextIds, Event<X> event) { |
| 142 | Require.nonEmpty("List of browsing context ids", browsingContextIds); |
no test coverage detected