19declare(strict_types=1);
37 if ($use_cache && self::$connection_status !==
null) {
42 self::$connection_status = $connector->isServerAlive();
50 $this->
settings->getURL(
'Heartbeat'),
65 $responseObject = json_decode(
$response,
false, 512, JSON_THROW_ON_ERROR);
67 return $responseObject instanceof stdClass && ((
int) $responseObject->status) === 200;
77 $this->
settings->getURL(
'Connect', (
string) $scope) .
'/' . $userId
87 $credentials = $this->
settings->getAuthKey() .
':' . $this->
settings->getAuthSecret();
89 "Connection: close\r\n" .
90 "Content-Type: application/json; charset=utf-8\r\n" .
91 "Authorization: Basic " . base64_encode($credentials);
104 if (is_array($stream_context_params)) {
105 $ctx = array_merge_recursive($ctx, $stream_context_params);
108 set_error_handler(
static function (
int $severity,
string $message,
string $file,
int $line): never {
109 throw new ErrorException(
$message, $severity, $severity, $file, $line);
114 }
catch (Exception
$e) {
117 restore_error_handler();
129 $this->
settings->getURL(
'CreatePrivateRoom', (
string) $scope) .
130 '/' . $user .
'/' . rawurlencode($title)
149 $this->
settings->getURL(
'EnterPrivateRoom', (
string) $scope) .
'/' . $user
159 $this->
settings->getURL(
'ClearMessages', (
string) $scope) .
'/' . $user
177 $this->
settings->getURL(
'LeavePrivateRoom', (
string) $scope) .
'/' . $user
186 return $this->
kick($scope, $user);
197 $this->
settings->getURL(
'Kick', (
string) $scope) .
'/' . $user
207 $this->
settings->getURL(
'Ban', (
string) $scope) .
'/' . $user
213 return $this->settings;
222 $this->
settings->getURL(
'InvitePrivateRoom', (
string) $scope) .
223 '/' . $user .
'/' . $invited_id
232 $query = http_build_query([
'message' =>
$message]);
235 $this->
settings->getURL(
'UserConfigChange',
null) .
'?' . $query
static getDefaultConfiguration()
Instantiates and returns ilChatroomAdmin object using instance_id and settings from settingsTable.
Class ilChatroomServerConnector.
sendBan(int $scope, int $user)
kick(int $scope, int $user)
Returns kick URL Creates kick URL using given $scope and $query and returns it.
static bool $connection_status
sendClearMessages(int $scope, int $user)
connect(int $scope, int $userId)
Creates connect URL using given $scope and $userId and returns it.
sendCreatePrivateRoom(int $scope, int $user, string $title)
file_get_contents(string $url, ?array $stream_context_params=null)
sendLeavePrivateRoom(int $scope, int $user)
leavePrivateRoom(int $scope, int $user)
__construct(private readonly ilChatroomServerSettings $settings)
sendUserConfigChange(string $message)
sendEnterPrivateRoom(int $scope, int $user)
sendInviteToPrivateRoom(int $scope, int $user, int $invited_id)
sendKick(int $scope, int $user)
enterPrivateRoom(int $scope, int $user)
static checkServerConnection(bool $use_cache=true)
Class ilChatroomServerSettings.
static getLogger(string $a_component_id)
Get component logger.