<?php

declare(strict_types=1);

namespace App\Command;

use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Command\Annotation\Command;
use Psr\Container\ContainerInterface;

use App\Amqp\Producer\MqProducer;
use App\JsonRpc\ChatServiceInterface;
use App\JsonRpc\UserServiceInterface;
use App\Service\Message\ReceiveHandleService;
use App\Service\RedisService;
use Hyperf\Amqp\Producer;
use Hyperf\Context\ApplicationContext as ContextApplicationContext;
use Hyperf\Contract\OnCloseInterface;
use Hyperf\Contract\OnMessageInterface;
use Hyperf\Contract\OnOpenInterface;
use Hyperf\Di\Annotation\Inject;
use Hyperf\Engine\WebSocket\Response;
use Phper666\JWTAuth\JWT;


#[Command]
class Test extends HyperfCommand
{
    public function __construct(protected ContainerInterface $container)
    {
        parent::__construct('demo:command');
    }

    public function configure()
    {
        parent::configure();
        $this->setDescription('Hyperf Demo Command');
    }

    public function handle()
    {
        //记录执行时间
        $start = microtime(true);
        for ($i = 0; $i < 200000; $i++) {
            $chatdata['receiver_id'] = 1;
            $chatdata['user_id'] = $i;
            $chatdata['group_receiver_id'] = 0;
            $chatdata['is_read'] = 1;
            $chatdata['action'] = 'said';
            $message = new MqProducer($chatdata);
            $producer = ContextApplicationContext::getContainer()->get(Producer::class);
            $re = $producer->produce($message);
        }
        $this->info(microtime(true) - $start);
        $this->line('Hello Hyperf!', 'info');
    }
}