KTVSingle/app/Console/Commands/TestMarqueeMessage.php

48 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Services\TcpSocketClient;
class TestMarqueeMessage extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'tcp:marquee
{ip : 目標設備 IP}
{port : 目標設備 Port}
{message : 要顯示的文字}';
/**
* The console command description.
*
* @var string
*/
protected $description = '發送跑馬燈訊息到指定的設備';
/**
* Execute the console command.
*/
public function handle()
{
$ip = $this->argument('ip');
$port = (int) $this->argument('port');
$message = $this->argument('message');
$client = new TcpSocketClient($ip, $port);
try {
$this->info("📤 發送中:{$message}");
$response = $client->send($message);
$this->info("✅ 回應:{$response}");
} catch (\Exception $e) {
$this->error("❌ 發送失敗:" . $e->getMessage());
}
}
}