You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Michael_xu 2b1299b408
v11.0.3-20210517
4 years ago
..
src v11.0.3-20210517 4 years ago
LICENSE v11.0.3-20210517 4 years ago
README.md v11.0.3-20210517 4 years ago
composer.json v11.0.3-20210517 4 years ago

README.md

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

ThinkPHP 5.0 Workerman 扩展

使用方法

首先创建控制器类并继承 think\worker\Server然后设置属性和添加回调方法

namespace app\index\controller;

use think\worker\Server;
use app\index\model\User;

class Worker extends Server
{
	protected $socket = 'http://0.0.0.0:2346';

	public function onMessage($connection,$data)
	{
		$user = User::get($data['get']['id']);
		$connection->send(json_encode($user));
	}
}

注意该示例使用了User模型操作仅仅作为参考。

在命令行启动服务端

php index.php index/Worker/start

在浏览器中进行客户端测试 http://127.0.0.1:2346/?id=1