Example #1
0
 /**
  * Create an RTC offer instance and save it.
  * @param string $name
  * @param string $offer RTCOffer json
  * @return \DataFestivus\RTCStore\Connection
  */
 public function offerCreate($name, $offer)
 {
     $connection = new Connection();
     $connection->setName($name);
     $connection->setOffer($offer);
     $this->save($connection);
     return $connection;
 }
Example #2
0
 /**
  * Retrieve an RTC connection with the specified name
  * @param $name
  * @return \DataFestivus\RTCStore\Connection
  */
 public function getOffer($name)
 {
     $select = $this->selectExecute($name);
     $row = $select->fetch(\PDO::FETCH_ASSOC);
     $connection = null;
     if ($row) {
         $connection = new Connection();
         $connection->setName($row['name']);
         $connection->setOffer($row['offer']);
         $connection->setAnswer($row['answer']);
         $connection->setCandidates(unserialize($row['candidates']));
     }
     return $connection;
 }
Example #3
0
 private function getAllConnections()
 {
     $fh = fopen($this->getStorePath(), 'r');
     if (!$fh) {
         throw new \Exception("Could not open rtcstore csv file.");
     }
     $connections = [];
     while ($fh && FALSE !== ($row = fgetcsv($fh))) {
         if (count($row) == 4) {
             $connection = new Connection();
             $connection->setName($row[0]);
             $connection->setOffer($row[1]);
             $connection->setAnswer($row[2]);
             $connection->setCandidates(unserialize($row[3]));
             $connections[$row[0]] = $connection;
         }
     }
     fclose($fh);
     return $connections;
 }