Changeset View
Changeset View
Standalone View
Standalone View
src/app/OpenVidu/Room.php
Show First 20 Lines • Show All 167 Lines • ▼ Show 20 Lines | public function deleteSession(): bool | ||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
* Returns metadata for every connection in a session. | |||||
* | |||||
* @return array Connections metadata, indexed by connection identifier | |||||
* @throws \Exception if session does not exist | |||||
*/ | |||||
public function getSessionConnections(): array | |||||
{ | |||||
if (!$this->session_id) { | |||||
throw new \Exception("The room session does not exist"); | |||||
} | |||||
return Connection::where('session_id', $this->session_id) | |||||
// Ignore screen sharing connection for now | |||||
->whereRaw("(role & " . self::ROLE_SCREEN . ") = 0") | |||||
->get() | |||||
->keyBy('id') | |||||
->map(function ($item) { | |||||
// For now we need only 'role' property, it might change in the future. | |||||
// Make sure to not return all metadata here as it might contain sensitive data. | |||||
return ['role' => $item->role]; | |||||
}) | |||||
->all(); | |||||
} | |||||
/** | |||||
* Create a OpenVidu session (connection) token | * Create a OpenVidu session (connection) token | ||||
* | * | ||||
* @param int $role User role (see self::ROLE_* constants) | * @param int $role User role (see self::ROLE_* constants) | ||||
* | * | ||||
* @return array|null Token data on success, NULL otherwise | * @return array|null Token data on success, NULL otherwise | ||||
* @throws \Exception if session does not exist | * @throws \Exception if session does not exist | ||||
*/ | */ | ||||
public function getSessionToken($role = self::ROLE_SUBSCRIBER): ?array | public function getSessionToken($role = self::ROLE_SUBSCRIBER): ?array | ||||
▲ Show 20 Lines • Show All 201 Lines • Show Last 20 Lines |