예제 #1
0
 /**
  * Create and encode the connection packet
  */
 protected function encodeConnectionPacket()
 {
     $parameters = array('app' => $this->app, 'flashVer' => 'WIN 10,1,85,3', 'swfUrl' => $this->swfUrl, 'tcUrl' => sprintf('rtmps://%s:%d', $this->server, $this->port), 'fpad' => false, 'capabilities' => 239, 'audioCodecs' => 3191, 'videoCodecs' => 252, 'pageUrl' => $this->pageUrl, 'objectEncoding' => 3);
     $output = new \SabreAMF_OutputStream();
     $amf3 = new \SabreAMF_AMF3_Serializer($output);
     $amf = new \SabreAMF_AMF0_Serializer($output);
     $amf->writeAMFData('connect');
     $amf->writeAMFData(1);
     // the invokeId
     // Parameters
     $output->writeByte(0x11);
     // AMF3 object
     $output->writeByte(0x9);
     // array
     $output->writeByte(0x1);
     foreach ($parameters as $name => $value) {
         $amf3->writeString($name);
         $amf3->writeAMFData($value);
     }
     $output->writeByte(0x1);
     // Service call arguments
     $output->writeByte(0x1);
     $output->writeByte(0x0);
     $amf->writeAMFData('nil');
     $amf->writeAMFData('', \SabreAMF_AMF0_Const::DT_STRING);
     $commandMessageObject = new \SabreAMF_AMF3_CommandMessage();
     $commandData = array('messageRefType' => null, 'operation' => 5, 'correlationId' => '', 'clientId' => null, 'destination' => null, 'messageId' => $commandMessageObject->generateRandomId(), 'timestamp' => 0.0, 'timeToLive' => 0.0, 'body' => new \SabreAMF_TypedObject('', array()), 'header' => array('DSMessagingVersion' => 1.0, 'DSId' => 'my-rtmps'));
     $commandMessage = new \SabreAMF_TypedObject("flex.messaging.messages.CommandMessage", $commandData);
     $output->writeByte(0x11);
     // amf3
     $amf3->writeAMFData($commandMessage);
     $packet = $this->addHeaders($output->getRawData());
     $packet[7] = chr(0x14);
     // message type
     $this->socket->write($packet);
 }
예제 #2
0
 public function doConnect()
 {
     $connectParams = array('objectEncoding' => 3, 'app' => $this->app, 'fpad' => false, 'flashVer' => 'WIN 10,1,85,3', 'tcUrl' => "{$this->protocol}://{$this->host}:{$this->port}", 'audioCodecs' => 3191, 'videoFunction' => 1, 'pageUrl' => $this->pageUrl, 'capabilities' => 239, 'swfUrl' => $this->swfUrl, 'videoCodecs' => 252);
     $stream = new \SabreAMF_OutputStream();
     $serializer = new \SabreAMF_AMF0_Serializer($stream);
     $serializer3 = new \SabreAMF_AMF3_Serializer($stream);
     $serializer->writeAMFData("connect");
     $serializer->writeAMFData($this->invokeId++);
     $stream->writeByte(0x11);
     $stream->writeByte(0x9);
     //params
     $serializer3->writeAMFData(null);
     foreach ($connectParams as $key => $value) {
         $serializer3->writeString($key);
         $serializer3->writeAMFData($value);
     }
     $serializer3->writeAMFData(null);
     //Service call
     $stream->writeByte(0x1);
     $stream->writeByte(0x0);
     $serializer->writeAMFData('nil');
     $serializer->writeAMFData('', \SabreAMF_AMF0_Const::DT_STRING);
     $cmdmsg = new \SabreAMF_AMF3_CommandMessage();
     $headers = array('DSMessagingVersion' => 1.0, 'DSId' => 'my-rtmps');
     $data = array('headers' => $headers, 'timestamp' => 0.0, 'body' => null, 'operation' => 5, 'messageRefType' => null, 'correlationId' => '', 'messageId' => $cmdmsg->generateRandomId(), 'timeToLive' => 0.0, 'clientId' => null, 'destination' => null);
     $cm = new \SabreAMF_TypedObject("flex.messaging.messages.CommandMessage", $data);
     $stream->writeByte(0x11);
     @$serializer3->writeAMFData($cm);
     $res = $this->addHeader($stream->getRawData());
     $res[7] = chr(0x14);
     $this->send($res);
     $response = $this->readResponse();
     $this->dsId = $response['data']['id'];
     return $response;
 }