From 4067e458bbb8b23bc206e4f4bc1416f2cb4124da Mon Sep 17 00:00:00 2001 From: jibon Costa Date: Wed, 4 May 2022 22:56:30 +0600 Subject: [PATCH] few updates --- examples/plugNmeetConnect.php | 5 +++-- examples/quickJoin.php | 7 +++++-- src/Parameters/GenerateJoinTokenParameters.php | 4 ++-- src/Responses/BaseResponse.php | 8 +++++++- src/Responses/GenerateJoinTokenResponse.php | 2 +- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/examples/plugNmeetConnect.php b/examples/plugNmeetConnect.php index 7d91616..9aa105b 100755 --- a/examples/plugNmeetConnect.php +++ b/examples/plugNmeetConnect.php @@ -174,7 +174,7 @@ public function createRoom(string $roomId, string $roomTitle, string $welcomeMes if (isset($roomMetadata['default_lock_settings'])) { $defaultLocks = $roomMetadata['default_lock_settings']; $lockSettings = new LockSettingsParameters(); - + if (isset($defaultLocks['lock_microphone'])) { $lockSettings->setLockMicrophone($defaultLocks['lock_microphone']); } @@ -220,13 +220,14 @@ public function createRoom(string $roomId, string $roomTitle, string $welcomeMes * @param bool $isAdmin * @return GenerateJoinTokenResponse */ - public function getJoinToken(string $roomId, string $name, string $userId, bool $isAdmin): GenerateJoinTokenResponse + public function getJoinToken(string $roomId, string $name, string $userId, bool $isAdmin, bool $isHidden = false): GenerateJoinTokenResponse { $generateJoinTokenParameters = new GenerateJoinTokenParameters(); $generateJoinTokenParameters->setRoomId($roomId); $generateJoinTokenParameters->setName($name); $generateJoinTokenParameters->setUserId($userId); $generateJoinTokenParameters->setIsAdmin($isAdmin); + $generateJoinTokenParameters->setIsHidden($isHidden); return $this->plugnmeet->getJoinToken($generateJoinTokenParameters); } diff --git a/examples/quickJoin.php b/examples/quickJoin.php index ee300c9..4bb17fd 100644 --- a/examples/quickJoin.php +++ b/examples/quickJoin.php @@ -35,6 +35,7 @@ $max_participants = 0; // value 0 means no limit (unlimited) $user_full_name = "Your name"; $userId = "Your-Unique-User-Id"; // must be unique for each user. +$isAdmin = true; $roomMetadata = array( "room_features" => array( @@ -98,9 +99,11 @@ if ($isRoomActive && $output->status) { try { - $join = $connect->getJoinToken($roomId, $user_full_name, $userId, true); + $join = $connect->getJoinToken($roomId, $user_full_name, $userId, $isAdmin); - $output->url = "
" . $config->plugnmeet_server_url . "?access_token=" . $join->getToken(); + if ($join->getStatus()) { + $output->url = "
" . $config->plugnmeet_server_url . "?access_token=" . $join->getToken(); + } $output->status = $join->getStatus(); $output->msg = $join->getResponseMsg(); } catch (Exception $e) { diff --git a/src/Parameters/GenerateJoinTokenParameters.php b/src/Parameters/GenerateJoinTokenParameters.php index 63c75ab..de52790 100644 --- a/src/Parameters/GenerateJoinTokenParameters.php +++ b/src/Parameters/GenerateJoinTokenParameters.php @@ -44,11 +44,11 @@ class GenerateJoinTokenParameters /** * @var bool */ - protected $isAdmin; + protected $isAdmin = false; /** * @var bool */ - protected $isHidden; + protected $isHidden = false; /** * @var UserMetadataParameters diff --git a/src/Responses/BaseResponse.php b/src/Responses/BaseResponse.php index 4c89f5b..6697231 100644 --- a/src/Responses/BaseResponse.php +++ b/src/Responses/BaseResponse.php @@ -64,6 +64,12 @@ public function getStatus(): bool */ public function getResponseMsg(): string { - return $this->rawResponse->msg; + $msg = $this->rawResponse->msg; + + if (is_array($msg)) { + return json_encode($msg); + } + + return $msg; } } diff --git a/src/Responses/GenerateJoinTokenResponse.php b/src/Responses/GenerateJoinTokenResponse.php index edf7763..aadccf3 100644 --- a/src/Responses/GenerateJoinTokenResponse.php +++ b/src/Responses/GenerateJoinTokenResponse.php @@ -33,6 +33,6 @@ class GenerateJoinTokenResponse extends BaseResponse */ public function getToken(): string { - return $this->rawResponse->token; + return $this->rawResponse->token ?? ""; } }