# protocol
~~~
string $worker->protocol
~~~
设置当前Worker实例的协议类。
>[danger] 在WarriorMan中,协议类只可以使用protocol指定
~~~
$worker = new Worker('tcp://0.0.0.0:8686');
$worker->protocol = "\Workerman\Protocols\Text"; // 设置协议
~~~
## 范例
~~~
use Workerman\Worker;
require_once __DIR__ . '/Workerman/Autoloader.php';
Warriorman\Worker::rename();
$worker = new Worker('tcp://0.0.0.0:8686');
$worker->protocol = 'Workerman\\Protocols\\Http';
$worker->onMessage = function($connection, $data)
{
var_dump($_GET, $_POST);
$connection->send("hello");
};
// 运行worker
Worker::runAll();
~~~
- 序言
- 启动停止
- 简单的开发示例
- 性能测试
- 性能测试-数据库
- 通讯协议
- Coroutine类
- create
- getCid
- yield
- resume
- sleep
- wait
- getTotalNum
- isExist
- defer
- Runtime类
- Worker类
- 构造函数
- 属性
- workerId
- id
- name
- protocol
- transport
- reusePort
- backlog
- connections
- stdoutFile
- pidFile
- logFile
- user
- reloadable
- daemonize
- globalEvent
- 回调属性
- onWorkerStart
- onWorkerReload
- onConnect
- onMessage
- onClose
- onBufferFull
- onBufferDrain
- onError
- 方法
- rename
- runAll
- stopAll
- listen
- TcpConnection类
- 属性
- id
- protocol
- worker
- maxSendBufferSize
- defaultMaxSendBufferSize
- defaultMaxPackageSize
- 方法
- set
- send
- getRemoteIp
- getRemotePort
- close
- destroy
- pauseRecv
- resumeRecv
- pipe
- Timer定时器类
- add
- del
- 定时器注意事项
- Channel类
- 构造方法
- push
- pop
- length
- isEmpty()