Beispiel #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 fetchProvider
  * @param string $name
  * @param Connection $connection
  * @param integer $code
  */
 public function testFetch($name, Connection $connection = null, $code)
 {
     $this->rtcStore->method('getOffer')->willReturn($connection);
     $this->controller->fetch($name);
     list($_code, $message, $_connection, $errors) = $this->controller->getCallResult();
     $this->assertEquals($code, $_code);
     $this->assertSame($connection, $_connection);
 }