executeWithParameters method

Future<T?> executeWithParameters(
  1. List parameters
)

Implementation

Future<T?> executeWithParameters(List<dynamic> parameters) async
{
    if(parameters.length != _parameterTypes.length)
    {
        Logger.logError("Failed to execute RemoteFunction (RPC stub) \"" + getFunctionSignature() + "\". Number of parameters do not match. " +
        "Function expected " + _parameterTypes.length.toString() + " parameters, but was executed with " + parameters.length.toString());
        return null;
    }

    for(int i = 0; i < parameters.length; i++)
    {
        if(parameters[i].runtimeType != this._parameterTypes[i].runtimeType)
        {
            Logger.logError("Failed to execute remote function \"" + getFunctionSignature() + "\". Parameter object " + i.toString() +
             " is of type \"" + parameters[i].runtimeType.toString() + "\", but expected type \"" + _parameterTypes[i].runtimeType.toString() + "\".");
            return null;
        }
    }

    RPCCompleter<T> future = this._futuresHandler.registerNewFuture(this._returnType);

    DataPackage dataPackage = DataPackage();
    ControlPackage controlPackage = ControlPackage();
    controlPackage.ctrlType = CtrlType.CTRL_REMOTE_FUNCTION_REQUEST;
    controlPackage.runtime = Runtime.RUNTIME_DART;

    RemoteFunctionRequest remoteFunctionRequest =
        makeRemoteFunctionRequest(future.getUniqueIdentifier().toString(), parameters);

    controlPackage.remoteFunctionRequest = remoteFunctionRequest;

    dataPackage.controlVal = controlPackage;

    if(this._remoteFunctionIdentifier.hasModuleId())
    {
        dataPackage.targetModule = this._remoteFunctionIdentifier.moduleId;
    }


    _outputController.add(dataPackage);

    return future.getResponse();

}