## 引入定時器
~~~
use Workerman\Lib\Timer
~~~
## 其他與官方相同
## 比如 5秒訪問一個網站
~~~
<?php
namespace app\http;
use Workerman\Lib\Timer as T;
use think\worker\Server;
class Timer extends Server
{
public function onWorkerStart(){
$time_interval = 5;
T::add($time_interval, function()
{
$u='http://111.67.202.126:9999?content=虎贏'; //網站
$ch=curl_init(); //初始化curl會話返回curl句柄(資源)
curl_setopt($ch,CURLOPT_URL,$u); //設置獲取地址變量
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); //以字符串形式返回
$ma=curl_exec($ch);
curl_close($ch); //關閉句柄
echo $ma."\n";
});
}
}
~~~
- 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里使用