package com.red.circle.other.app.manager;

import com.red.circle.other.app.command.rocket.RocketLaunchCmdExe;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 火箭发射管理器
 * 职责：异步处理火箭发射
 *
 * @author system
 * @date 2025-01-15
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class RocketLaunchManager {

    private final RocketLaunchCmdExe rocketLaunchCmdExe;

    /**
     * 异步发射火箭
     * @param roomId 房间ID
     * @param triggerUserId 触发用户ID
     */
    @Async("rocketLaunchExecutor")
    public void launchAsync(Long roomId, Long triggerUserId) {
        try {
            log.info("异步执行火箭发射: roomId={}, 触发用户={}", roomId, triggerUserId);
            rocketLaunchCmdExe.execute(roomId, triggerUserId);
        } catch (Exception e) {
            log.error("异步火箭发射失败: roomId={}", roomId, e);
        }
    }
}
