Only sending a message if we have the API id

This commit is contained in:
Nelson R. Perez 2018-06-14 11:50:35 -05:00
parent 3159a44c3a
commit be33c91823

View file

@ -151,16 +151,15 @@ public class NetworkService extends Service {
} }
public long sendMessage(ApiCallable apiCallable, int requiredApi){ public long sendMessage(ApiCallable apiCallable, int requiredApi){
int apiId = 0;
if(requiredApi != -1 && mApiIds.containsKey(requiredApi)){ if(requiredApi != -1 && mApiIds.containsKey(requiredApi)){
apiId = mApiIds.get(requiredApi); int apiId = mApiIds.get(requiredApi);
}
ApiCall call = apiCallable.toApiCall(apiId, ++mCurrentId); ApiCall call = apiCallable.toApiCall(apiId, ++mCurrentId);
mRequestClassMap.put(mCurrentId, apiCallable.getClass()); mRequestClassMap.put(mCurrentId, apiCallable.getClass());
if(mWebSocket != null && mWebSocket.send(call.toJsonString())){ if(mWebSocket != null && mWebSocket.send(call.toJsonString())){
Log.v(TAG,"-> "+call.toJsonString()); Log.v(TAG,"-> "+call.toJsonString());
return mCurrentId; return mCurrentId;
} }
}
return -1; return -1;
} }