作者 何书鹏

phpsocket.io http请求

@@ -98,7 +98,7 @@ class Notify extends Api @@ -98,7 +98,7 @@ class Notify extends Api
98 // 给后台发送新订单提醒 98 // 给后台发送新订单提醒
99 $client = new Client(); 99 $client = new Client();
100 $http_port = config('socketio.http_port'); 100 $http_port = config('socketio.http_port');
101 - $client->request('POST', request()->domain() . ":{$http_port}/", [ 101 + $client->request('POST', 'http://'. $_SERVER['HTTP_HOST'] . ":{$http_port}/", [
102 'form_params' => [ 102 'form_params' => [
103 'type' => 'publish', 103 'type' => 'publish',
104 'content' => '您有新的订单,请注意查收', 104 'content' => '您有新的订单,请注意查收',
@@ -69,7 +69,14 @@ class Server @@ -69,7 +69,14 @@ class Server
69 // 当$sender_io启动后监听一个http端口,通过这个端口可以给任意uid或者所有uid推送数据 69 // 当$sender_io启动后监听一个http端口,通过这个端口可以给任意uid或者所有uid推送数据
70 $sender_io->on('workerStart', function() use ($sender_io) { 70 $sender_io->on('workerStart', function() use ($sender_io) {
71 // 监听一个http端口 71 // 监听一个http端口
72 - $inner_http_worker = new Worker('https://0.0.0.0:2121'); 72 + $context = array(
  73 + 'ssl' => array(
  74 + 'local_cert' => '/usr/local/nginx/cert/chengyigou.cn/chengyigou.cn.crt',
  75 + 'local_pk' => '/usr/local/nginx/cert/chengyigou.cn/chengyigou.cn.key',
  76 + 'verify_peer' => false,
  77 + )
  78 + );
  79 + $inner_http_worker = new Worker('http://0.0.0.0:2121',$context);
73 // 当http客户端发来数据时触发 80 // 当http客户端发来数据时触发
74 $inner_http_worker->onMessage = function(TcpConnection $http_connection, Request $request) use ($sender_io) { 81 $inner_http_worker->onMessage = function(TcpConnection $http_connection, Request $request) use ($sender_io) {
75 // global $uidConnectionMap; 82 // global $uidConnectionMap;