From 63ca310e261ab748ee0209042090ad809c2eb8bd Mon Sep 17 00:00:00 2001 From: 何书鹏 <heshupeng@bronet.cn> Date: Fri, 13 May 2022 20:56:43 +0800 Subject: [PATCH] phpsocket.io http请求 --- application/api/controller/Notify.php | 2 +- application/socketio/controller/Server.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/application/api/controller/Notify.php b/application/api/controller/Notify.php index 4bde8a3..e52f877 100644 --- a/application/api/controller/Notify.php +++ b/application/api/controller/Notify.php @@ -98,7 +98,7 @@ class Notify extends Api // 给后台发送新订单提醒 $client = new Client(); $http_port = config('socketio.http_port'); - $client->request('POST', request()->domain() . ":{$http_port}/", [ + $client->request('POST', 'http://'. $_SERVER['HTTP_HOST'] . ":{$http_port}/", [ 'form_params' => [ 'type' => 'publish', 'content' => '您有新的订单,请注意查收', diff --git a/application/socketio/controller/Server.php b/application/socketio/controller/Server.php index ed9e003..b0a088c 100644 --- a/application/socketio/controller/Server.php +++ b/application/socketio/controller/Server.php @@ -69,7 +69,14 @@ class Server // 当$sender_io启动后监听一个http端口,通过这个端口可以给任意uid或者所有uid推送数据 $sender_io->on('workerStart', function() use ($sender_io) { // 监听一个http端口 - $inner_http_worker = new Worker('https://0.0.0.0:2121'); + $context = array( + 'ssl' => array( + 'local_cert' => '/usr/local/nginx/cert/chengyigou.cn/chengyigou.cn.crt', + 'local_pk' => '/usr/local/nginx/cert/chengyigou.cn/chengyigou.cn.key', + 'verify_peer' => false, + ) + ); + $inner_http_worker = new Worker('http://0.0.0.0:2121',$context); // 当http客户端发来数据时触发 $inner_http_worker->onMessage = function(TcpConnection $http_connection, Request $request) use ($sender_io) { // global $uidConnectionMap; -- libgit2 0.24.0