|
3 | 3 | namespace OpenTok; |
4 | 4 |
|
5 | 5 | use OpenTok\Session; |
| 6 | +use OpenTok\Stream; |
| 7 | +use OpenTok\StreamList; |
6 | 8 | use OpenTok\Archive; |
7 | 9 | use OpenTok\Broadcast; |
8 | 10 | use OpenTok\Layout; |
@@ -388,21 +390,35 @@ public function deleteArchive($archiveId) |
388 | 390 | * recent archive. If you do not specify an offset, 0 is used. |
389 | 391 | * @param integer $count Optional. The number of archives to be returned. The maximum number of |
390 | 392 | * archives returned is 1000. |
| 393 | + * @param string $sessionId Optional. The OpenTok session Id for which you want to retrieve Archives for. If no session Id |
| 394 | + * is specified, the method will return archives from all sessions created with the API key. |
| 395 | + * |
391 | 396 | * @return ArchiveList An ArchiveList object. Call the items() method of the ArchiveList object |
392 | 397 | * to return an array of Archive objects. |
393 | 398 | */ |
394 | | - public function listArchives($offset=0, $count=null) |
| 399 | + public function listArchives($offset=0, $count=null, $sessionId=null) |
395 | 400 | { |
396 | 401 | // validate params |
397 | 402 | Validators::validateOffsetAndCount($offset, $count); |
| 403 | + if (!is_null($sessionId)) { |
| 404 | + Validators::validateSessionIdBelongsToKey($sessionId, $this->apiKey); |
| 405 | + } |
398 | 406 |
|
399 | | - $archiveListData = $this->client->listArchives($offset, $count); |
| 407 | + $archiveListData = $this->client->listArchives($offset, $count, $sessionId); |
400 | 408 | return new ArchiveList($archiveListData, array( 'client' => $this->client )); |
401 | 409 | } |
402 | 410 |
|
| 411 | + /** |
| 412 | + * Force disconnects a specific client connected to an OpenTok session. |
| 413 | + * |
| 414 | + * @param string $sessionId The OpenTok session ID where the signal will be sent. |
| 415 | + * |
| 416 | + * @param string $connectionId The connectionId of the connection in a session. |
| 417 | + */ |
| 418 | + |
403 | 419 | public function forceDisconnect($sessionId, $connectionId) |
404 | 420 | { |
405 | | - Validators::validateSessionId($sessionId); |
| 421 | + Validators::validateSessionIdBelongsToKey($sessionId, $this->apiKey); |
406 | 422 | Validators::validateConnectionId($connectionId); |
407 | 423 |
|
408 | 424 | return $this->client->forceDisconnect($sessionId, $connectionId); |
@@ -490,6 +506,46 @@ public function updateStream($sessionId, $streamId, $properties = array()) |
490 | 506 | $this->client->updateStream($sessionId, $streamId, $properties); |
491 | 507 | } |
492 | 508 |
|
| 509 | + /** |
| 510 | + * Gets an Stream object for the given stream ID. |
| 511 | + * |
| 512 | + * @param String $sessionId The session ID. |
| 513 | + * |
| 514 | + * @param String $streamId The stream ID. |
| 515 | + * |
| 516 | + * @return Stream The Stream object. |
| 517 | + */ |
| 518 | + |
| 519 | + public function getStream($sessionId, $streamId) |
| 520 | + { |
| 521 | + Validators::validateSessionId($sessionId); |
| 522 | + Validators::validateStreamId($streamId); |
| 523 | + |
| 524 | + // make API call |
| 525 | + $streamData = $this->client->getStream($sessionId, $streamId); |
| 526 | + return new Stream($streamData); |
| 527 | + |
| 528 | + } |
| 529 | + |
| 530 | + /** |
| 531 | + * Returns a StreamList Object for the given session ID. |
| 532 | + * |
| 533 | + * @param String $sessionId The session ID. |
| 534 | + * |
| 535 | + * @return StreamList A StreamList object. Call the items() method of the StreamList object |
| 536 | + * to return an array of Stream objects. |
| 537 | + */ |
| 538 | + |
| 539 | + public function listStreams($sessionId) |
| 540 | + { |
| 541 | + Validators::validateSessionIdBelongsToKey($sessionId, $this->apiKey); |
| 542 | + |
| 543 | + // make API call |
| 544 | + $streamListData = $this->client->listStreams($sessionId); |
| 545 | + return new StreamList($streamListData); |
| 546 | + |
| 547 | + } |
| 548 | + |
493 | 549 | /** |
494 | 550 | * Initiate an outgoing SIP call |
495 | 551 | * |
@@ -566,6 +622,52 @@ public function dial($sessionId, $token, $sipUri, $options=array()) |
566 | 622 | return new SipCall($sipJson); |
567 | 623 | } |
568 | 624 |
|
| 625 | + /** |
| 626 | + * Sends a signal to clients (or a specific client) connected to an OpenTok session. |
| 627 | + * |
| 628 | + * @param string $sessionId The OpenTok session ID where the signal will be sent. |
| 629 | + * |
| 630 | + * |
| 631 | + * @param array $payload This array defines the payload for the signal. This array includes the |
| 632 | + * following keys, of which type is optional: |
| 633 | + * |
| 634 | + * <ul> |
| 635 | + * |
| 636 | + * <li><code>'data'</code> (string) — The data string for the signal. You can send a maximum of 8kB.</li> |
| 637 | + * <li><code>'type'</code> (string) — (Optional) The type string for the signal. You can send a maximum of 128 characters, and only the following characters are allowed: A-Z, a-z, numbers (0-9), '-', '_', and '~'. </li> |
| 638 | + * |
| 639 | + * </ul> |
| 640 | + * |
| 641 | + * |
| 642 | + * @param string $connectionId An optional parameter used to send the signal to a specific connection in a session. |
| 643 | + */ |
| 644 | + public function signal($sessionId, $payload, $connectionId=null) |
| 645 | + { |
| 646 | + |
| 647 | + // unpack optional arguments (merging with default values) into named variables |
| 648 | + $defaults = array( |
| 649 | + 'type' => '', |
| 650 | + 'data' => '', |
| 651 | + ); |
| 652 | + |
| 653 | + $payload = array_merge($defaults, array_intersect_key($payload, $defaults)); |
| 654 | + list($type, $data) = array_values($payload); |
| 655 | + |
| 656 | + // validate arguments |
| 657 | + Validators::validateSessionIdBelongsToKey($sessionId, $this->apiKey); |
| 658 | + Validators::validateSignalPayload($payload); |
| 659 | + |
| 660 | + if (is_null($connectionId) || empty($connectionId)) { |
| 661 | + // make API call without connectionId |
| 662 | + $this->client->signal($sessionId, $payload); |
| 663 | + } else { |
| 664 | + Validators::validateConnectionId($connectionId); |
| 665 | + // make API call with connectionId |
| 666 | + $this->client->signal($sessionId, $payload, $connectionId); |
| 667 | + } |
| 668 | + |
| 669 | + } |
| 670 | + |
569 | 671 | /** @internal */ |
570 | 672 | private function _sign_string($string, $secret) |
571 | 673 | { |
|
0 commit comments