Esempio n. 1
0
 public function askRouter()
 {
     $what = mt_rand(0, 100) % 2 == 0 ? "foo" : "bar";
     $id = sprintf('%s-%s', time(), $this->id);
     printf("Send /%s request with id %s\n", $what, $id);
     $this->dealer->send(new Event(sprintf("/request/%s", $what), ['id' => $id]));
 }
 public function onNext($value)
 {
     if ($this->event) {
         $this->event->data = $value;
         $event = $this->event;
     } else {
         $event = new Event("/response", $value);
     }
     $this->zmq->send($event);
 }
Esempio n. 3
0
 public function keepAlive()
 {
     echo "Sending /keepalive\n";
     $this->pusher->send('/keepalive');
 }
Esempio n. 4
0
 public function handleBar(Event $event)
 {
     $slotId = $event->getLabel('address');
     printf("[%s]id %s, response sent\n", date('H:i:s'), $event->getData('id'));
     $this->router->send(new Event('/response/bar', ['id' => $event->getData('id')]), $slotId);
 }