fixed
This commit is contained in:
85
front/config/worker_server.php
Normal file
85
front/config/worker_server.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2018 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
use think\facade\Env;
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Workerman设置 仅对 php think worker:server 指令有效
|
||||
// +----------------------------------------------------------------------
|
||||
return [
|
||||
/**
|
||||
* 2024-1-21日测试通过,可以发信息
|
||||
* php think worker:server
|
||||
* 【php think worker:server start命令对应的是此文件】
|
||||
*/
|
||||
// 扩展自身需要的配置
|
||||
'protocol' => 'websocket', // 协议 支持 tcp udp unix http websocket text
|
||||
'host' => '0.0.0.0', // 监听地址
|
||||
'port' => 2001, // 监听端口
|
||||
'socket' => '', // 完整监听地址
|
||||
'context' => [], // socket 上下文选项
|
||||
'worker_class' => '', // 自定义Workerman服务类名 支持数组定义多个服务
|
||||
|
||||
// 支持workerman的所有配置参数
|
||||
'name' => 'thinkphp',
|
||||
'count' => 4,
|
||||
'daemonize' => false,
|
||||
'pidFile' => Env::get('runtime_path') . 'worker.pid',
|
||||
|
||||
// 支持事件回调
|
||||
// onWorkerStart
|
||||
'onWorkerStart' => function ($worker) {
|
||||
|
||||
\wanghua\general_utility_tools_php\tool\Tools::log_to_write_txt([
|
||||
'onWorkerStart'=>$worker
|
||||
]);
|
||||
},
|
||||
// onWorkerReload
|
||||
'onWorkerReload' => function ($worker) {
|
||||
|
||||
\wanghua\general_utility_tools_php\tool\Tools::log_to_write_txt([
|
||||
'onWorkerReload'=>$worker
|
||||
]);
|
||||
},
|
||||
// onConnect
|
||||
'onConnect' => function ($connection) {
|
||||
|
||||
\wanghua\general_utility_tools_php\tool\Tools::log_to_write_txt([
|
||||
'onConnect'=>'onConnect'
|
||||
]);
|
||||
$connection->send(json_encode(['msg_type'=>'onConnect']));
|
||||
//$connection->send(json_encode(['test'=>'test','conn'=>$connection],JSON_UNESCAPED_UNICODE));
|
||||
},
|
||||
// onMessage
|
||||
'onMessage' => function ($connection, $data) {
|
||||
\wanghua\general_utility_tools_php\tool\Tools::log_to_write_txt([
|
||||
'onMessage'=>$data
|
||||
]);
|
||||
$connection->send(json_encode(['msg_type'=>'onMessage']));
|
||||
//$connection->send($connection.' === receive ,,,success');
|
||||
},
|
||||
// onClose
|
||||
'onClose' => function ($connection) {
|
||||
\wanghua\general_utility_tools_php\tool\Tools::log_to_write_txt([
|
||||
'onClose'=>'onClose'
|
||||
]);
|
||||
$connection->send(json_encode(['msg_type'=>'onClose']));
|
||||
|
||||
},
|
||||
// onError
|
||||
'onError' => function ($connection, $code, $msg) {
|
||||
\wanghua\general_utility_tools_php\tool\Tools::log_to_write_txt([
|
||||
'onError'=>[$code=>$msg]
|
||||
]);
|
||||
$connection->send(json_encode(['msg_type'=>'onError']));
|
||||
//echo "error [ $code ] $msg\n";
|
||||
},
|
||||
|
||||
];
|
||||
Reference in New Issue
Block a user