在我的iOS应用程序中,我正在使用TokBox实现一个私有视频聊天功能。我需要为每个私人聊天创建一个随机会话ID,使用Server,我很难理解如何做到这一点。
我成功地完成了文档“learning-opentok-php”中列出的所有步骤,这些步骤可以在opentok 页面上找到。我将我的OpenTok应用程序链接到Heroku,并配置了“web/index.php”,以便在浏览器上显示静态的“SESSION_ID”和“TOKEN_ID”。
正如文档中解释的那样,“示例应用程序”使用单个会话ID,并且不为每个调用生成新的会话ID。请有人提供一些例子或建议,如何配置我的应用程序,以生成每次不同的会话ID?
发布于 2016-05-24 11:56:47
$app->get('/', function () use ($app) {
// If a sessionId has already been created, retrieve it from the cache
$sessionId = $app->cache->getOrCreate('sessionId', array(), function() use ($app) {
// If the sessionId hasn't been created, create it now and store it
$session = $app->opentok->createSession();
return $session->getSessionId();
});
// Generate a fresh token for this client
$token = $app->opentok->generateToken($sessionId);
$app->render('helloworld.php', array(
'apiKey' => $app->apiKey,
'sessionId' => $sessionId,
'token' => $token
));( });尝试以下代码
每次新的sessionId在服务器上发送请求。
https://stackoverflow.com/questions/35808535
复制相似问题