protokol
要求(workerman >= 3.2.7)
Açıklama:
string Worker::$protocol
Geçerli Worker örneğinin protokol sınıfını ayarlayın.
Not: Protokol işleme sınıfı, Worker'ı başlatırken dinleme parametrelerinde doğrudan belirtilebilir. Örneğin:
$worker = new Worker('http://0.0.0.0:8686');
Örnek
use Workerman\Worker;
use Workerman\Connection\TcpConnection;
require_once __DIR__ . '/vendor/autoload.php';
$worker = new Worker('tcp://0.0.0.0:8686');
$worker->protocol = 'Workerman\\Protocols\\Http';
$worker->onMessage = function(TcpConnection $connection, $data)
{
var_dump($_GET, $_POST);
$connection->send("hello");
};
// worker'ı çalıştır
Worker::runAll();
Yukarıdaki kod aşağıdaki kod ile eşdeğerdir:
use Workerman\Worker;
use Workerman\Connection\TcpConnection;
require_once __DIR__ . '/vendor/autoload.php';
/**
* Öncelikle kullanıcının özel bir \Protocols\Http protokol sınıfı olup olmadığı kontrol edilecektir,
* Eğer yoksa workerman'ın yerleşik protokol sınıfı Workerman\Protocols\Http kullanılacaktır.
*/
$worker = new Worker('http://0.0.0.0:8686');
$worker->onMessage = function(TcpConnection $connection, $data)
{
var_dump($_GET, $_POST);
$connection->send("hello");
};
// worker'ı çalıştır
Worker::runAll();