Skip to content

Commit

Permalink
Improve: Accept channels array on connection token generation (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliustm authored Mar 12, 2020
1 parent 82fd99e commit c92e5ba
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,16 @@ public function info()
* @param array $info
* @return string
*/
public function generateConnectionToken($userId = '', $exp = 0, $info = array())
public function generateConnectionToken($userId = '', $exp = 0, $info = array(), $channels = array())
{
$header = array('typ' => 'JWT', 'alg' => 'HS256');
$payload = array('sub' => (string) $userId);
if (!empty($info)) {
$payload['info'] = $info;
}
if (!empty($channels)) {
$payload['channels'] = $channels;
}
if ($exp) {
$payload['exp'] = $exp;
}
Expand Down Expand Up @@ -329,7 +332,7 @@ public function generatePrivateChannelToken($client, $channel, $exp = 0, $info =
/*
* Function added for backward compatibility with PHP version < 5.5
*/

public function _json_last_error_msg() {
if (function_exists('json_last_error_msg')) {
return json_last_error_msg();
Expand Down

0 comments on commit c92e5ba

Please sign in to comment.