Fixed problem caused by the lack of registered API id for calls that don't require any API

This commit is contained in:
Nelson R. Perez 2018-06-15 18:26:59 -05:00
parent 7197ea4078
commit 918d27b5cd

View file

@ -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())){