Example #1
0
 /**
  * writeAMF3Data 
  * 
  * @param mixed $data 
  * @return void 
  */
 public function writeAMF3Data(SabreAMF_AMF3_Wrapper $data)
 {
     $serializer = new SabreAMF_AMF3_Serializer($this->stream);
     return $serializer->writeAMFData($data->getData());
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function invoke($destination, $operation, $parameters = array(), $callback = null, $packetClass = 'flex.messaging.messages.RemotingMessage', $headers = array(), $body = array())
 {
     $packet = new RTMPPacket($destination, $operation, $parameters, $packetClass, $headers, $body);
     $packet->build($this->DSId);
     $output = new \SabreAMF_OutputStream();
     $amf = new \SabreAMF_AMF0_Serializer($output);
     $amf3 = new \SabreAMF_AMF3_Serializer($output);
     $invokeId = ++$this->invokeId;
     $output->writeByte(0x0);
     $output->writeByte(0x5);
     $amf->writeAMFData($invokeId);
     $output->writeByte(0x5);
     $output->writeByte(0x11);
     $amf3->writeAMFData($packet->getData());
     $ret = $this->addHeaders($output->getRawData());
     $this->socket->write($ret);
     $this->responses[$invokeId] = [$this->parsePacket(), $callback];
     return $invokeId;
 }
Example #3
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;
     }
 }