50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Jobs;
|
||
|
|
|
||
|
|
use Illuminate\Bus\Queueable;
|
||
|
|
use Illuminate\Queue\SerializesModels;
|
||
|
|
use Illuminate\Queue\InteractsWithQueue;
|
||
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||
|
|
use App\Models\InteractLive;
|
||
|
|
use App\Services\IMService;
|
||
|
|
use App\Http\Response\ResponseJson;
|
||
|
|
class SendIMBroadcastMsg implements ShouldQueue
|
||
|
|
{
|
||
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||
|
|
use ResponseJson;
|
||
|
|
public $tries = 1;
|
||
|
|
/**
|
||
|
|
* Create a new job instance.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function __construct()
|
||
|
|
{
|
||
|
|
//
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Execute the job.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function handle()
|
||
|
|
{
|
||
|
|
try {
|
||
|
|
//获取当前直播数
|
||
|
|
$count = InteractLive::inLive()->count();
|
||
|
|
$im = new IMService();
|
||
|
|
$body = ['num'=>$count, 'type'=>'in_live'];
|
||
|
|
// $result = $im->broadcastMsg($body);
|
||
|
|
// if ($result['code'] != 200) throw new \Exception("发送网易广播消息失败", 1);
|
||
|
|
// return $result;
|
||
|
|
} catch (\Exception $e) {
|
||
|
|
$this->getError($e);
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|