60 lines
1.3 KiB
PHP
60 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Cdr;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Redis;
|
|
use function \Swoole\Coroutine\run;
|
|
|
|
class SwooleDial extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'swoole:dial';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = '呼叫队列';
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle()
|
|
{
|
|
\Swoole\Coroutine\run(function (){
|
|
$key = config('freeswitch.redis_key.dial');
|
|
while ($uuid = Redis::blpop($key)) {
|
|
$cdr = Cdr::query()->where('uuid','=',$uuid)->first();
|
|
if ($cdr == null){
|
|
Log::info(sprintf("通话记录[%s]不存在",$uuid));
|
|
continue;
|
|
}
|
|
//开户协程发起通话并监听
|
|
\Swoole\Coroutine::create(function () use ($uuid){
|
|
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|