Example #1
0
 /**
  * @param array $args - request arguments, i.e. $_POST
  * @param RTCStore $store
  * @return array [
  *  int $statusCode, 
  *  string $statusMsg, 
  *  RTCConnection $connection, 
  *  string[] $errors
  * ]
  * @throws \Exception
  */
 public static function signal(array $args, RTCStore $store = null)
 {
     $call = '';
     $name = '';
     $connection = '';
     extract($args, EXTR_IF_EXISTS);
     if ($store == null) {
         $store = RTCStore::instance();
     }
     $signal = new Controller($store);
     switch ($call) {
         case self::CALL_OFFER:
             $signal->offer($name, $connection);
             break;
         case self::CALL_ANSWER:
             $signal->answer($name, $connection);
             break;
         case self::CALL_FETCH:
             $signal->fetch($name);
             break;
         default:
             $signal->error('invalid call', ['call' => "'call' parameter must be one of [\"" . implode('", "', self::getCalls()) . '"].']);
             break;
     }
     return $signal->getCallResult();
 }
 /**
  * @dataProvider answerProvider
  * @param string $name
  * @param string $connJson
  * @param integer $code
  * @param Connection|null $RTCconn
  */
 public function testAnswer($name, $connJson, $code, Connection $RTCconn = null)
 {
     $this->rtcStore->method('getOffer')->willReturn($RTCconn);
     $this->controller->answer($name, $connJson);
     list($_code, $message, $connection, $errors) = $this->controller->getCallResult();
     $this->assertEquals($code, $_code, sprintf("Expected result code %d, received %d (%d).", $code, $_code, $message));
     $this->assertSame($connection, $RTCconn);
 }