input_ = $input; $this->output_ = $output ? $output : $input; } public function get($api, $param) { $this->send_get($api, $param); return $this->recv_get(); } public function send_get($api, $param) { $args = new \DeverApi\ApiService_get_args(); $args->api = $api; $args->param = $param; $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); if ($bin_accel) { thrift_protocol_write_binary($this->output_, 'get', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); } else { $this->output_->writeMessageBegin('get', TMessageType::CALL, $this->seqid_); $args->write($this->output_); $this->output_->writeMessageEnd(); $this->output_->getTransport()->flush(); } } public function recv_get() { $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\DeverApi\ApiService_get_result', $this->input_->isStrictRead()); else { $rseqid = 0; $fname = null; $mtype = 0; $this->input_->readMessageBegin($fname, $mtype, $rseqid); if ($mtype == TMessageType::EXCEPTION) { $x = new TApplicationException(); $x->read($this->input_); $this->input_->readMessageEnd(); throw $x; } $result = new \DeverApi\ApiService_get_result(); $result->read($this->input_); $this->input_->readMessageEnd(); } if ($result->success !== null) { return $result->success; } throw new \Exception("get failed: unknown result"); } } // HELPER FUNCTIONS AND STRUCTURES class ApiService_get_args { static $_TSPEC; /** * @var string */ public $api = null; /** * @var string */ public $param = null; public function __construct($vals=null) { if (!isset(self::$_TSPEC)) { self::$_TSPEC = array( 1 => array( 'var' => 'api', 'type' => TType::STRING, ), 2 => array( 'var' => 'param', 'type' => TType::STRING, ), ); } if (is_array($vals)) { if (isset($vals['api'])) { $this->api = $vals['api']; } if (isset($vals['param'])) { $this->param = $vals['param']; } } } public function getName() { return 'ApiService_get_args'; } public function read($input) { $xfer = 0; $fname = null; $ftype = 0; $fid = 0; $xfer += $input->readStructBegin($fname); while (true) { $xfer += $input->readFieldBegin($fname, $ftype, $fid); if ($ftype == TType::STOP) { break; } switch ($fid) { case 1: if ($ftype == TType::STRING) { $xfer += $input->readString($this->api); } else { $xfer += $input->skip($ftype); } break; case 2: if ($ftype == TType::STRING) { $xfer += $input->readString($this->param); } else { $xfer += $input->skip($ftype); } break; default: $xfer += $input->skip($ftype); break; } $xfer += $input->readFieldEnd(); } $xfer += $input->readStructEnd(); return $xfer; } public function write($output) { $xfer = 0; $xfer += $output->writeStructBegin('ApiService_get_args'); if ($this->api !== null) { $xfer += $output->writeFieldBegin('api', TType::STRING, 1); $xfer += $output->writeString($this->api); $xfer += $output->writeFieldEnd(); } if ($this->param !== null) { $xfer += $output->writeFieldBegin('param', TType::STRING, 2); $xfer += $output->writeString($this->param); $xfer += $output->writeFieldEnd(); } $xfer += $output->writeFieldStop(); $xfer += $output->writeStructEnd(); return $xfer; } } class ApiService_get_result { static $_TSPEC; /** * @var string */ public $success = null; public function __construct($vals=null) { if (!isset(self::$_TSPEC)) { self::$_TSPEC = array( 0 => array( 'var' => 'success', 'type' => TType::STRING, ), ); } if (is_array($vals)) { if (isset($vals['success'])) { $this->success = $vals['success']; } } } public function getName() { return 'ApiService_get_result'; } public function read($input) { $xfer = 0; $fname = null; $ftype = 0; $fid = 0; $xfer += $input->readStructBegin($fname); while (true) { $xfer += $input->readFieldBegin($fname, $ftype, $fid); if ($ftype == TType::STOP) { break; } switch ($fid) { case 0: if ($ftype == TType::STRING) { $xfer += $input->readString($this->success); } else { $xfer += $input->skip($ftype); } break; default: $xfer += $input->skip($ftype); break; } $xfer += $input->readFieldEnd(); } $xfer += $input->readStructEnd(); return $xfer; } public function write($output) { $xfer = 0; $xfer += $output->writeStructBegin('ApiService_get_result'); if ($this->success !== null) { $xfer += $output->writeFieldBegin('success', TType::STRING, 0); $xfer += $output->writeString($this->success); $xfer += $output->writeFieldEnd(); } $xfer += $output->writeFieldStop(); $xfer += $output->writeStructEnd(); return $xfer; } } class ApiServiceProcessor { protected $handler_ = null; public function __construct($handler) { $this->handler_ = $handler; } public function process($input, $output) { $rseqid = 0; $fname = null; $mtype = 0; $input->readMessageBegin($fname, $mtype, $rseqid); $methodname = 'process_'.$fname; if (!method_exists($this, $methodname)) { $input->skip(TType::STRUCT); $input->readMessageEnd(); $x = new TApplicationException('Function '.$fname.' not implemented.', TApplicationException::UNKNOWN_METHOD); $output->writeMessageBegin($fname, TMessageType::EXCEPTION, $rseqid); $x->write($output); $output->writeMessageEnd(); $output->getTransport()->flush(); return; } $this->$methodname($rseqid, $input, $output); return true; } protected function process_get($seqid, $input, $output) { $args = new \DeverApi\ApiService_get_args(); $args->read($input); $input->readMessageEnd(); $result = new \DeverApi\ApiService_get_result(); $result->success = $this->handler_->get($args->api, $args->param); $bin_accel = ($output instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); if ($bin_accel) { thrift_protocol_write_binary($output, 'get', TMessageType::REPLY, $result, $seqid, $output->isStrictWrite()); } else { $output->writeMessageBegin('get', TMessageType::REPLY, $seqid); $result->write($output); $output->writeMessageEnd(); $output->getTransport()->flush(); } } }