/** * @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); }
/** * @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(); }
$df_autoload = '/../notweb/df_autoload.php'; if (isset($_SERVER['df_autoload'])) { $df_autoload = $_SERVER['df_autoload']; } include_once __DIR__ . '/' . $df_autoload; $errors = []; $status = 'success'; $statusCode = 200; $rtcConnection = null; function df_return() { global $status, $statusCode, $errors, $rtcConnection; header("Content-Type: application/json"); http_response_code($statusCode); echo json_encode(array('result' => $status, 'errors' => $errors, 'connection' => $rtcConnection)); error_log('returning datafestivus result'); exit; } set_exception_handler(function (Exception $ex) { global $status, $statusCode, $errors; $statusCode = 500; $status = 'error'; $errors['server'] = $ex->getMessage(); error_log('data festivus exception: ' . var_export($ex, true)); df_return(); }); register_shutdown_function('df_return'); $store = \DataFestivus\RTCStore\RTCStore::instance(); list($statusCode, $status, $rtcConnection) = \DataFestivus\Controller::signal($_POST, $store); exit;