@@ -7,6 +7,8 @@ In this chapter discussed how web-based display can be created in the ROOT.
77Idea of web displays is implementation of user interface, which can run remotely
88or locally in the web-browsers, fully decoupled from the application code.
99For the communication between application and browser websockets are used.
10+ On the server side ROOT application runs THttpServer instance which serves one or
11+ several clients. Client is any web browser
1012
1113
1214## Creating web-window
@@ -46,44 +48,21 @@ win->SetDataCallBack([](unsigned connid, const std::string &msg) {
4648```
4749
4850Here ** connid** is unique identifier, which assign to each connection when it is established.
49- There are several predefined messages kinds: ** "CONN_READY"** when new connection established and
50- ** "CONN_CLOSED"** when connection is closed by client.
5151The connection identifier should be used when sending message to the client:
5252
5353``` {.cpp}
5454
55- // get connection id for the first connection in the list
56-
57- if (win->NumConnections() > 0) {
58- unsigned connid = win->GetConnectionId();
59- std::string msg = "Hello, world";
60- win->Send(msg, connid);
61- }
55+ unsigned connid = win->GetConnectionId(); // first connection
56+ std::string msg = "Hello, world";
57+ win->Send(connid, msg);
6258
6359```
6460
65- ## Display window
66-
67- To display window in the browser, one should call ` win->Show() ` method.
68- This will starts new window (or new tab) in the default browser and show content of HTML page,
69- configured for the window. As argument of ` Show() ` method one can specify browser kind like
70- "chromium" or "firefox" or just full path to the program which should be invoked.
71- With the method ` win->GetUrl() ` one obtains URL string, which can be typed in the browser address string directly.
72-
73- Same window can be displayed several times in different browsers or different browser tabs - one only
74- must allow appropriate number of connections calling ` win->SetConnLimit(3) `
75-
76- For the local displays ** Chromium Embeded Framework (CEF)** is used. It provides functionality
77- of Chrome web browser in ROOT application without need to create and start real http server.
78- If CEF was configured correctly, it is enough to call ` win->Show("cef") ` to display window in CEF.
79-
80-
8161## Client code
8262
83- There is no limitations which framework should be used on the client side.
8463The minimal HTML/JavaScript code, which establish connection with the server, looks like:
8564
86- ``` {. html}
65+ ``` { html}
8766<!DOCTYPE HTML>
8867<html>
8968 <head>
@@ -116,3 +95,65 @@ The minimal HTML/JavaScript code, which establish connection with the server, lo
11695</html>
11796
11897```
98+
99+ Here ` jsroot/webwindow ` module is loaded to let establish connection with ROOT application.
100+ It includes all necessary initialization and authentication of websocket connection with the server.
101+ Beside this part there is no limitations which HTML/JS framework should be used to organize layout and code on the client side.
102+
103+
104+ ## Display window
105+
106+ To configure web display one uses ` --web=<kind> ` argument when starting ROOT.
107+ Typical values are:
108+
109+ - "chrome": select Google Chrome browser for interactive web display
110+ - "firefox": select Mozilla Firefox browser for interactive web display
111+ - "edge": select Microsoft Edge browser for interactive web display
112+ - "qt6": uses QWebEngine from Qt6, no real http server started (requires ` qt6web ` component build for ROOT)
113+ - "cef": uses Chromium Embeded Framework, no real http server started (requires ` cefweb ` component build for ROOT)
114+ - "default": system default web browser, invoked with ` xdg-open ` on Linux, ` start ` on Mac or ` open ` on Windows
115+ - "off": turns off the web display and comes back to normal graphics in interactive mode.
116+
117+ Alternatively one can call ` gROOT->SetWebDisplay("<kind>") ` to specify display kind.
118+ Same argument can be provided directly to the ` RWebWindow::Show() ` .
119+
120+ With the method ` win->GetUrl() ` one obtains URL string, which can be typed in the browser address string directly.
121+
122+
123+ ## Use ROOT web widgets on the remote nodes
124+
125+ It is advised to use the ` rootssh ` script with built-in port forwarding and run
126+ the user interface on the local host with the default web browser. Like:
127+
128+ [localhost] rootssh username@remotenode
129+
130+ As with regular ` ssh ` , one can specify command which should be run on remote node:
131+
132+ [localhost] rootssh username@remotenode "root --web -e 'new TBrowser'"
133+
134+ Script automatically creates tunnel and configures several shell variables in remote session. These are:
135+
136+ - ` ROOT_WEBGUI_SOCKET ` - unix socket which will be used by ROOT ` THttpServer ` in webgui
137+ - ` ROOT_LISTENER_SOCKET ` - unix socket which gets messages from ROOT when new web widgets are started
138+
139+ When on remote node in ROOT session new web widget is created, default web browser will be started on the local node and display created widget.
140+
141+ It is highly recommended to use ` rootssh ` script on public nodes like ` lxplus ` . Unix sockets, which are created on
142+ the remote session, are configured with ` 0700 ` file mode - means only user allowed to access them.
143+
144+ One can provide ` --port number ` parameter to configure port number on local node and ` --browser <name> ` to specify
145+ web browser executable to display web widgets. Like:
146+
147+ [localhost] rootssh --port 8877 --browser chromium username@remotenode
148+
149+ Also any kind of normal ` ssh ` arguments can be specified:
150+
151+ [localhost] rootssh -Y -E file.log username@remotenode
152+
153+ On remote node root session should be started with ` root --web ` argument to advise ROOT use web widgets. Like:
154+
155+ [remotehost] root --web hsimple.C
156+
157+ [ ` rootssh ` script] ( https://raw.githubusercontent.com/root-project/root/master/config/rootssh ) can be download and used independently from ROOT installation - it is only required that supported ROOT version installed on remote node.
158+
159+
0 commit comments