getMethodCallContext method

Future<MethodCallContext> getMethodCallContext({
  1. required Session createSessionCallback(
    1. EndpointConnector connector
    ),
  2. required String endpointPath,
  3. required String methodName,
  4. required Map<String, dynamic> parameters,
  5. required SerializationManager serializationManager,
})
inherited

Tries to get a MethodCallContext for a given endpoint and method name. If the method is not found, a MethodNotFoundException is thrown. If the endpoint is not found, an EndpointNotFoundException is thrown. If the user is not authorized to access the endpoint, a NotAuthorizedException is thrown. If the input parameters are invalid, an InvalidParametersException is thrown. If the found method is not a MethodConnector, an InvalidEndpointMethodTypeException is thrown.

Implementation

Future<MethodCallContext> getMethodCallContext({
  required Session Function(EndpointConnector connector)
      createSessionCallback,
  required String endpointPath,
  required String methodName,
  required Map<String, dynamic> parameters,
  required SerializationManager serializationManager,
}) async {
  var (methodConnector, endpoint, parsedArguments) =
      await _getEndpointMethodConnector(
    createSessionCallback: createSessionCallback,
    endpointPath: endpointPath,
    methodName: methodName,
    arguments: parameters,
    serializationManager: serializationManager,
  );

  if (methodConnector is! MethodConnector) {
    throw InvalidEndpointMethodTypeException(methodName, endpointPath);
  }

  return MethodCallContext(
    method: methodConnector,
    arguments: parsedArguments,
    endpoint: endpoint,
  );
}