Ejemplo n.º 1
0
 protected function invoke()
 {
     $cm = null;
     if (func_num_args() >= 3) {
         $add_header = array();
         $add_body = array();
         $destination = func_get_arg(0);
         $operation = func_get_arg(1);
         $body = func_get_arg(2);
         if (func_num_args() > 3) {
             $type = func_get_arg(3);
         } else {
             $type = "flex.messaging.messages.RemotingMessage";
         }
         if (func_num_args() > 4) {
             $add_header = func_get_arg(4);
         }
         if (func_num_args() > 5) {
             $add_body = func_get_arg(5);
         }
         $cmdmsg = new \SabreAMF_AMF3_RemotingMessage();
         $headers = array('DSRequestTimeout' => 60, 'DSId' => $this->dsId, 'DSEndpoint' => 'my-rtmps');
         foreach ($add_header as $k => $v) {
             $headers[$k] = $v;
         }
         $headers_cm = new \SabreAMF_TypedObject(null, $headers);
         $data = array('headers' => $headers_cm, 'timestamp' => 0, 'body' => $body, 'operation' => $operation, 'source' => null, 'messageId' => $cmdmsg->generateRandomId(), 'clientId' => null, 'timeToLive' => 0, 'destination' => $destination);
         foreach ($add_body as $k => $v) {
             $data[$k] = $v;
         }
         $cm = new \SabreAMF_TypedObject($type, $data);
     } else {
         $cm = func_get_arg(0);
     }
     if ($cm != null) {
         $stream = new \SabreAMF_OutputStream();
         $serializer = new \SabreAMF_AMF0_Serializer($stream);
         $serializer3 = new \SabreAMF_AMF3_Serializer($stream);
         $stream->writeByte(0x0);
         $stream->writeByte(0x5);
         $serializer->writeAMFData($this->invokeId++);
         $stream->writeByte(0x5);
         $stream->writeByte(0x11);
         $serializer3->writeAMFData($cm);
         $res = $this->addHeader($stream->getRawData());
         $this->send($res);
         $response = $this->readResponse(1);
         if ($response['result'] == '_error') {
             $data = $response['data']->getData();
             $exString = $data->faultString . " " . ($data->faultDetail ? $data->faultDetail : '');
             throw new \Exception($exString);
         }
         return $response;
     }
 }
Ejemplo n.º 2
0
 /**
  * Build the packet's body
  */
 public function buildBody()
 {
     $remoteMessage = new \SabreAMF_AMF3_RemotingMessage();
     $this->data = new \SabreAMF_TypedObject($this->class, array_merge(array('destination' => $this->destination, 'operation' => $this->operation, 'source' => null, 'timestamp' => 0, 'messageId' => $remoteMessage->generateRandomId(), 'timeToLive' => 0, 'clientId' => null, 'headers' => $this->headers, 'body' => $this->parameters), $this->additionalBody));
 }