humanemulator.net — справка. Продукт, демо и покупка — на хуманэмулятор.рф | Демо | Купить | API | лог изменений

is_enable_web_rtc

is_enable_web_rtc(); - проверить разрешен или запрещен WebRTC в браузере.
Запретить или разрешить WebRTC можно командой enable_web_rtc

После отработки функция возвращает результат своей работы в скрипт :
  • true – разрешены
  • false – запрещены

    Пример использования
    <?php
    // Scenario: Check if WebRTC is enabled, disable it, then check again to demonstrate the is_enable_web_rtc function
    // Path to the init.php file for connecting to the XHE API
    $xhe_host = "localhost:7010";
    if (!isset($path)){
        // Path to the init.php file for connecting to the XHE API
        $path = "../../../Templates/init.php";
        // Including init.php grants access to all classes and functionality for working with the XHE API
        require($path);
    }
    
    // The following code demonstrates the usage of the is_enable_web_rtc function
    
    // First, check if WebRTC is currently enabled
    $webrtc_enabled = WEB::$browser->is_enable_web_rtc();
    echo "WebRTC currently enabled: " . ($webrtc_enabled ? "Yes" : "No") . "\n";
    
    // Disable WebRTC
    WEB::$browser->enable_web_rtc(false);
    
    // Check again after disabling
    $webrtc_enabled2 = WEB::$browser->is_enable_web_rtc();
    echo "\nWebRTC enabled after disabling: " . ($webrtc_enabled2 ? "Yes" : "No") . "\n";
    
    // Quit the application
    WINDOW::$app->quit();
    ?>
    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
    
    xhe_host = "127.0.0.1:7013"
    from xweb_human_emulator import *
    
    # Start
    echo("<hr> <font color = blue> browser.xxxxxxxxx </font> <hr>")
    
    # 1
    if len(sys.argv) == 1:
    echo("1.Disable Web RTC:")
    echo(browser.enable_web_rtc(false), "")
    echo(browser.is_enable_web_rtc(), "<br>")
    echo("Restart to apply the setting.")
    sleep(5)
    app.restart(__ file __, "1")
    
    if len(sys.argv) == 2:
    # 2
    echo("2.Let's go to the WebSocket test page:")
    echo(browser.navigate("https://browserleaks.com/webrtc"), "<br>")
    sleep(5)
    # 3
    echo("3.Enable Web RTC:")
    echo(browser.enable_web_rtc(true), "")
    echo(browser.is_enable_web_rtc(), "<br>")
    echo("Restart to apply the setting.")
    sleep(5)
    app.restart(__ file __, "1 2")
    
    # 4
    echo("4.Let's go to the Web RTC test page:")
    echo(browser.navigate("https://browserleaks.com/webrtc", false), "<br>")
    
    # end
    echo("<hr> <br>")
    
    # Quit
    app.quit()
    #region using
    
    using System;
    using System.Diagnostics;
    using System.Collections.Generic;
    using System.Linq;
    using System.IO;
    using System.Text;
    using System.Threading;
    
    using XHE;
    using XHE.XHE_DOM;
    using XHE.XHE_System;
    using XHE.XHE_Window;
    using XHE.XHE_Web;
    
    #endregion
    
     class Program: XHEScript
     {
    static void Main(string [] args)
    {
    //init XHE
    
    server = "127.0.0.1:7022";
    InitXHE();
    
    //Start
    
    echo("<hr> <font color = blue> browser.enable_web_rtc </font> <hr>");
    
    //1
    
    if(args.Length == 0)
    {
    echo("1.Disable Web RTC:");
    echo(browser.enable_web_rtc(false) + "");
    echo(browser.is_enable_web_rtc() + "<br>");
    
    echo("Restart to apply the setting.");
    sleep(5);
    app.restart(debug.get_cur_script_path(), "1");
    }
    
    if(args.Length == 1)
    {
    //2
    
    echo("2.Let's go to the Web RTC test page:");
    echo(browser.navigate("https://browserleaks.com/webrtc/") + "<br>");
    
    
    sleep(5);
    
    //3
    
    echo("3.Allow Web Socket:");
    echo(browser.enable_web_rtc(true) + "");
    echo(browser.is_enable_web_rtc() + "<br>");
    
    echo("Restart to apply the setting.");
    sleep(5);
    app.restart(debug.get_cur_script_path(), "1 2");
    }
    
    //4
    
    echo("4.Let's go to the Web RTC test page:");
    echo(browser.navigate("https://browserleaks.com/webrtc/", false) + "<br>");
    
    
    //end
    
    echo("<hr> <br>");
    
    app.quit();
    }
    }
    //connect the object to control the emulator, if not already connected
    
    xhe_host = "127.0.0.1:7012";
    echo = require("../../../Templates JS/xweb_human_emulator.js");
    
    //Start
    
    echo("<hr> <font color = blue> browser.enable_web_socket </font> <hr>");
    
    //command line arguments
    
    var argv = process.argv;
    
    //1
    
    if(argv.length == 2)
    {
    echo("1.Disable Web RTC:");
    echo(browser.enable_web_rtc(false) + "");
    echo(browser.is_enable_web_rtc() + "<br>");
    
    echo("Restart to apply the setting.");
    browser.sleep(5);
    app.restart(debug.get_cur_script_path(), "1");
    }
    
    if(argv.length == 3)
    {
    //2
    
    echo("2.Let's go to the Web RTC test page:");
    echo(browser.navigate("https://browserleaks.com/webrtc") + "<br>");
    
    
    browser.sleep(5);
    
    //3
    
    echo("3.Enable Web RTC:");
    echo(browser.enable_web_rtc(true) + "");
    echo(browser.is_enable_web_rtc() + "<br>");
    
    echo("Restart to apply the setting.");
    browser.sleep(5);
    app.restart(debug.get_cur_script_path(), "1 2");
    }
    
    //4
    
    echo("4.Let's go to the Web RTC test page:");
    echo(browser.navigate("https://browserleaks.com/webrtc", false) + "<br>");
    
    
    //end
    
    echo("<hr> <br>");
    
    //Quit
    
    app.quit();

    =============================================
    Browser    Объекты    DOM  System  Vision  Web  Window        
    =============================================
    если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
    .