* @link https://github.com/gzydong/hyperf-chat */ namespace App\Amqp\Producer; use App\Constants\SocketConstants; use Hyperf\Amqp\Message\ProducerMessage; use Hyperf\Amqp\Message\Type; /** * 消息生产者 * * @package App\Amqp\Producer */ class ChatMessageProducer extends ProducerMessage { /** * 交换机类型 * * @var string */ public $type = Type::FANOUT; /** * 交换机名称 * * @var string */ public $exchange = SocketConstants::CONSUMER_MESSAGE_EXCHANGE; /** * 实例化处理 * * @param string $event 事件名 * @param array $data 数据 * @param array $options 其它参数 */ public function __construct(string $event, array $data, array $options = []) { $message = [ 'uuid' => uniqid((strval(mt_rand(0, 1000)))), 'event' => $event, 'data' => $data, 'options' => $options ]; $this->payload = $message; } }