enterConversation method

Future<void> enterConversation(
  1. String conversationName,
  2. CTX ctx
)

Starts a conversation by name.

Implementation

Future<void> enterConversation(
  String conversationName,
  CTX ctx,
) async {
  final conversationWrapper = _conversations[conversationName];
  if (conversationWrapper == null) {
    throw TeleverseException(
      'Conversation "$conversationName" not found',
      description:
          'Make sure to register the conversation using createConversation',
      type: TeleverseExceptionType.invalidParameter,
    );
  }

  final key = getStorageKey(ctx);

  // Clean up any existing conversation for this key
  await _cleanupConversation(key, conversationName);

  // Create conversation handle
  final conversation = Conversation._(
    storage,
    key,
    conversationName,
    this,
    defaultTimeout,
  );

  // Start the conversation
  unawaited(conversationWrapper.function(conversation, ctx));
}