优化消息推送配置
Signed-off-by: vilson <545522390@qq.com>
This commit is contained in:
parent
62b4ab889d
commit
572081cf60
12
application/common/Plugins/GateWayWorker/config.php
Normal file
12
application/common/Plugins/GateWayWorker/config.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
define('SERVER_ADDRESS', '192.168.0.159');//服务注册地址
|
||||||
|
define('SERVER_PORT', '2346');//服务注册端口
|
||||||
|
define('CLIENT_PORT', '2345');//客户端监听端口
|
||||||
|
define('USE_SSL', false);//是否使用ssl
|
||||||
|
define('SSL_CONFIG', array(
|
||||||
|
// 请使用绝对路径
|
||||||
|
'local_cert' => '/www/wwwroot/pms/server.pem', // 也可以是crt文件
|
||||||
|
'local_pk' => '/www/wwwroot/pms/server.key',
|
||||||
|
'verify_peer' => false,
|
||||||
|
'allow_self_signed' => true, //如果是自签名证书需要开启此选项
|
||||||
|
));//ssl配置
|
@ -17,6 +17,7 @@ use GatewayWorker\Gateway;
|
|||||||
use GatewayWorker\BusinessWorker;
|
use GatewayWorker\BusinessWorker;
|
||||||
use Workerman\Autoloader;
|
use Workerman\Autoloader;
|
||||||
require_once __DIR__ . '/vendor/autoload.php';
|
require_once __DIR__ . '/vendor/autoload.php';
|
||||||
|
require_once __DIR__ . '/config.php';
|
||||||
|
|
||||||
// 自动加载类
|
// 自动加载类
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ $worker->name = 'YourAppBusinessWorker';
|
|||||||
// bussinessWorker进程数量
|
// bussinessWorker进程数量
|
||||||
$worker->count = 4;
|
$worker->count = 4;
|
||||||
// 服务注册地址
|
// 服务注册地址
|
||||||
$worker->registerAddress = '192.168.0.159:2346';
|
$worker->registerAddress = SERVER_ADDRESS . ':' . SERVER_PORT;
|
||||||
|
|
||||||
// 如果不是在根目录启动,则运行runAll方法
|
// 如果不是在根目录启动,则运行runAll方法
|
||||||
if(!defined('GLOBAL_START'))
|
if(!defined('GLOBAL_START'))
|
||||||
|
@ -16,27 +16,18 @@ use Workerman\Worker;
|
|||||||
use GatewayWorker\Gateway;
|
use GatewayWorker\Gateway;
|
||||||
|
|
||||||
require_once __DIR__ . '/vendor/autoload.php';
|
require_once __DIR__ . '/vendor/autoload.php';
|
||||||
|
require_once __DIR__ . '/config.php';
|
||||||
|
|
||||||
$ssl = false;
|
|
||||||
$context = array();
|
$context = array();
|
||||||
if ($ssl) {
|
if (USE_SSL) {
|
||||||
// 证书最好是申请的证书
|
// 证书最好是申请的证书
|
||||||
$context = array(
|
$context = SSL_CONFIG;
|
||||||
// 更多ssl选项请参考手册 http://php.net/manual/zh/context.ssl.php
|
|
||||||
'ssl' => array(
|
|
||||||
// 请使用绝对路径
|
|
||||||
'local_cert' => '/www/wwwroot/pms/server.pem', // 也可以是crt文件
|
|
||||||
'local_pk' => '/www/wwwroot/pms/server.key',
|
|
||||||
'verify_peer' => false,
|
|
||||||
'allow_self_signed' => true, //如果是自签名证书需要开启此选项
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// gateway 进程,这里使用Text协议,可以用telnet测试
|
// gateway 进程,这里使用Text协议,可以用telnet测试
|
||||||
$gateway = new Gateway("websocket://192.168.0.159:2345", $context);
|
$gateway = new Gateway('websocket://' . SERVER_ADDRESS . ':' . CLIENT_PORT, $context);
|
||||||
|
|
||||||
if ($ssl) {
|
if (USE_SSL) {
|
||||||
// 开启SSL,websocket+SSL 即wss
|
// 开启SSL,websocket+SSL 即wss
|
||||||
$gateway->transport = 'ssl';
|
$gateway->transport = 'ssl';
|
||||||
}
|
}
|
||||||
@ -51,7 +42,7 @@ $gateway->lanIp = '127.0.0.1';
|
|||||||
// 则一般会使用4000 4001 4002 4003 4个端口作为内部通讯端口
|
// 则一般会使用4000 4001 4002 4003 4个端口作为内部通讯端口
|
||||||
$gateway->startPort = 2900;
|
$gateway->startPort = 2900;
|
||||||
// 服务注册地址
|
// 服务注册地址
|
||||||
$gateway->registerAddress = '192.168.0.159:2346';
|
$gateway->registerAddress = SERVER_ADDRESS . ':' . SERVER_PORT;
|
||||||
|
|
||||||
// 心跳间隔
|
// 心跳间隔
|
||||||
$gateway->pingInterval = 60;
|
$gateway->pingInterval = 60;
|
||||||
|
@ -11,19 +11,21 @@
|
|||||||
* @link http://www.workerman.net/
|
* @link http://www.workerman.net/
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Workerman\Worker;
|
use Workerman\Worker;
|
||||||
use GatewayWorker\Register;
|
use GatewayWorker\Register;
|
||||||
|
|
||||||
require_once __DIR__ . '/vendor/autoload.php';
|
require_once __DIR__ . '/vendor/autoload.php';
|
||||||
|
require_once __DIR__ . '/config.php';
|
||||||
|
|
||||||
|
|
||||||
// 自动加载类
|
// 自动加载类
|
||||||
|
|
||||||
// register 必须是text协议
|
// register 必须是text协议
|
||||||
$register = new Register('http://192.168.0.159:2346');
|
$register = new Register('http://' . SERVER_ADDRESS . ':' . SERVER_PORT);
|
||||||
|
|
||||||
// 如果不是在根目录启动,则运行runAll方法
|
// 如果不是在根目录启动,则运行runAll方法
|
||||||
if(!defined('GLOBAL_START'))
|
if (!defined('GLOBAL_START')) {
|
||||||
{
|
|
||||||
Worker::runAll();
|
Worker::runAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace service;
|
namespace service;
|
||||||
|
|
||||||
require_once env('app_path') . 'common/Plugins/GateWayWorker/vendor/autoload.php';
|
require_once env('app_path') . 'common/Plugins/GateWayWorker/vendor/autoload.php';
|
||||||
|
require_once env('app_path') . 'common/Plugins/GateWayWorker/config.php';
|
||||||
|
|
||||||
use GatewayWorker\Lib\Gateway;
|
use GatewayWorker\Lib\Gateway;
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ class MessageService
|
|||||||
*这里假设GatewayClient和Register服务都在一台服务器上,ip填写127.0.0.1
|
*这里假设GatewayClient和Register服务都在一台服务器上,ip填写127.0.0.1
|
||||||
*注意:ip不能是0.0.0.0
|
*注意:ip不能是0.0.0.0
|
||||||
**/
|
**/
|
||||||
Gateway::$registerAddress = '192.168.0.159:2346';
|
Gateway::$registerAddress = SERVER_ADDRESS . ':' . SERVER_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isUidOnline($uid)
|
public function isUidOnline($uid)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user