no message

SPY×FAMILY
鹿和sa0ChunLuyu 3 years ago
parent f22eea62a7
commit 26ef95c93a

@ -19,6 +19,7 @@
*/ */
//declare(ticks=1); //declare(ticks=1);
require_once __DIR__ . '/../../config.php';
use \GatewayWorker\Lib\Gateway; use \GatewayWorker\Lib\Gateway;
@ -59,6 +60,31 @@ class Events
*/ */
public static function onClose($client_id) public static function onClose($client_id)
{ {
global $config;
if (!!$config['close']) self::post($config['close'], ['client' => $client_id]);
}
public static function post($url, $data, $type = 'json')
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
if ($type === 'data') {
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
}
if ($type === 'json') {
$data_string = json_encode($data, JSON_UNESCAPED_UNICODE);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($data_string)
]);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
}
$r = curl_exec($curl);
curl_close($curl);
return $r;
} }
} }

@ -1,7 +1,13 @@
<?php <?php
$config = [ $config = [
'name' => '鹿和开发套件', // 服务名称 // 服务名称
'port' => 3282, // 服务端口 'name' => '鹿和开发套件',
'register' => 3238, // 服务注册端口 // 服务端口
'start' => 3900, // 内部通讯起始端口 'port' => 3282,
// 服务注册端口
'register' => 3238,
// 内部通讯起始端口
'start' => 3900,
// 退出接口
'close' => '',
]; ];
Loading…
Cancel
Save