close() public method

public close ( )
Esempio n. 1
0
 public static function unserialize($data, $simple = false)
 {
     $stream = new BytesIO($data);
     $reader = new Reader($stream, $simple);
     $result = $reader->unserialize();
     $stream->close();
     return $result;
 }
Esempio n. 2
0
 function decode($response, array &$args, stdClass $context)
 {
     if ($context->oneway) {
         return null;
     }
     if (empty($response)) {
         throw new Exception("EOF");
     }
     if ($response[strlen($response) - 1] !== Tags::TagEnd) {
         throw new Exception("Wrong Response: \r\n{$response}");
     }
     $mode = $context->mode;
     if ($mode === ResultMode::RawWithEndTag) {
         return $response;
     } elseif ($mode === ResultMode::Raw) {
         return substr($response, 0, -1);
     }
     $stream = new BytesIO($response);
     $reader = new Reader($stream);
     $result = null;
     $tag = $stream->getc();
     if ($tag === Tags::TagResult) {
         if ($mode === ResultMode::Normal) {
             $result = $reader->unserialize();
         } elseif ($mode === ResultMode::Serialized) {
             $result = $reader->readRaw()->toString();
         }
         $tag = $stream->getc();
         if ($tag === Tags::TagArgument) {
             $reader->reset();
             $arguments = $reader->readList();
             $n = min(count($arguments), count($args));
             for ($i = 0; $i < $n; $i++) {
                 $args[$i] = $arguments[$i];
             }
             $tag = $stream->getc();
         }
     } elseif ($tag === Tags::TagError) {
         $e = new Exception($reader->readString());
         $stream->close();
         throw $e;
     }
     if ($tag !== Tags::TagEnd) {
         $stream->close();
         throw new Exception("Wrong Response: \r\n{$response}");
     }
     $stream->close();
     return $result;
 }
Esempio n. 3
0
 private function doOutput($name, &$args, $byref, $simple, $context)
 {
     if ($simple === null) {
         $simple = $this->simple;
     }
     $stream = new BytesIO(Tags::TagCall);
     $writer = new Writer($stream, $simple);
     $writer->writeString($name);
     if (count($args) > 0 || $byref) {
         $writer->reset();
         $writer->writeArray($args);
         if ($byref) {
             $writer->writeBoolean(true);
         }
     }
     $stream->write(Tags::TagEnd);
     $request = $stream->toString();
     $count = count($this->filters);
     for ($i = 0; $i < $count; $i++) {
         $request = $this->filters[$i]->outputFilter($request, $context);
     }
     $stream->close();
     return $request;
 }
Esempio n. 4
0
 protected function doFunctionList($context)
 {
     $stream = new BytesIO();
     $writer = new Writer($stream, true);
     $stream->write(Tags::TagFunctions);
     $writer->writeArray($this->names);
     $stream->write(Tags::TagEnd);
     $data = $stream->toString();
     $stream->close();
     return $this->outputFilter($data, $context);
 }