server.php 493 B

12345678910111213141516171819202122
  1. <?php
  2. use Workerman\Worker;
  3. use Workerman\Lib\Timer;
  4. // composer autoload
  5. include __DIR__ . '/../vendor/autoload.php';
  6. $channel_server = new Channel\Server();
  7. $worker = new Worker();
  8. $worker->onWorkerStart = function()
  9. {
  10. Channel\Client::on('test event', function($event_data){
  11. echo 'test event triggered event_data :';
  12. var_dump($event_data);
  13. });
  14. Timer::add(5, function(){
  15. Channel\Client::publish('test event', 'some data');
  16. });
  17. };
  18. Worker::runAll();