添加服务

This commit is contained in:
老李 2021-03-16 22:51:59 +08:00
parent e62c79ab0a
commit 3d01239cf7
2 changed files with 33 additions and 7 deletions

View File

@ -6,7 +6,7 @@ use App\Models\Cdr;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
use function \Swoole\Coroutine\run;
use App\Service\EslListen;
class SwooleDial extends Command
{
@ -44,14 +44,9 @@ class SwooleDial extends Command
\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){
(new EslListen($uuid))->run();
});
}
});

31
app/Service/EslListen.php Normal file
View File

@ -0,0 +1,31 @@
<?php
namespace App\Service;
use App\Models\Cdr;
use Illuminate\Support\Facades\Log;
class EslListen
{
//通话记录对象
public $cdr;
//esl连接对象
public $fs;
public function __construct($uuid)
{
$cdr = Cdr::query()->where('uuid','=',$uuid)->first();
if ($cdr == null) {
Log::info(sprintf("通话记录[%s]不存在",$uuid));
return false;
}
}
public function run()
{
}
}