Ejemplo n.º 1
0
 /**
  * Reads the message header
  *
  * @param string $name  Function name
  * @param int    $type  message type TMessageType::CALL or TMessageType::REPLY
  * @param int    $seqid The sequence id of this message
  */
 public function readMessageBegin(&$name, &$type, &$seqid)
 {
     return $this->concreteProtocol_->readMessageBegin($name, $type, $seqid);
 }
 /**
  * This implementation of <code>process</code> performs the following steps:
  *
  * <ol>
  *     <li>Read the beginning of the message.</li>
  *     <li>Extract the service name from the message.</li>
  *     <li>Using the service name to locate the appropriate processor.</li>
  *     <li>Dispatch to the processor, with a decorated instance of TProtocol
  *         that allows readMessageBegin() to return the original Message.</li>
  * </ol>
  *
  * @throws TException If the message type is not CALL or ONEWAY, if
  * the service name was not found in the message, or if the service
  * name was not found in the service map.
  */
 public function process(TProtocol $input, TProtocol $output)
 {
     /*
         Use the actual underlying protocol (e.g. TBinaryProtocol) to read the
         message header. This pulls the message "off the wire", which we'll
         deal with at the end of this method.
     */
     $input->readMessageBegin($fname, $mtype, $rseqid);
     if ($mtype !== TMessageType::CALL && $mtype != TMessageType::ONEWAY) {
         throw new TException("This should not have happened!?");
     }
     // Extract the service name and the new Message name.
     if (strpos($fname, TMultiplexedProtocol::SEPARATOR) === false) {
         throw new TException("Service name not found in message name: {$fname}. Did you " . "forget to use a TMultiplexProtocol in your client?");
     }
     list($serviceName, $messageName) = explode(':', $fname, 2);
     if (!array_key_exists($serviceName, $this->serviceProcessorMap_)) {
         throw new TException("Service name not found: {$serviceName}.  Did you forget " . "to call registerProcessor()?");
     }
     // Dispatch processing to the stored processor
     $processor = $this->serviceProcessorMap_[$serviceName];
     return $processor->process(new StoredMessageProtocol($input, $messageName, $mtype, $rseqid), $output);
 }