<?php

namespace app\queue\redis;

use support\Log;
use Webman\Push\PushException;
use Webman\RedisQueue\Consumer;

class SendBroadcasts implements Consumer
{
    // 要消费的队列名
    public $queue = 'broadcast_tasks';

    // 连接名，对应 plugin/webman/redis-queue/redis.php 里的连接`
    public $connection = 'default';

    // 消费
    public function consume($data)
    {
        // 无需反序列化
        try {
            sendSocketMessage('broadcast', $data);
        } catch (PushException $e) {
            Log::error($e->getMessage());
        }
    }
}
