I have video rooms (via Twig) being created on my page when the users want to start a video chat between each other. When they leave the room, the room is being deleted after a period of time and they have to create a new room in order to start talking again. The problem is that I have a notification system that leaves the old URL in your notifications and when user tries to click that again after some period of time he receives a 404.
I don't want any superb solution at this point, I just want to move the user to custom twig template if the room is no longer available - let's say. 404video.html
Thanks for any help!
/**
* @Route("/video/join/{room_name}", name="videochat_join")
*
* @param $room_name
*
* @return RedirectResponse|Response
*
* @throws TwilioExceptionsConfigurationException
* @throws TwilioExceptionsTwilioException
*/
public function joinVideo($room_name)
{
$user = $this->getCurrentUser();
$twilio = new Client(getenv('TWILIO_API_KEY'), getenv('TWILIO_API_SECRET'));
$room = $twilio->video->v1->rooms($room_name)->fetch();
$roomSid = $room->sid;
$token = new AccessToken(getenv('TWILIO_ACCOUNT_SID'), getenv('TWILIO_API_KEY'), getenv('TWILIO_API_SECRET'), 3600, $user->getEmail());
$videoGrant = new VideoGrant();
$videoGrant->setRoom($room_name);
$token->addGrant($videoGrant);
return $this->render('chat/video_join.html.twig', [
'roomSid' => $roomSid,
'roomName' => $room_name,
'accessToken' => $token->toJWT(),
]);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…