コード例 #1
0
 /**
  * sendResponse 
  *
  * Sends the responses back to the client. Call this after you answered all the requests with setResponse
  * 
  * @return void
  */
 public function sendResponse()
 {
     header('Content-Type: ' . SabreAMF_Const::MIMETYPE);
     $this->amfResponse->setEncoding($this->amfRequest->getEncoding());
     $this->amfResponse->serialize($this->amfOutputStream);
     echo $this->amfOutputStream->getRawData();
 }
コード例 #2
0
ファイル: Server.php プロジェクト: romlg/cms36
 /**
  * sendResponse 
  *
  * Sends the responses back to the client. Call this after you answered all the requests with setResponse
  * 
  * @return void
  */
 public function sendResponse()
 {
     header('Content-Type: application/x-amf');
     $this->amfResponse->setEncoding($this->amfRequest->getEncoding());
     $this->amfResponse->serialize($this->amfOutputStream);
     echo $this->amfOutputStream->getRawData();
 }
コード例 #3
0
ファイル: Client.php プロジェクト: w3hacker/queryphp
 /**
  * sendRequest 
  *
  * sendRequest sends the request to the server. It expects the servicepath and methodname, and the parameters of the methodcall
  * 
  * @param string $servicePath The servicepath (e.g.: myservice.mymethod)
  * @param array $data The parameters you want to send
  * @return mixed 
  */
 public function sendRequest($servicePath, $data)
 {
     // We're using the FLEX Messaging framework
     if ($this->encoding & SabreAMF_Const::FLEXMSG) {
         // Setting up the message
         $message = new SabreAMF_AMF3_RemotingMessage();
         $message->body = $data;
         // We need to split serviceName.methodName into separate variables
         $service = explode('.', $servicePath);
         $method = array_pop($service);
         $service = implode('.', $service);
         $message->operation = $method;
         $message->source = $service;
         $data = $message;
     }
     $this->amfRequest->addBody(array('target' => $this->encoding & SabreAMF_Const::FLEXMSG ? 'null' : $servicePath, 'response' => '/1', 'data' => $data));
     $this->amfRequest->serialize($this->amfOutputStream);
     // The curl request
     $ch = curl_init($this->endPoint);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_TIMEOUT, 20);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: ' . SabreAMF_Const::MIMETYPE));
     curl_setopt($ch, CURLOPT_POSTFIELDS, $this->amfOutputStream->getRawData());
     if ($this->httpProxy) {
         curl_setopt($ch, CURLOPT_PROXY, $this->httpProxy);
     }
     $result = curl_exec($ch);
     if (curl_errno($ch)) {
         throw new Exception('CURL error: ' . curl_error($ch));
         false;
     } else {
         curl_close($ch);
     }
     $this->amfInputStream = new SabreAMF_InputStream($result);
     $this->amfResponse = new SabreAMF_Message();
     $this->amfResponse->deserialize($this->amfInputStream);
     $this->parseHeaders();
     foreach ($this->amfResponse->getBodies() as $body) {
         if (strpos($body['target'], '/1') === 0) {
             return $body['data'];
         }
     }
 }
コード例 #4
0
 /**
  * Encode Message
  *
  * @param int $amfVersion
  * @return RtmpPacket
  */
 public function encode()
 {
     $amfVersion = 3;
     //Using AMF3
     //Increment transaction id
     $this->transactionId = self::$currentTransactionID++;
     //Create packet
     $p = new RtmpPacket();
     if ($this->commandName == "connect") {
         $this->transactionId = 1;
         $amfVersion = 0;
         //Connect packet must be in AMF0
     }
     $p->chunkStreamId = 3;
     $p->streamId = 0;
     $p->chunkType = RtmpPacket::CHUNK_TYPE_0;
     $p->type = $amfVersion == 0 ? RtmpPacket::TYPE_INVOKE_AMF0 : RtmpPacket::TYPE_INVOKE_AMF3;
     //Invoke
     //Encoding payload
     $stream = new SabreAMF_OutputStream();
     $serializer = new SabreAMF_AMF0_Serializer($stream);
     $serializer->writeAMFData($this->commandName);
     $serializer->writeAMFData($this->transactionId);
     $serializer->writeAMFData($this->commandObject);
     if ($this->arguments != null) {
         foreach ($this->arguments as $arg) {
             $serializer->writeAMFData($arg);
         }
     }
     $p->payload = '';
     if ($amfVersion == 3) {
         $p->payload = "";
     }
     //XXX: put empty bytes in amf3 mode...I don't know why..*/
     $p->payload .= $stream->getRawData();
     $this->packet = $p;
     return $p;
 }
コード例 #5
0
ファイル: RTMPClient.php プロジェクト: phxlol/lol-php-api
 /**
  * {@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;
 }
コード例 #6
0
ファイル: Client.php プロジェクト: s1lviu/TriluliluDownloader
 /**
  * sendRequest 
  *
  * sendRequest sends the request to the server. It expects the servicepath and methodname, and the parameters of the methodcall
  * 
  * @param string $servicePath The servicepath (e.g.: myservice.mymethod)
  * @param array $data The parameters you want to send
  * @return mixed 
  */
 public function sendRequest($servicePath, $data)
 {
     // We're using the FLEX Messaging framework
     if ($this->encoding & SabreAMF_Const::FLEXMSG) {
         // Setting up the message
         $message = new SabreAMF_AMF3_RemotingMessage();
         $message->body = $data;
         // We need to split serviceName.methodName into separate variables
         $service = explode('.', $servicePath);
         $method = array_pop($service);
         $service = implode('.', $service);
         $message->operation = $method;
         $message->source = $service;
         $data = $message;
     }
     $this->amfRequest->addBody(array('target' => $this->encoding & SabreAMF_Const::FLEXMSG ? 'null' : $servicePath, 'response' => '/1', 'data' => $data));
     $this->amfRequest->serialize($this->amfOutputStream);
     ##test
     /*
     			require '../Zebra_cURL.php';
     
     $curl = new Zebra_cURL($this->endPoint);
     $curl->cache('cache', 3600);
     $curl->threads = 10;
     $curl->option(array(
     CURLOPT_CURLOPT_POST  =>  1,
     CURLOPT_FOLLOWLOCATION  =>  TRUE,
     CURLOPT_REFERER => 'http://www.trilulilu.ro',
     CURLOPT_TIMEOUT => 20,
     CURLOPT_HTTPHEADER => array('Content-type: ' . SabreAMF_Const::MIMETYPE),
     CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13',
     CURLOPT_RETURNTRANSFER         =>  1,
     CURLOPT_POSTFIELDS => $this->amfOutputStream->getRawData(),
     ));
     $v=$curl->get($url);
     $data=$v->body;
     $result =   html_entity_decode($data);
     
     ##
     */
     // The curl request
     $ch = curl_init($this->endPoint);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_REFERER, 'http://www.trilulilu.ro');
     curl_setopt($ch, CURLOPT_TIMEOUT, 20);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: ' . SabreAMF_Const::MIMETYPE));
     curl_setopt($ch, CURLOPT_POSTFIELDS, $this->amfOutputStream->getRawData());
     if ($this->httpProxy) {
         curl_setopt($ch, CURLOPT_PROXY, $this->httpProxy);
     }
     $result = curl_exec($ch);
     if (curl_errno($ch)) {
         throw new Exception('CURL error: ' . curl_error($ch));
         false;
     } else {
         curl_close($ch);
     }
     $this->amfInputStream = new SabreAMF_InputStream($result);
     $this->amfResponse = new SabreAMF_Message();
     $this->amfResponse->deserialize($this->amfInputStream);
     $this->parseHeaders();
     foreach ($this->amfResponse->getBodies() as $body) {
         if (strpos($body['target'], '/1') === 0) {
             return $body['data'];
         }
     }
 }
コード例 #7
0
ファイル: AmfSerializer.php プロジェクト: nakonechny/PhpYamdi
 public function getOutput()
 {
     return $this->outputStream->getRawData();
 }
コード例 #8
0
ファイル: RtmpClient.php プロジェクト: honomoa/phpLoL
 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;
     }
 }