コード例 #1
0
ファイル: AuthTest.php プロジェクト: jsnshrmn/Suma
 protected function _addLogout($request)
 {
     $cmdBody = new Zend_Amf_Value_MessageBody("", "/1", "");
     $loginCmd = new Zend_Amf_Value_Messaging_CommandMessage();
     $cmdBody->setData($loginCmd);
     $loginCmd->operation = Zend_Amf_Value_Messaging_CommandMessage::LOGOUT_OPERATION;
     $request->addAmfBody($cmdBody);
 }
コード例 #2
0
ファイル: Amf.php プロジェクト: raisinbread/li3_amf
 /**
  * Exracts URI and params info based on object encoding.
  *
  * @param Zend_Amf_Value_MessageBody $body 
  * @return array
  */
 public function extractUriAndParams($body)
 {
     try {
         if ($this->objectEncoding == \Zend_Amf_Constants::AMF0_OBJECT_ENCODING) {
             // AMF0 Object Encoding
             $targetURI = $body->getTargetURI();
             // Split the target string into its values.
             $source = substr($targetURI, 0, strrpos($targetURI, '.'));
             if ($source) {
                 // Break off method name from namespace into source
                 $method = substr(strrchr($targetURI, '.'), 1);
                 $return = array('method' => $method, 'params' => $body->getData(), 'source' => $source);
             } else {
                 // Just have a method name.
                 $return = array('targetURI' => $targetURI, 'params' => $body->getData());
             }
         } else {
             // AMF3 read message type
             $message = $body->getData();
             if ($message instanceof \Zend_Amf_Value_Messaging_CommandMessage) {
                 // async call with command message
                 switch ($message->operation) {
                     case \Zend_Amf_Value_Messaging_CommandMessage::CLIENT_PING_OPERATION:
                         require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
                         $return = new \Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
                         break;
                     default:
                         require_once 'Zend/Amf/Server/Exception.php';
                         throw new \Zend_Amf_Server_Exception('CommandMessage::' . $message->operation . ' not implemented');
                         break;
                 }
             } elseif ($message instanceof \Zend_Amf_Value_Messaging_RemotingMessage) {
                 require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
                 $return = new \Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
                 $return->body = array('method' => $message->operation, 'params' => $message->body, 'source' => $message->source);
             } else {
                 // Amf3 message sent with netConnection
                 $targetURI = $body->getTargetURI();
                 // Split the target string into its values.
                 $source = substr($targetURI, 0, strrpos($targetURI, '.'));
                 if ($source) {
                     // Break off method name from namespace into source
                     $method = substr(strrchr($targetURI, '.'), 1);
                     $return = array('method' => $method, 'params' => array($body->getData()), 'source' => $source);
                 } else {
                     // Just have a method name.
                     $return = array('targetURI' => $targetURI, 'params' => $body->getData());
                 }
             }
         }
         $responseType = \Zend_AMF_Constants::RESULT_METHOD;
     } catch (Exception $e) {
         $isDebug = Configure::read('debug') > 0;
         switch ($objectEncoding) {
             case \Zend_Amf_Constants::AMF0_OBJECT_ENCODING:
                 $return = array('description' => $isDebug ? '' : $e->getMessage(), 'detail' => $isDebug ? '' : $e->getTraceAsString(), 'line' => $isDebug ? 0 : $e->getLine(), 'code' => $e->getCode());
                 break;
             case \Zend_Amf_Constants::AMF3_OBJECT_ENCODING:
                 require_once 'Zend/Amf/Value/Messaging/ErrorMessage.php';
                 $return = new \Zend_Amf_Value_Messaging_ErrorMessage($message);
                 $return->faultString = $this->isProduction() ? '' : $e->getMessage();
                 $return->faultCode = $e->getCode();
                 $return->faultDetail = $this->isProduction() ? '' : $e->getTraceAsString();
                 break;
         }
         $responseType = \Zend_AMF_Constants::STATUS_METHOD;
     }
     return $return;
 }