/** * Answer an existing offer and save it. * @param Connection $connection * @param string $answer RTCOfferAnswer json * @return void */ public function offerAnswer(Connection $connection, $answer) { $jsonObj = json_decode($answer); if ($jsonObj && $answer != $connection->getAnswer()) { $connection->setAnswer($answer); $this->save($connection); } }
/** * 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; }
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; }