Logo ROOT  
Reference Guide
ROOT::Experimental::RWebWindowsManager Class Reference

Central instance to create and show web-based windows like Canvas or FitPanel.

Manager responsible to creating THttpServer instance, which is used for RWebWindow's communication with clients.

Method RWebWindows::Show() used to show window in specified location.

Definition at line 37 of file RWebWindowsManager.hxx.

Public Member Functions

 RWebWindowsManager ()
 window manager constructor Required here for correct usage of unique_ptr<THttpServer> More...
 
 ~RWebWindowsManager ()
 window manager destructor Required here for correct usage of unique_ptr<THttpServer> More...
 
std::shared_ptr< RWebWindowCreateWindow ()
 Creates new window To show window, RWebWindow::Show() have to be called. More...
 
THttpServerGetServer () const
 Returns THttpServer instance. More...
 
std::string GetServerAddr () const
 Returns http address of the server, empty string when not available. More...
 
void SetShowCallback (WebWindowShowCallback_t func)
 Assign show callback which can catch window showing, used by RBrowser. More...
 
void Terminate ()
 Terminate http server and ROOT application. More...
 

Static Public Member Functions

static void AssignMainThrd ()
 Re-assigns main thread id Normally main thread id recognized at the moment when library is loaded It supposed to be a thread where gApplication->Run() will be called If application runs in separate thread, one have to call this method to let RWebWindowsManager correctly recognize such situation. More...
 
static std::shared_ptr< RWebWindowsManager > & Instance ()
 Returns default window manager Used to display all standard ROOT elements like TCanvas or TFitPanel. More...
 
static bool IsMainThrd ()
 Returns true when called from main process Main process recognized at the moment when library is loaded It supposed to be a thread where gApplication->Run() will be called If application runs in separate thread, one have to use AssignMainThrd() method to let RWebWindowsManager correctly recognize such situation. More...
 

Private Member Functions

void AssignWindowThreadId (RWebWindow &win)
 Assign thread id for window Required in case of external process events. More...
 
bool CreateServer (bool with_http=false)
 Creates http server, if required - with real http engine (civetweb) One could configure concrete HTTP port, which should be used for the server, provide following entry in rootrc file: More...
 
float GetLaunchTmout () const
 Returns timeout for launching new browser process. More...
 
std::string GetUrl (const RWebWindow &win, bool remote=false)
 Provide URL address to access specified window from inside or from remote. More...
 
bool IsUseHttpThread () const
 Returns true if http server use special thread for requests processing (default off) More...
 
bool IsUseSenderThreads () const
 Returns true if extra threads to send data via websockets will be used (default off) More...
 
unsigned ShowWindow (RWebWindow &win, const RWebDisplayArgs &args)
 Show window in specified location, see Show() method for more details. More...
 
void Unregister (RWebWindow &win)
 Release all references to specified window Called from RWebWindow destructor. More...
 
int WaitFor (RWebWindow &win, WebWindowWaitFunc_t check, bool timed=false, double tm=-1)
 Waits until provided check function or lambdas returns non-zero value Regularly calls WebWindow::Sync() method to let run event loop If call from the main thread, runs system events processing Check function has following signature: int func(double spent_tm) Parameter spent_tm is time in seconds, which already spent inside function Waiting will be continued, if function returns zero. More...
 

Private Attributes

std::string fAddr
 ! HTTP address of the server More...
 
std::unique_ptr< TExecfAssgnExec
 ! special exec to assign thread id via ProcessEvents More...
 
bool fExternalProcessEvents {false}
 ! indicate that there are external process events engine More...
 
unsigned fIdCnt {0}
 ! counter for identifiers More...
 
float fLaunchTmout {30.}
 ! timeout in seconds to start browser process, default 30s More...
 
std::recursive_mutex fMutex
 ! main mutex, used for window creations More...
 
std::unique_ptr< THttpServerfServer
 ! central communication with the all used displays More...
 
WebWindowShowCallback_t fShowCallback
 ! function called for each RWebWindow::Show call More...
 
bool fUseHttpThrd {false}
 ! use special thread for THttpServer More...
 
bool fUseSenderThreads {false}
 ! use extra threads for sending data from RWebWindow to clients More...
 

Friends

class RWebWindow
 

#include <ROOT/RWebWindowsManager.hxx>

Constructor & Destructor Documentation

◆ RWebWindowsManager()

RWebWindowsManager::RWebWindowsManager ( )

window manager constructor Required here for correct usage of unique_ptr<THttpServer>

Definition at line 121 of file RWebWindowsManager.cxx.

◆ ~RWebWindowsManager()

RWebWindowsManager::~RWebWindowsManager ( )

window manager destructor Required here for correct usage of unique_ptr<THttpServer>

Definition at line 135 of file RWebWindowsManager.cxx.

Member Function Documentation

◆ AssignMainThrd()

void RWebWindowsManager::AssignMainThrd ( )
static

Re-assigns main thread id Normally main thread id recognized at the moment when library is loaded It supposed to be a thread where gApplication->Run() will be called If application runs in separate thread, one have to call this method to let RWebWindowsManager correctly recognize such situation.

Definition at line 111 of file RWebWindowsManager.cxx.

◆ AssignWindowThreadId()

void RWebWindowsManager::AssignWindowThreadId ( RWebWindow win)
private

Assign thread id for window Required in case of external process events.

Definition at line 147 of file RWebWindowsManager.cxx.

◆ CreateServer()

bool RWebWindowsManager::CreateServer ( bool  with_http = false)
private

Creates http server, if required - with real http engine (civetweb) One could configure concrete HTTP port, which should be used for the server, provide following entry in rootrc file:

 WebGui.HttpPort: 8088

or specify range of http ports, which can be used:

 WebGui.HttpPortMin: 8800
 WebGui.HttpPortMax: 9800

By default range [8800..9800] is used

One also can bind HTTP server socket to loopback address, In that case only connection from localhost will be available:

 WebGui.HttpLoopback: yes

Or one could specify hostname which should be used for binding of server socket

 WebGui.HttpBind: hostname | ipaddress

To use secured protocol, following parameter should be specified

 WebGui.UseHttps: yes
 WebGui.ServerCert: sertificate_filename.pem

All incoming requests processed in THttpServer in timer handler with 10 ms timeout. One may decrease value to improve latency or increase value to minimize CPU load

 WebGui.HttpTimer: 10

To processing incoming http requests and websockets, THttpServer allocate 10 threads One have to increase this number if more simultaneous connections are expected:

 WebGui.HttpThrds: 10

One also can configure usage of special thread of processing of http server requests

 WebGui.HttpThrd: no

Extra threads can be used to send data to different clients via websocket (default no)

 WebGui.SenderThrds: no

If required, one could change websocket timeouts (default is 10000 ms)

 WebGui.HttpWSTmout: 10000

By default, THttpServer created in restricted mode which only allows websocket handlers and processes only very few other related http requests. For security reasons such mode should be always enabled. Only if it is really necessary to process all other kinds of HTTP requests, one could specify no for following parameter (default yes):

 WebGui.WSOnly: yes

In some applications one may need to force longpoll websocket emulations from the beginning, for instance when clients connected via proxys. Although JSROOT should automatically fallback to longpoll engine, one can configure this directly (default no)

 WebGui.WSLongpoll: no

Following parameter controls browser max-age caching parameter for files (default 3600) When 0 is specified, browser cache will be disabled

 WebGui.HttpMaxAge: 3600

Also one can provide extra URL options for, see TCivetweb::Create for list of supported options

 WebGui.HttpExtraArgs: winsymlinks=no

One also can configure usage of FastCGI server for web windows:

 WebGui.FastCgiPort: 4000
 WebGui.FastCgiThreads: 10

To be able start web browser for such windows, one can provide real URL of the web server which will connect with that FastCGI instance:

 WebGui.FastCgiServer: https://your_apache_server.com/root_cgi_path

Definition at line 240 of file RWebWindowsManager.cxx.

◆ CreateWindow()

std::shared_ptr< RWebWindow > RWebWindowsManager::CreateWindow ( )

Creates new window To show window, RWebWindow::Show() have to be called.

Definition at line 395 of file RWebWindowsManager.cxx.

◆ GetLaunchTmout()

float ROOT::Experimental::RWebWindowsManager::GetLaunchTmout ( ) const
inlineprivate

Returns timeout for launching new browser process.

Definition at line 60 of file RWebWindowsManager.hxx.

◆ GetServer()

THttpServer * ROOT::Experimental::RWebWindowsManager::GetServer ( ) const
inline

Returns THttpServer instance.

Definition at line 81 of file RWebWindowsManager.hxx.

◆ GetServerAddr()

std::string ROOT::Experimental::RWebWindowsManager::GetServerAddr ( ) const
inline

Returns http address of the server, empty string when not available.

Definition at line 84 of file RWebWindowsManager.hxx.

◆ GetUrl()

std::string RWebWindowsManager::GetUrl ( const RWebWindow win,
bool  remote = false 
)
private

Provide URL address to access specified window from inside or from remote.

Definition at line 457 of file RWebWindowsManager.cxx.

◆ Instance()

std::shared_ptr< RWebWindowsManager > & RWebWindowsManager::Instance ( )
static

Returns default window manager Used to display all standard ROOT elements like TCanvas or TFitPanel.

Definition at line 75 of file RWebWindowsManager.cxx.

◆ IsMainThrd()

bool RWebWindowsManager::IsMainThrd ( )
static

Returns true when called from main process Main process recognized at the moment when library is loaded It supposed to be a thread where gApplication->Run() will be called If application runs in separate thread, one have to use AssignMainThrd() method to let RWebWindowsManager correctly recognize such situation.

Definition at line 99 of file RWebWindowsManager.cxx.

◆ IsUseHttpThread()

bool ROOT::Experimental::RWebWindowsManager::IsUseHttpThread ( ) const
inlineprivate

Returns true if http server use special thread for requests processing (default off)

Definition at line 54 of file RWebWindowsManager.hxx.

◆ IsUseSenderThreads()

bool ROOT::Experimental::RWebWindowsManager::IsUseSenderThreads ( ) const
inlineprivate

Returns true if extra threads to send data via websockets will be used (default off)

Definition at line 57 of file RWebWindowsManager.hxx.

◆ SetShowCallback()

void ROOT::Experimental::RWebWindowsManager::SetShowCallback ( WebWindowShowCallback_t  func)
inline

Assign show callback which can catch window showing, used by RBrowser.

Definition at line 87 of file RWebWindowsManager.hxx.

◆ ShowWindow()

unsigned RWebWindowsManager::ShowWindow ( RWebWindow win,
const RWebDisplayArgs user_args 
)
private

Show window in specified location, see Show() method for more details.

Show web window in specified location.

Parameters
[in,out]winweb window by reference
user_argsspecifies where and how display web window

As display args one can use string like "firefox" or "chrome" - these are two main supported web browsers. See RWebDisplayArgs::SetBrowserKind() for all available options. Default value for the browser can be configured when starting root with –web argument like: "root --web=chrome". When root started in web server mode "root --web=server", no any web browser will be started - just URL will be printout, which can be entered in any running web browser

If allowed, same window can be displayed several times (like for RCanvas or TCanvas)

Following parameters can be configured in rootrc file:

 WebGui.Chrome: full path to Google Chrome executable
 WebGui.ChromeBatch: command to start chrome in batch, used for image production, like "$prog --headless --disable-gpu $geometry $url"
 WebGui.ChromeHeadless: command to start chrome in headless mode, like "fork: --headless --disable-gpu $geometry $url"
 WebGui.ChromeInteractive: command to start chrome in interactive mode, like "$prog $geometry --app=\'$url\' &"
 WebGui.Firefox: full path to Mozilla Firefox executable
 WebGui.FirefoxHeadless: command to start Firefox in headless mode, like "fork:--headless --private-window --no-remote $profile $url"
 WebGui.FirefoxInteractive: command to start Firefox in interactive mode, like "$prog --private-window \'$url\' &"
 WebGui.FirefoxProfile: name of Firefox profile to use
 WebGui.FirefoxProfilePath: file path to Firefox profile
 WebGui.FirefoxRandomProfile: usage of random Firefox profile -1 never, 0 - only for headless mode (dflt), 1 - always
 WebGui.LaunchTmout: time required to start process in seconds (default 30 s)
 WebGui.OperationTmout: time required to perform WebWindow operation like execute command or update drawings
 WebGui.RecordData: if specified enables data recording for each web window 0 - off, 1 - on
 WebGui.JsonComp: compression factor for JSON conversion, if not specified - each widget uses own default values
 WebGui.ForceHttp: 0 - off (default), 1 - always create real http server to run web window
 WebGui.Console: -1 - output only console.error(), 0 - add console.warn(), 1  - add console.log() output
 WebGui.ConnCredits: 10 - number of packets which can be send by server or client without acknowledge from receiving side
 WebGui.openui5src: alternative location for openui5 like https://openui5.hana.ondemand.com/
 WebGui.openui5libs: list of pre-loaded ui5 libs like sap.m, sap.ui.layout, sap.ui.unified
 WebGui.openui5theme: openui5 theme like sap_belize (default) or sap_fiori_3

THttpServer-related parameters documented in CreateServer method

Definition at line 520 of file RWebWindowsManager.cxx.

◆ Terminate()

void RWebWindowsManager::Terminate ( )

Terminate http server and ROOT application.

Definition at line 653 of file RWebWindowsManager.cxx.

◆ Unregister()

void RWebWindowsManager::Unregister ( RWebWindow win)
private

Release all references to specified window Called from RWebWindow destructor.

Definition at line 448 of file RWebWindowsManager.cxx.

◆ WaitFor()

int RWebWindowsManager::WaitFor ( RWebWindow win,
WebWindowWaitFunc_t  check,
bool  timed = false,
double  timelimit = -1 
)
private

Waits until provided check function or lambdas returns non-zero value Regularly calls WebWindow::Sync() method to let run event loop If call from the main thread, runs system events processing Check function has following signature: int func(double spent_tm) Parameter spent_tm is time in seconds, which already spent inside function Waiting will be continued, if function returns zero.

First non-zero value breaks waiting loop and result is returned (or 0 if time is expired). If parameter timed is true, timelimit (in seconds) defines how long to wait

Definition at line 617 of file RWebWindowsManager.cxx.

Friends And Related Function Documentation

◆ RWebWindow

friend class RWebWindow
friend

Definition at line 39 of file RWebWindowsManager.hxx.

Member Data Documentation

◆ fAddr

std::string ROOT::Experimental::RWebWindowsManager::fAddr
private

! HTTP address of the server

Definition at line 43 of file RWebWindowsManager.hxx.

◆ fAssgnExec

std::unique_ptr<TExec> ROOT::Experimental::RWebWindowsManager::fAssgnExec
private

! special exec to assign thread id via ProcessEvents

Definition at line 50 of file RWebWindowsManager.hxx.

◆ fExternalProcessEvents

bool ROOT::Experimental::RWebWindowsManager::fExternalProcessEvents {false}
private

! indicate that there are external process events engine

Definition at line 49 of file RWebWindowsManager.hxx.

◆ fIdCnt

unsigned ROOT::Experimental::RWebWindowsManager::fIdCnt {0}
private

! counter for identifiers

Definition at line 45 of file RWebWindowsManager.hxx.

◆ fLaunchTmout

float ROOT::Experimental::RWebWindowsManager::fLaunchTmout {30.}
private

! timeout in seconds to start browser process, default 30s

Definition at line 48 of file RWebWindowsManager.hxx.

◆ fMutex

std::recursive_mutex ROOT::Experimental::RWebWindowsManager::fMutex
private

! main mutex, used for window creations

Definition at line 44 of file RWebWindowsManager.hxx.

◆ fServer

std::unique_ptr<THttpServer> ROOT::Experimental::RWebWindowsManager::fServer
private

! central communication with the all used displays

Definition at line 42 of file RWebWindowsManager.hxx.

◆ fShowCallback

WebWindowShowCallback_t ROOT::Experimental::RWebWindowsManager::fShowCallback
private

! function called for each RWebWindow::Show call

Definition at line 51 of file RWebWindowsManager.hxx.

◆ fUseHttpThrd

bool ROOT::Experimental::RWebWindowsManager::fUseHttpThrd {false}
private

! use special thread for THttpServer

Definition at line 46 of file RWebWindowsManager.hxx.

◆ fUseSenderThreads

bool ROOT::Experimental::RWebWindowsManager::fUseSenderThreads {false}
private

! use extra threads for sending data from RWebWindow to clients

Definition at line 47 of file RWebWindowsManager.hxx.

Libraries for ROOT::Experimental::RWebWindowsManager:
[legend]

The documentation for this class was generated from the following files: