handleCommand method

  1. @override
Future<List<Event>> handleCommand(
  1. ChannelState currentState,
  2. Command command
)

Handle a command and generate events This is the core method for command processing

Implementation

@override
Future<List<Event>> handleCommand(ChannelState currentState, Command command) async {
  if (command is RequestChannelCommand) {
    return await _handleRequestChannel(currentState, command);
  } else if (command is AcceptChannelCommand) {
    return await _handleAcceptChannel(currentState, command);
  } else if (command is RejectChannelCommand) {
    return _handleRejectChannel(currentState, command);
  } else if (command is RecordServerAcceptanceCommand) {
    return _handleRecordServerAcceptance(currentState, command);
  } else if (command is RequestRefundSignatureCommand) {
    return await _handleRequestRefundSignature(currentState, command);
  } else if (command is ProvideRefundSignatureCommand) {
    return _handleProvideRefundSignature(currentState, command);
  } else if (command is OpenChannelCommand) {
    return _handleOpenChannel(currentState, command);
  } else if (command is RecordPaymentCommand) {
    return await _handleRecordPayment(currentState, command);
  } else if (command is AcknowledgePaymentCommand) {
    return await _handleAcknowledgePayment(currentState, command);
  } else if (command is CloseChannelCommand) {
    return _handleCloseChannel(currentState, command);
  } else if (command is FinalizeCloseCommand) {
    return _handleFinalizeClose(currentState, command);
  } else if (command is ClaimRefundCommand) {
    return _handleClaimRefund(currentState, command);
  }
  throw ArgumentError('Unknown command type: ${command.runtimeType}');
}