* @param senderUrl
* the sender url
* @return the JSON response
*/
public JSONResponse invoke(final Object msg, final URI senderUrl) {
final JSONMessage jsonMsg = jsonConvert(msg);
if (jsonMsg == null) {
LOG.log(Level.WARNING, "Received non-JSONRPC message:'" + msg + "'");
return null;
}
final JsonNode id = jsonMsg.getId();
try {
if (jsonMsg.isRequest()) {
final JSONRequest request = (JSONRequest) jsonMsg;
final RequestParams params = new RequestParams();
params.put(Sender.class, senderUrl.toASCIIString());
return JSONRPC.invoke(destination.get(), request, params, auth);
} else if (jsonMsg.isResponse() && callbacks != null && id != null
&& !id.isNull()) {
final AsyncCallback<JSONResponse> callback = callbacks.pull(id);
if (callback != null) {
final JSONResponse response = (JSONResponse) jsonMsg;
final JSONRPCException error = response.getError();