| 1234567891011121314151617181920212223242526272829303132333435 | <?phpnamespace app\common\util;use Channel\Client;use Exception;use think\facade\Log;class Channel{    public function __construct(){    }    /**     * 通知websocket进程     * @param string $events 事件     * @param string $type 类型     * @param int $connection_ids 连接id     * @param array $data 传输的数据报文     */    public  function sendChannel(string $events, string $type, int $connection_ids=0, array $data = []){        try {            Client::connect(config('channel.ip'),config('channel.port'));        }catch (Exception $e) {            // 异常捕获            Log::write( $e->getMessage(),'notice');        }        Client::publish($events,[            'type'=>$type,            'data'=>$data,            'connection_ids'=>$connection_ids,        ]);    }}
 |