Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
BitrixCall.php
1
<?php
2
3
namespace
Bitrix\Im\V2\Call
;
4
5
use
Bitrix\Im\Call\Call
;
6
use
Bitrix\Im\Call\Util
;
7
use
Bitrix\Main\Security\Random
;
8
use
Bitrix\Main\Web\JWT
;
9
10
class
BitrixCall
extends
Call
11
{
12
protected
function
initCall
()
13
{
14
if
(!$this->endpoint)
15
{
16
$this->uuid = Util::generateUUID();
17
$this->secretKey = Random::getString(10,
true
);
18
19
$callControllerClient =
new
ControllerClient
();
20
$createResult = $callControllerClient->createCall(
21
$this->
getUuid
(),
22
$this->
getSecretKey
(),
23
$this->
getInitiatorId
()
24
);
25
26
if
(!$createResult->isSuccess())
27
{
28
$this->
finish
();
29
30
throw
new \Exception($createResult->getErrorMessages()[0]);
31
}
32
$callData = $createResult->getData();
33
if
(!$callData[
'endpoint'
])
34
{
35
$this->
finish
();
36
37
throw
new \Exception(
'Empty endpoint'
);
38
}
39
40
$this->
setEndpoint
($callData[
'endpoint'
]);
41
$this->
save
();
42
}
43
}
44
45
protected
function
generateJwt
(
int
$userId): string
46
{
47
return
JWT::encode
(
48
[
49
'uuid'
=> $this->
getUuid
(),
50
'userId'
=> (
string
)$userId,
51
],
52
$this->
getSecretKey
()
53
);
54
}
55
56
public
function
getConnectionData
(
int
$userId): array
57
{
58
return
[
59
'endpoint'
=> $this->endpoint ?:
null
,
60
'jwt'
=> $this->
generateJwt
($userId),
61
];
62
}
63
64
public
function
inviteUsers
(
int
$senderId, array $toUserIds, $isLegacyMobile, $video =
false
, $sendPush =
true
)
65
{
66
foreach
($toUserIds as $toUserId)
67
{
68
$this->
getSignaling
()->sendInviteToUser(
69
$senderId,
70
$toUserId,
71
$toUserIds,
72
$isLegacyMobile,
73
$video,
74
$sendPush
75
);
76
}
77
}
78
79
public
function
getMaxUsers
()
80
{
81
return
static::getMaxCallServerParticipants();
82
}
83
}
Bitrix\Im\Call\Call
Definition
call.php:22
Bitrix\Im\Call\Call\getSecretKey
getSecretKey()
Definition
call.php:275
Bitrix\Im\Call\Call\getUuid
getUuid()
Definition
call.php:270
Bitrix\Im\Call\Call\getSignaling
getSignaling()
Definition
call.php:198
Bitrix\Im\Call\Call\finish
finish()
Definition
call.php:350
Bitrix\Im\Call\Call\setEndpoint
setEndpoint($endpoint)
Definition
call.php:345
Bitrix\Im\Call\Call\getInitiatorId
getInitiatorId()
Definition
call.php:90
Bitrix\Im\Call\Call\save
save()
Definition
call.php:408
Bitrix\Im\Call\Util
Definition
util.php:6
Bitrix\Im\V2\Call\BitrixCall
Definition
BitrixCall.php:11
Bitrix\Im\V2\Call\BitrixCall\inviteUsers
inviteUsers(int $senderId, array $toUserIds, $isLegacyMobile, $video=false, $sendPush=true)
Definition
BitrixCall.php:64
Bitrix\Im\V2\Call\BitrixCall\getMaxUsers
getMaxUsers()
Definition
BitrixCall.php:79
Bitrix\Im\V2\Call\BitrixCall\generateJwt
generateJwt(int $userId)
Definition
BitrixCall.php:45
Bitrix\Im\V2\Call\BitrixCall\initCall
initCall()
Definition
BitrixCall.php:12
Bitrix\Im\V2\Call\BitrixCall\getConnectionData
getConnectionData(int $userId)
Definition
BitrixCall.php:56
Bitrix\Im\V2\Call\ControllerClient
Definition
ControllerClient.php:8
Bitrix\Main\Security\Random
Definition
random.php:6
Bitrix\Main\Web\JWT
Definition
jwt.php:23
Bitrix\Main\Web\JWT\encode
static encode($payload, $key, $alg='HS256', $keyId=null, $head=null)
Definition
jwt.php:161
Bitrix\Im\V2\Call
Definition
BitrixCall.php:3
modules
im
lib
V2
Call
BitrixCall.php
Создано системой
1.10.0