From 918d27b5cdb44611af4b0a93740e0d275e4b9a47 Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Fri, 15 Jun 2018 18:26:59 -0500 Subject: [PATCH] Fixed problem caused by the lack of registered API id for calls that don't require any API --- .../graphenej/api/android/NetworkService.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java b/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java index e570af7..4ab7c83 100644 --- a/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java +++ b/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java @@ -150,9 +150,20 @@ public class NetworkService extends Service { return -1; } + /** + * Method that will send a message to the full node, and takes as an argument one of the + * API call wrapper classes. This is the preferred method of sending blockchain API calls. + * + * @param apiCallable The object that will get serialized into a request + * @param requiredApi The required APIs for this specific request. Should be one of the + * constants specified in the ApiAccess class. + * @return The id of the message that was just sent, or -1 if no message was sent. + */ public long sendMessage(ApiCallable apiCallable, int requiredApi){ - if(requiredApi != -1 && mApiIds.containsKey(requiredApi)){ - int apiId = mApiIds.get(requiredApi); + if(requiredApi != -1 && mApiIds.containsKey(requiredApi) || requiredApi == ApiAccess.API_NONE){ + int apiId = 0; + if(requiredApi != ApiAccess.API_NONE) + apiId = mApiIds.get(requiredApi); ApiCall call = apiCallable.toApiCall(apiId, ++mCurrentId); mRequestClassMap.put(mCurrentId, apiCallable.getClass()); if(mWebSocket != null && mWebSocket.send(call.toJsonString())){