Exemple #1
0
 /**
  * @internal
  */
 function __construct($opentok, $sessionId, $properties = array())
 {
     // unpack arguments
     $defaults = array('mediaMode' => MediaMode::ROUTED, 'location' => null);
     $properties = array_merge($defaults, array_intersect_key($properties, $defaults));
     list($mediaMode, $location) = array_values($properties);
     Validators::validateOpenTok($opentok);
     Validators::validateSessionId($sessionId);
     Validators::validateLocation($location);
     Validators::validateMediaMode($mediaMode);
     $this->opentok = $opentok;
     $this->sessionId = $sessionId;
     $this->location = $location;
     $this->mediaMode = $mediaMode;
 }
 /**
  * @internal
  */
 public function __construct($archiveListData, $options = array())
 {
     // unpack optional arguments (merging with default values) into named variables
     $defaults = array('apiKey' => null, 'apiSecret' => null, 'apiUrl' => 'https://api.opentok.com', 'client' => null);
     $options = array_merge($defaults, array_intersect_key($options, $defaults));
     list($apiKey, $apiSecret, $apiUrl, $client) = array_values($options);
     // validate params
     Validators::validateArchiveListData($archiveListData);
     Validators::validateClient($client);
     $this->data = $archiveListData;
     $this->client = isset($client) ? $client : new Client();
     if (!$this->client->isConfigured()) {
         Validators::validateApiKey($apiKey);
         Validators::validateApiSecret($apiSecret);
         Validators::validateApiUrl($apiUrl);
         $this->client->configure($apiKey, $apiSecret, $apiUrl);
     }
 }
Exemple #3
0
 /**
  * Stops the OpenTok archive, if it is being recorded.
  * <p>
  * Archives automatically stop recording after 90 minutes or when all clients have
  * disconnected from the session being archived.
  *
  * @throws Exception\ArchiveException The archive is not being recorded.
  */
 public function stop()
 {
     if ($this->isDeleted) {
         // TODO: throw an logic error about not being able to stop an archive thats deleted
     }
     $archiveData = $this->client->stopArchive($this->data['id']);
     try {
         Validators::validateArchiveData($archiveData);
     } catch (InvalidArgumentException $e) {
         throw new ArchiveUnexpectedValueException('The archive JSON returned after stopping was not valid', null, $e);
     }
     $this->data = $archiveData;
     return $this;
 }
 /**
  * Returns an ArchiveList. The <code>items()</code> method of this object returns a list of
  * archives that are completed and in-progress, for your API key.
  *
  * @param integer $offset Optional. The index offset of the first archive. 0 is offset of the
  * most recently started archive. 1 is the offset of the archive that started prior to the most
  * recent archive. If you do not specify an offset, 0 is used.
  * @param integer $count Optional. The number of archives to be returned. The maximum number of
  * archives returned is 1000.
  * @return ArchiveList An ArchiveList object. Call the items() method of the ArchiveList object
  * to return an array of Archive objects.
  */
 public function listArchives($offset = 0, $count = null)
 {
     // validate params
     Validators::validateOffsetAndCount($offset, $count);
     $archiveListData = $this->client->listArchives($offset, $count);
     return new ArchiveList($archiveListData, array('client' => $this->client));
 }