-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bba1eec
commit 2ce8219
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# swooletest | ||
方便快速创建基于swoole的服务 | ||
##用法 | ||
* app中新建具体behavior类,该类根据要使用的service(tcp,http,websocket)继承自相应的behavior | ||
* 在运行脚本中指定要使用的behavior | ||
> 使用完整命名空间路径 | ||
* 初始化相应的service; | ||
* 运行 | ||
##example | ||
```php | ||
define('BASEDIR', __DIR__); | ||
include BASEDIR . '/autoload.php'; //可自定义 | ||
$config = [ | ||
'Host'=>'0.0.0.0', | ||
'Port'=>9501, | ||
'Behavior'=>'\app\imBehavior', //具体行为类 | ||
'Set'=>[ | ||
'worker_num'=>2, //onTask必须设置 | ||
'task_worker_num'=>4, | ||
] | ||
]; | ||
$ws = new \library\wsService($config); //初始化服务 | ||
$ws->start(); | ||
``` |