Exemple #1
0
 public function testPrependRoutingInformationWithExistingRouting()
 {
     $msg = new Message(array('worker1', '', 'hello', 'world'));
     $msg->stripRoutingInformation();
     $msg->prependRoutingInformation(array('dealer1'));
     $this->assertSame(array('dealer1', '', 'worker1'), $msg->getRoutingInformation());
 }
Exemple #2
0
 /**
  * Send a Messsage.
  *
  * @param Message $msg
  *
  * @return Socket
  */
 public function msend(Message $msg)
 {
     if (ZMQ::SOCKET_ROUTER === $this->getSocketType()) {
         $msg->prepend($msg->getRoutingInformation());
     }
     if ($this->verbose) {
         $this->getLogger()->debug('SEND: ' . $this->id);
         $this->getLogger()->debug($msg);
     }
     $parts = $msg->toArray();
     $iMax = count($parts) - 1;
     if ($iMax < 0) {
         throw new RuntimeException('No parts to send.');
     }
     for ($i = 0; $i < $iMax; $i++) {
         $this->send($parts[$i], ZMQ::MODE_SNDMORE);
     }
     $this->send($parts[$iMax]);
     if ($this->verbose) {
         $this->getLogger()->debug('Message sent.');
     }
     return $this;
 }