# 运行第二个 Flash Send 实例用于测试
# 使用不同的端口和实例名称

$env:FLASH_SEND_PORT_OFFSET = "100"
$env:FLASH_SEND_INSTANCE = "Test2"

Write-Host "启动 Flash Send 实例 2..." -ForegroundColor Green
Write-Host "UDP:53317 (共用) | WS:53418 | HTTP:53419" -ForegroundColor Cyan

$exePath = "$PSScriptRoot\..\src-tauri\target\release\flash-send-instance2.exe"

# 如果副本不存在则复制
if (-not (Test-Path $exePath)) {
    $srcPath = "$PSScriptRoot\..\src-tauri\target\release\flash-send.exe"
    if (Test-Path $srcPath) {
        Copy-Item $srcPath $exePath
        Write-Host "已复制可执行文件" -ForegroundColor Yellow
    } else {
        Write-Host "错误: 请先编译主程序 (cargo build --release)" -ForegroundColor Red
        exit 1
    }
}

& $exePath
