else if ($_POST['COMMAND'] == 'wait') { CIMCall::Wait(Array( 'CHAT_ID' => $chatId, 'USER_ID' => $userId, )); } else if ($_POST['COMMAND'] == 'reconnect') { CIMCall::Command($chatId, $_POST['RECIPIENT_ID'], 'reconnect', Array()); } else if ($_POST['COMMAND'] == 'answer') { CIMCall::Answer(Array( 'CHAT_ID' => $chatId, 'USER_ID' => $userId, 'CALL_TO_GROUP' => $_POST['CALL_TO_GROUP'] == 'Y', )); } else if ($_POST['COMMAND'] == 'start') { CIMCall::Start(Array( 'CHAT_ID' => $chatId, 'USER_ID' => $userId, 'RECIPIENT_ID' => intval($_POST['RECIPIENT_ID']), 'CALL_TO_GROUP' => $_POST['CALL_TO_GROUP'] == 'Y', )); } else if (in_array($_POST['COMMAND'], Array(IM_CALL_END_DECLINE, IM_CALL_END_TIMEOUT, IM_CALL_END_BUSY, IM_CALL_END_OFFLINE, IM_CALL_END_ACCESS))) { $arParams = Array(
if ($e = $GLOBALS["APPLICATION"]->GetException()) { $errorMessage = $e->GetString(); } echo CUtil::PhpToJsObject(array('ERROR' => $errorMessage)); } else { echo CUtil::PhpToJsObject(array('CHAT_ID' => $arCallData['CHAT_ID'], 'USERS' => $arCallData['USER_DATA']['USERS'], 'USERS_CONNECT' => isset($arCallData['USERS_CONNECT']) ? $arCallData['USERS_CONNECT'] : array(), 'HR_PHOTO' => $arCallData['USER_DATA']['HR_PHOTO'], 'CALL_VIDEO' => $arCallData['STATUS_TYPE'] == IM_CALL_VIDEO, 'CALL_TO_GROUP' => $arCallData['CALL_TO_GROUP'], 'CALL_ENABLED' => $arCallData['STATUS_TYPE'] != IM_CALL_NONE, 'ERROR' => $errorMessage)); } } else { if ($_POST['COMMAND'] == 'wait') { CIMCall::Wait(array('CHAT_ID' => $chatId, 'USER_ID' => $userId)); } else { if ($_POST['COMMAND'] == 'reconnect') { CIMCall::Command($chatId, $_POST['RECIPIENT_ID'], 'reconnect', array()); } else { if ($_POST['COMMAND'] == 'answer') { CIMCall::Answer(array('CHAT_ID' => $chatId, 'USER_ID' => $userId, 'CALL_TO_GROUP' => $_POST['CALL_TO_GROUP'] == 'Y', 'MOBILE' => $_POST['MOBILE'])); } else { if ($_POST['COMMAND'] == 'start') { CIMCall::Start(array('CHAT_ID' => $chatId, 'USER_ID' => $userId, 'RECIPIENT_ID' => intval($_POST['RECIPIENT_ID']), 'CALL_TO_GROUP' => $_POST['CALL_TO_GROUP'] == 'Y')); } else { if (in_array($_POST['COMMAND'], array(IM_CALL_END_DECLINE, IM_CALL_END_TIMEOUT, IM_CALL_END_BUSY, IM_CALL_END_OFFLINE, IM_CALL_END_ACCESS))) { $arParams = array('CHAT_ID' => $chatId, 'USER_ID' => $userId, 'RECIPIENT_ID' => intval($_POST['RECIPIENT_ID']), 'REASON' => $_POST['COMMAND']); $_POST['PARAMS'] = CUtil::JsObjectToPhp($_POST['PARAMS']); if (isset($_POST['VIDEO'])) { $arParams['VIDEO'] = $_POST['VIDEO']; } if (isset($_POST['PARAMS']['ACTIVE'])) { $arParams['ACTIVE'] = $_POST['PARAMS']['ACTIVE']; } if (isset($_POST['PARAMS']['INITIATOR'])) { $arParams['INITIATOR'] = $_POST['PARAMS']['INITIATOR'];