createStream method

void createStream({
  1. required MethodStreamCallContext methodStreamCallContext,
  2. required UuidValue methodStreamId,
  3. required Session session,
})

Implementation

void createStream({
  required MethodStreamCallContext methodStreamCallContext,
  required UuidValue methodStreamId,
  required Session session,
}) async {
  var outputStreamContext = await _createOutputController(
    methodStreamCallContext,
    session,
    methodStreamId,
  );

  var inputStreams = _createInputStreams(
    methodStreamCallContext,
    methodStreamId,
    session,
  );
  var streamParams = inputStreams.map(
    (key, value) => MapEntry(key, value.stream),
  );

  switch (methodStreamCallContext.method.returnType) {
    case MethodStreamReturnType.streamType:
      _handleMethodWithStreamReturn(
        methodStreamCallContext: methodStreamCallContext,
        session: session,
        streamParams: streamParams,
        outputController: outputStreamContext.controller,
        subscription: outputStreamContext.subscription,
        methodStreamId: methodStreamId,
      );
      break;
    case MethodStreamReturnType.futureType:
    case MethodStreamReturnType.voidType:
      await _handleMethodWithFutureReturn(
        methodStreamCallContext: methodStreamCallContext,
        session: session,
        streamParams: streamParams,
        outputController: outputStreamContext.controller,
        methodStreamId: methodStreamId,
      );
      break;
  }
}