handleResponse method

void handleResponse(
  1. DataPackage remoteFunctionResponse
)

Implementation

void handleResponse(DataPackage remoteFunctionResponse)
{
    if(!remoteFunctionResponse.controlVal.hasRemoteFunctionReturn())
    {
        Logger.logError("Failed to handle remote function response " +
            remoteFunctionResponse.toString() + ". Did not find RemoteFunctionReturn data");
        return;
    }

    RemoteFunctionReturn remoteFunctionReturn = remoteFunctionResponse.controlVal.remoteFunctionReturn;
    String futureIdentifier = remoteFunctionReturn.remoteFutureIdentifier;
    FutureUniqueIdentifier uniqueIdentifier = FutureUniqueIdentifier(futureIdentifier);

    AbstractRPCCompleter? future = this._futuresHandler.lookupFuture(uniqueIdentifier);

    if(future == null)
    {
        // Not an error. Can happen if the user does not sture the future, as he does not care about a result.
        //Logger.logError("Failed to forward result of remote function. Cannot find future with identifier \"" + futureIdentifier + "\".");
        return;
    }

    if(remoteFunctionReturn.executionStatus != RemoteFunctionStatus.STATUS_OK)
    {
        Logger.logError("Remote function failed. Future with identifier \"" +
            futureIdentifier + "\" failed with status \"" + remoteFunctionReturn.executionStatus.toString() + "\".");
        future.setFailed();
        return;
    }
    future.setResponse(remoteFunctionResponse);
}