예제 #1
0
파일: AMF0.php 프로젝트: stunti/zf2
 /**
  * Unserialize an AMF0 value to PHP
  * 
  * @param  mixed $value 
  * @param  array $opts 
  * @return void
  * @throws \Zend\Serializer\Exception
  */
 public function unserialize($value, array $opts = array())
 {
     try {
         $stream = new AMFParser\InputStream($value);
         $deserializer = new AMFParser\AMF0\Deserializer($stream);
         return $deserializer->readTypeMarker();
     } catch (\Exception $e) {
         throw new SerializationException('Unserialization failed by previous error', 0, $e);
     }
 }
예제 #2
0
파일: AMF0.php 프로젝트: alab1001101/zf2
 /**
  * Unserialize an AMF0 value to PHP
  * 
  * @param  mixed $value 
  * @param  array $opts 
  * @return void
  * @throws Zend\Serializer\Exception
  */
 public function unserialize($value, array $opts = array())
 {
     try {
         $stream = new AmfParser\InputStream($value);
         $deserializer = new AmfParser\Amf0\Deserializer($stream);
         return $deserializer->readTypeMarker();
     } catch (\Exception $e) {
         throw new RuntimeException('Unserialization failed: ' . $e->getMessage(), 0, $e);
     }
 }
예제 #3
0
 /**
  * Deserialize a message body from the input stream
  *
  * @return \Zend\Amf\Value\MessageBody
  * @throws Amf\Exception\RuntimeException
  */
 public function readBody()
 {
     $targetURI = $this->_inputStream->readUTF();
     $responseURI = $this->_inputStream->readUTF();
     $length = $this->_inputStream->readLong();
     try {
         $data = $this->_deserializer->readTypeMarker();
     } catch (\Exception $e) {
         throw new Amf\Exception\RuntimeException('Unable to parse ' . $targetURI . ' body data ' . $e->getMessage(), 0, $e);
     }
     // Check for AMF3 objectEncoding
     if ($this->_deserializer->getObjectEncoding() == Amf\Constants::AMF3_OBJECT_ENCODING) {
         /*
          * When and AMF3 message is sent to the server it is nested inside
          * an AMF0 array called Content. The following code gets the object
          * out of the content array and sets it as the message data.
          */
         if (is_array($data) && $data[0] instanceof Value\Messaging\AbstractMessage) {
             $data = $data[0];
         }
         // set the encoding so we return our message in AMF3
         $this->_objectEncoding = Amf\Constants::AMF3_OBJECT_ENCODING;
     }
     $body = new Value\MessageBody($targetURI, $responseURI, $data);
     return $body;
 }