['img'=>'音控-01.jpg','label' =>'暫停'], 'volume_up' =>['img'=>'音控-02.jpg','label' =>'音量 ↑'], 'volume_down' =>['img'=>'音控-04.jpg','label' =>'音量 ↓'], 'mic_up' =>['img'=>'音控-06.jpg','label' =>'麥克風 ↑'], 'mic_down' =>['img'=>'音控-03.jpg','label' =>'麥克風 ↓'], 'mute' =>['img'=>'音控-05.jpg','label' =>'靜音'], 'original_song' =>['img'=>'音控-07.jpg','label' =>'原唱'], 'service' =>['img'=>'音控-08.jpg','label' =>'服務鈴'], 'replay' =>['img'=>'音控-09.jpg','label' =>'重播'], 'male_key' =>['img'=>'音控-11.jpg','label' =>'男調'], 'female_key' =>['img'=>'音控-12.jpg','label' =>'女調'], 'cut' =>['img'=>'音控-10.jpg','label' =>'切歌'], 'lower_key' =>['img'=>'音控-15.jpg','label' =>'降調'], 'standard_key' =>['img'=>'音控-14.jpg','label' =>'原調'], 'raise_key' =>['img'=>'音控-13.jpg','label' =>'升調'], ]; public function mount() { $this->roomSession = request()->roomSession; } public function sendControl(string $action) { $dbSession = $this->roomSession->refreshValid(); if (!$dbSession) { session()->forget('room_code'); $this->notification()->send([ 'icon' => 'error', 'title' => '驗證失敗', 'description' => 'Token 已失效,請重新登入', ]); return $this->redirect(route('welcome'), navigate: true); }else{ $room=$this->roomSession->room; } $client = new TcpSocketClient($room->internal_ip, $room->port); try { $response = $client->send($room->name . "," . $action); } catch (\Throwable $e) { logger()->error('❌ TCP 傳送失敗: ' . $e->getMessage(), [ 'room_id' => $room->id, 'ip' => $room->internal_ip, 'port' => $room->port, ]); } $title = $this->buttons[$action]['label'] ?? $action; $this->notification()->send( (isset($response) && trim($response) === "OK") ?[ 'icon' => 'success', 'title' => $title, 'description' => '已執行操作', ]:[ 'icon' => 'error', 'title' => $title, 'description' => $data['message'] ?? '操作失敗', ] ); } public function render() { return view('livewire.pages.sound-control'); } }