Example #1
0
 /**
  * Tests a periodic timer.
  */
 public function testPeriodic()
 {
     $total = 10;
     $count = 0;
     Vertx::setPeriodic(10, function ($timer_id) use(&$count, $total) {
         $this->assertNotNull($timer_id);
         $count += 1;
         if ($count == $total) {
             Vertx::cancelTimer($timer_id);
             Vertx::setTimer(10, function () {
                 $this->complete();
             });
         } else {
             if ($count > $total) {
                 $this->assertTrue(FALSE, 'Counter went off too many times!');
             }
         }
     });
 }
Example #2
0
<?php

$eventBus = Vertx::eventBus();
$logger = Vertx::logger();
Vertx::setPeriodic(1000, function () use($eventBus, $logger) {
    $eventBus->send('ping-address', 'ping', function ($reply) use($logger) {
        $logger->info("Received reply " . $reply->body);
    });
});
Example #3
0
<?php

$eventBus = Vertx::eventBus();
Vertx::setPeriodic(1000, function () use($eventBus) {
    $eventBus->publish('news-feed', 'Some news!');
});