lib/avro/ipc.php
public function request($message_name, $request_datum)
  {
    $io = new AvroStringIO();
    $encoder = new AvroIOBinaryEncoder($io);
    $this->write_handshake_request($encoder);
    $this->write_call_request($message_name, $request_datum, $encoder);
    
    $call_request = $io->string();
    if ($this->local_protocol->messages[$message_name]->is_one_way()) {
      $this->transceiver->write_message($call_request);
      if (!$this->transceiver->is_connected()) {
        $handshake_response = $this->transceiver->read_message();
        $io = new AvroStringIO($handshake_response);
        $decoder = new AvroIOBinaryDecoder($io);
        $this->read_handshake_response($decoder);
      }
      return true;
      
    } else {
      $call_response = $this->transceiver->transceive($call_request);
      // process the handshake and call response
      $io = new AvroStringIO($call_response);
      $decoder = new AvroIOBinaryDecoder($io);
      $call_response_exists = $this->read_handshake_response($decoder);
      if ($call_response_exists) {
         $call_response = $this->read_call_response($message_name, $decoder);
        return $call_response;
      } else
        return $this->request($message_name, $request_datum);
    }
  }
public function request($message_name, $request_datum)
  {
    $io = new AvroStringIO();
    $encoder = new AvroIOBinaryEncoder($io);
    $this->write_handshake_request($encoder);
    $this->write_call_request($message_name, $request_datum, $encoder);
    
    $call_request = $io->string();
    if ($this->local_protocol->messages[$message_name]->is_one_way()) {
      $this->transceiver->write_message($call_request);
      if (!$this->transceiver->is_connected()) {
        $handshake_response = $this->transceiver->read_message();
        $io = new AvroStringIO($handshake_response);
        $decoder = new AvroIOBinaryDecoder($io);
        $this->read_handshake_response($decoder);
      }
      return true;
      
    } else {
      $call_response = $this->transceiver->transceive($call_request);
      // process the handshake and call response
      $io = new AvroStringIO($call_response);
      $decoder = new AvroIOBinaryDecoder($io);
      $call_response_exists = $this->read_handshake_response($decoder);
      if ($call_response_exists) {
         $call_response = $this->read_call_response($message_name, $decoder);
        return $call_response;
      } else
        return $this->request($message_name, $request_datum);
    }
  }
public function request ( $ message_name , $ request_datum ) { $ io = new AvroStringIO ( ) ; $ encoder = new AvroIOBinaryEncoder ( $ io ) ; $ this -> write_handshake_request ( $ encoder ) ; $ this -> write_call_request ( $ message_name , $ request_datum , $ encoder ) ; $ call_request = $ io -> string ( ) ; if ( $ this -> local_protocol -> messages [ $ message_name ] -> is_one_way ( ) ) { $ this -> transceiver -> write_message ( $ call_request ) ; if ( ! $ this -> transceiver -> is_connected ( ) ) { $ handshake_response = $ this -> transceiver -> read_message ( ) ; $ io = new AvroStringIO ( $ handshake_response ) ; $ decoder = new AvroIOBinaryDecoder ( $ io ) ; $ this -> read_handshake_response ( $ decoder ) ; } return true ; } else { $ call_response = $ this -> transceiver -> transceive ( $ call_request ) ; // process the handshake and call response $ io = new AvroStringIO ( $ call_response ) ; $ decoder = new AvroIOBinaryDecoder ( $ io ) ; $ call_response_exists = $ this -> read_handshake_response ( $ decoder ) ; if ( $ call_response_exists ) { $ call_response = $ this -> read_call_response ( $ message_name , $ decoder ) ; return $ call_response ; } else return $ this -> request ( $ message_name , $ request_datum ) ; } }
Writes a request message and reads a response or error message.
@param string $message_name : name of the IPC method
@param mixed $request_datum : IPC request
@throw AvroException when $message_name is not registered on the local or remote protocol
@throw AvroRemoteException when server send an error
Writes a request message and reads a response or error message .