Example #1
0
 /**
  * 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);
     }
 }
Example #2
0
 public function save(Connection $connection)
 {
     $select = $this->selectExecute($connection->getName());
     $id = $select->fetchColumn(0);
     $params = array();
     if ($id) {
         $params['id'] = $id;
         $statement = $this->getUpdate();
     } else {
         $statement = $this->getInsert();
     }
     $params['name'] = $connection->getName();
     $params['offer'] = $connection->getOffer();
     $params['answer'] = $connection->getAnswer();
     $params['candidates'] = serialize($connection->getCandidates());
     $result = $statement->execute($params);
     if (!$result) {
         throw new \Exception("failed to save connection record.");
     }
 }