2022-08-16 15:19:21 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Channel\Client;
|
|
|
|
use Channel\Server;
|
|
|
|
use Workerman\Worker;
|
2023-05-05 12:04:46 +08:00
|
|
|
use Workerman\Timer;
|
2022-08-16 15:19:21 +08:00
|
|
|
|
|
|
|
// composer autoload
|
|
|
|
include __DIR__ . '/../vendor/autoload.php';
|
|
|
|
|
|
|
|
$channel_server = new Server();
|
|
|
|
|
|
|
|
$worker = new Worker();
|
|
|
|
$worker->onWorkerStart = function()
|
|
|
|
{
|
|
|
|
Client::connect();
|
|
|
|
|
|
|
|
Client::on('test event', function($event_data){
|
|
|
|
echo 'test event triggered event_data :';
|
|
|
|
var_dump($event_data);
|
|
|
|
});
|
|
|
|
|
|
|
|
Timer::add(2, function(){
|
|
|
|
Client::publish('test event', 'some data');
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
Worker::runAll();
|