@Override public void onFailure(Throwable t) { if (t instanceof CancellationException) { log.debug("Canceling {} call", message.getMethod()); } else { log.error("Could not get reply for blockchain.address.get_history", t); } } }, Threading.USER_THREAD);
@Override public void onFailure(Throwable t) { if (t instanceof CancellationException) { log.debug("Canceling {} call", message.getMethod()); } else { log.error("Could not get reply for blockchain.block.get_header", t); } } }, Threading.USER_THREAD);
@Override public void onFailure(Throwable t) { if (t instanceof CancellationException) { log.debug("Canceling {} call", message.getMethod()); } else { log.error("Could not get reply for blockchain.transaction.get", t); } } }, Threading.USER_THREAD);
public ListenableFuture<ResultMessage> subscribe(CallMessage message, SubscribeResultHandler handler) { // Add the subscription handler the the subscribersHandlers map so that any future // subscription call will be handled by it. // If this particular method was not used before, initialize a list of handlers if (!subscribersHandlers.containsKey(message.getMethod())) { subscribersHandlers.put(message.getMethod(), Collections.synchronizedList(new ArrayList<SubscribeResultHandler>())); } // Add handler if needed if (!subscribersHandlers.get(message.getMethod()).contains(handler)) { subscribersHandlers.get(message.getMethod()).add(handler); } // Make the subscription call, the server will reply immediately return call(message); } }
@Override public void onFailure(Throwable t) { if (t instanceof CancellationException) { log.debug("Canceling {} call", callMessage.getMethod()); } else { log.error("Could not get reply for {} blockchain headers subscribe: {}", type.getName(), t.getMessage()); } } }, Threading.USER_THREAD);
@Override public void onFailure(Throwable t) { if (t instanceof CancellationException) { log.info("Canceling {} call", callMessage.getMethod()); } else { log.error("Could not get reply for {} address subscribe {}: ", type.getName(), address, t.getMessage()); } } }, Threading.USER_THREAD);
@Override public void onFailure(Throwable t) { if (t instanceof CancellationException) { log.debug("Canceling {} call", pingMsg.getMethod()); } else { log.error("Server {} ping failed", type.getName()); } } }, Threading.USER_THREAD);
@Test public void testCallMessageParse() throws JSONException { String message = "{\"id\": 0, \"method\": \"blockchain.headers.subscribe\", \"params\": []}"; CallMessage call = CallMessage.fromJson(message); Assert.assertEquals(call.getMethod(), "blockchain.headers.subscribe"); }
@Test public void testCallMessageSubscribe() { CallMessage call = new CallMessage("blockchain.headers.subscribe", new ArrayList()); Assert.assertEquals(call.getMethod(), "blockchain.headers.subscribe"); Assert.assertEquals("{\"id\":null,\"method\":\"blockchain.headers.subscribe\",\"params\":[]}\n", call.toString()); }
@Test public void testCallMessage() { CallMessage call = new CallMessage(1L, "blockchain.address.listunspent", Arrays.asList("npF3ApeWwMS8kwXJyybPZ76vNbv5txVjDf")); Assert.assertEquals(call.getId(), 1L); Assert.assertEquals(call.getMethod(), "blockchain.address.listunspent"); Assert.assertEquals("{\"id\":1,\"method\":\"blockchain.address.listunspent\"," + "\"params\":[\"npF3ApeWwMS8kwXJyybPZ76vNbv5txVjDf\"]}\n", call.toString()); }
@Test public void testCallMessage2() { CallMessage call = new CallMessage(1L, "blockchain.address.listunspent", "npF3ApeWwMS8kwXJyybPZ76vNbv5txVjDf"); Assert.assertEquals(call.getMethod(), "blockchain.address.listunspent"); Assert.assertEquals("{\"id\":1,\"method\":\"blockchain.address.listunspent\"," + "\"params\":[\"npF3ApeWwMS8kwXJyybPZ76vNbv5txVjDf\"]}\n", call.toString()); }