<?php
/**
 * Broadcast Channel Authorization Routes
 *
 * @version     1.0.$Revision:$
 * @version     SVN: $Id:$
 * @package     bplan-base/globals
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 * @copyright   Copyright (C) 2025, 2026 bplan-solutions GmbH & Co. KG <https://www.bplan-solutions.de/>
 * /Δ\
 */


use Illuminate\Support\Facades\Broadcast;


/*
**  Standard Laravel-User-Channel */
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
    return (int) $user->id === (int) $id;
});


/*
**  Gezielter Push an ein bestimmtes Terminal (Kiosk-Location).
**  Channel-Name: private-terminal.{uuid}
**
**  Auth-TODO: Token valid AND {uuid} ist eine aktive Kiosk-TerminalConnection */
Broadcast::channel('terminal.{uuid}', function ($user, string $uuid) {
    return true;
});


/*
**  Broadcast an alle Idle-Terminals.
**  Channel-Name: presence-terminals.idle
**  Presence: gibt Identifier zurück (für Backend-Übersicht wer online ist)
**
**  Auth-TODO: Token valid → accepted; Identifier = Location-UUID */
Broadcast::channel('terminals.idle', function ($user) {
    return [
        'id'   => $user->id,
        'name' => $user->name
    ];
});


/*
**  Druckstatus für einen konkreten Druckauftrag.
**  Channel-Name: private-print-job.{uuid}
**
**  Auth-TODO: Token valid → accepted (tenant-basiert) */
Broadcast::channel('print-job.{uuid}', function ($user, string $uuid) {
    return true;
});
