1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
ControllerClient.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Call;
4
5use Bitrix\Main\Result;
6use Bitrix\Main\Config\Option;
7use Bitrix\Main\Service\MicroService\BaseSender;
8use Bitrix\Im\Call\Call;
9
11{
12 private const SERVICE_MAP = [
13 'ru' => 'https://videocalls.bitrix.info',
14 'eu' => 'https://videocalls-de.bitrix.info',
15 'us' => 'https://videocalls-us.bitrix.info',
16 ];
17 private const REGION_RU = ['ru', 'by', 'kz'];
18 private const REGION_EU = ['de', 'eu', 'fr', 'it', 'pl', 'tr', 'uk'];
19
20 private array $httpClientParameters = [];
21
28 public function getEndpoint(string $region): string
29 {
30 $endpoint = Option::get('im', 'call_server_url');
31
32 if (empty($endpoint))
33 {
34 if (in_array($region, self::REGION_RU, true))
35 {
36 $endpoint = self::SERVICE_MAP['ru'];
37 }
38 elseif (in_array($region, self::REGION_EU, true))
39 {
40 $endpoint = self::SERVICE_MAP['eu'];
41 }
42 else
43 {
44 $endpoint = self::SERVICE_MAP['us'];
45 }
46 }
47 elseif (!(mb_strpos($endpoint, 'https://') === 0 || mb_strpos($endpoint, 'http://') === 0))
48 {
49 $endpoint = 'https://' . $endpoint;
50 }
51
52 return $endpoint;
53 }
54
55
61 protected function getServiceUrl(): string
62 {
63 $region = \Bitrix\Main\Application::getInstance()->getLicense()->getRegion() ?: 'ru';
64
65 return $this->getEndpoint($region);
66 }
67
73 public function createCall(Call $call): Result
74 {
75 $action = 'callcontroller.InternalApi.createCall';
76 $data = [
77 'callType' => 'call',
78 'roomType' => $call->getType(),
79 'uuid' => $call->getUuid(),
80 'initiatorUserId' => $call->getInitiatorId(),
81 'callId' => $call->getId(),
82 'version' => \Bitrix\Main\ModuleManager::getVersion('call'),
83 'usersCount' => count($call->getUsers()),
84 ];
85
86 if ($call instanceof ConferenceCall)
87 {
88 $data['callType'] = 'conference';
89 }
90
91 if ($call instanceof PlainCall)
92 {
93 $action = 'callcontroller.InternalApi.createPlain';
94 $data['callType'] = 'plain';
95 $this->httpClientParameters = [
96 'waitResponse' => false,
97 'socketTimeout' => 5,
98 'streamTimeout' => 5,
99 ];
100 }
101 else
102 {
103 $data = array_merge($data, [
104 'secretKey' => $call->getSecretKey(),
105 'maxParticipants' => \Bitrix\Im\Call\Call::getMaxCallServerParticipants(),
106 ]);
107 $this->httpClientParameters = [
108 'waitResponse' => true,
109 'socketTimeout' => 10,
110 'streamTimeout' => 15,
111 ];
112 }
113
114 return $this->performRequest($action, $data);
115 }
116
122 public function finishCall(Call $call): Result
123 {
124 $data = [
125 'uuid' => $call->getUuid()
126 ];
127
128 $this->httpClientParameters = [
129 'waitResponse' => false,
130 'socketTimeout' => 5,
131 'streamTimeout' => 5,
132 ];
133
134 $action = 'callcontroller.InternalApi.finishCall';
135 if ($call instanceof ConferenceCall)
136 {
137 $data['callType'] = 'conference';
138 }
139 if ($call instanceof PlainCall)
140 {
141 $action = 'callcontroller.InternalApi.finishPlain';
142 $data['callType'] = 'plain';
143 }
144
145 return $this->performRequest($action, $data);
146 }
147
149 {
150 return array_merge(parent::getHttpClientParameters(), $this->httpClientParameters);
151 }
152}
Определения call.php:24
getSecretKey()
Определения call.php:490
getUsers()
Определения call.php:227
getId()
Определения call.php:102
getUuid()
Определения call.php:485
getType()
Определения call.php:110
getInitiatorId()
Определения call.php:134
getEndpoint(string $region)
Определения ControllerClient.php:28
static getInstance()
Определения application.php:98
static getVersion($moduleName)
Определения modulemanager.php:89
performRequest($action, array $parameters=[])
Определения basesender.php:25
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$region
Определения .description.php:13
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$action
Определения file_dialog.php:21