# 官方文檔:
https://www.workerman.net/doc/workerman/timer/add.html
## 代碼案例:
~~~
require_once 'workerman/Autoloader.php';
use Workerman\Worker;
use Workerman\Lib\Timer;
$worker=new Worker('text://0.0.0.0:8883');
$worker->onWorkerStart=function ($worker){
Timer::add(3,function (){
echo "定時器"."\n";
});
};
$worker->onConnect = function($connection)
{
echo "new connection from address ". $connection->getRemoteIp() . ":". $connection->getRemotePort() ."\n"; //獲取端口與IP
};
Worker::runAll();
~~~
- WebSocket協議
- 構造函數(6種協議)
- count(進程設置)
- name(鏈接名稱)
- $daemonize(守護進程設置)
- logFile(日志路徑)
- stdoutFile(守護進程記錄文件)
- connections(獲取鏈接數組的)
- worker的回調屬性
- worker類的方法
- Connection類的方法
- getRemotePort獲取端口方法
- getRemoteIp獲取IP地址
- close 安全關閉連接
- 定時器
- Channel分布式通信組件
- 心跳檢測程序
- liunx優化配置
- thinkphp5.1使用worerman
- thinkphp5.1中用Channel實現廣播通信
- thinkphp5.1中使用定時器
- thinkphp5.1使用TcpConnection類
- Gateway類使用
- BusinessWorker使用
- Register類的使用
- Events類使用(業務邏輯層)
- Lib\Gateway 接口(經常用)
- webman中間件stomp
- Gateway在thinkphp5.1里使用