Represents web window, which can be shown in web browser or any other supported environment.
Window can be configured to run either in the normal or in the batch (headless) mode. In second case no any graphical elements will be created. For the normal window one can configure geometry (width and height), which are applied when window shown.
Each window can be shown several times (if allowed) in different places - either as the CEF (chromium embedded) window or in the standard web browser. When started, window will open and show HTML page, configured with RWebWindow::SetDefaultPage() method.
Typically (but not necessarily) clients open web socket connection to the window and one can exchange data, using RWebWindow::Send() method and call-back function assigned via RWebWindow::SetDataCallBack().
Definition at line 53 of file RWebWindow.hxx.
Classes | |
struct | QueueEntry |
struct | QueueItem |
struct | WebConn |
Public Member Functions | |
RWebWindow () | |
RWebWindow constructor Should be defined here because of std::unique_ptr<RWebWindowWSHandler> | |
~RWebWindow () | |
RWebWindow destructor Closes all connections and remove window from manager. | |
void | AssignThreadId () |
Assign thread id which has to be used for callbacks WARNING!!! only for expert use Automatically done at the moment when any callback function is invoked Can be invoked once again if window Run method will be invoked from other thread Normally should be invoked before Show() method is called. | |
bool | CanSend (unsigned connid, bool direct=true) const |
Returns true if sending via specified connection can be performed. | |
void | CloseConnection (unsigned connid) |
Close specified connection. | |
void | CloseConnections () |
Closes all connection to clients Normally leads to closing of all correspondent browser windows Some browsers (like firefox) do not allow by default to close window. | |
std::string | GetAddr () const |
Returns window address which is used in URL. | |
std::string | GetClientVersion () const |
Returns current client version. | |
unsigned | GetConnectionId (int num=0) const |
Returns connection id for specified connection sequence number Only active connections are returned - where clients confirms connection Total number of connections can be retrieved with NumConnections() method. | |
unsigned | GetConnLimit () const |
returns configured connections limit (0 - default) | |
unsigned | GetDisplayConnection () const |
Returns first connection id where window is displayed It could be that connection(s) not yet fully established - but also not timed out Batch jobs will be ignored here Returns 0 if connection not exists. | |
unsigned | GetHeight () const |
returns configured window height (0 - default) | |
unsigned | GetId () const |
Returns ID for the window - unique inside window manager. | |
std::shared_ptr< RWebWindowsManager > | GetManager () const |
Returns window manager. | |
unsigned | GetMaxQueueLength () const |
Return maximal queue length of data which can be held by window. | |
float | GetOperationTmout () const |
Returns timeout for synchronous WebWindow operations. | |
std::string | GetRelativeAddr (const RWebWindow &win) const |
Returns relative URL address for the specified window Address can be required if one needs to access data from one window into another window Used for instance when inserting panel into canvas. | |
std::string | GetRelativeAddr (const std::shared_ptr< RWebWindow > &win) const |
Returns relative URL address for the specified window Address can be required if one needs to access data from one window into another window Used for instance when inserting panel into canvas. | |
int | GetSendQueueLength (unsigned connid) const |
Returns send queue length for specified connection. | |
THttpServer * | GetServer () |
Return THttpServer instance serving requests to the window. | |
std::string | GetUrl (bool remote=true) |
Return URL string to access web window. | |
std::string | GetUserArgs () const |
Returns configured user arguments for web window See SetUserArgs method for more details. | |
unsigned | GetWidth () const |
returns configured window width (0 - default) actual window width can be different | |
bool | HasConnection (unsigned connid=0, bool only_active=true) const |
returns true if specified connection id exists | |
bool | IsNativeOnlyConn () const |
returns true if only native (own-created) connections are allowed | |
bool | IsShown () const |
Returns true when window was shown at least once. | |
int | NumConnections (bool with_pending=false) const |
Returns current number of active clients connections. | |
void | RecordData (const std::string &fname="protocol.json", const std::string &fprefix="") |
Configures recording of communication data in protocol file Provided filename will be used to store JSON array with names of written files - text or binary If data was send from client, "send" entry will be placed. | |
void | Run (double tm=0.) |
Run window functionality for specified time If no action can be performed - just sleep specified time. | |
void | Send (unsigned connid, const std::string &data) |
Sends data to specified connection. | |
void | SendBinary (unsigned connid, const void *data, std::size_t len) |
Send binary data to specified connection. | |
void | SendBinary (unsigned connid, std::string &&data) |
Send binary data to specified connection. | |
void | SetCallBacks (WebWindowConnectCallback_t conn, WebWindowDataCallback_t data, WebWindowConnectCallback_t disconn=nullptr) |
Set call-backs function for connect, data and disconnect events. | |
void | SetClientVersion (const std::string &vers) |
Set client version, used as prefix in scripts URL When changed, web browser will reload all related JS files while full URL will be different Default is empty value - no extra string in URL Version should be string like "1.2" or "ver1.subv2" and not contain any special symbols. | |
void | SetConnectCallBack (WebWindowConnectCallback_t func) |
Set call-back function for new connection. | |
void | SetConnLimit (unsigned lmt=0) |
Configure maximal number of allowed connections - 0 is unlimited Will not affect already existing connections Default is 1 - the only client is allowed. | |
void | SetConnToken (const std::string &token="") |
Configures connection token (default none) When specified, in URL of webpage such token should be provided as &token=value parameter, otherwise web window will refuse connection. | |
void | SetDataCallBack (WebWindowDataCallback_t func) |
Set call-back function for data, received from the clients via websocket. | |
void | SetDefaultPage (const std::string &page) |
Set content of default window HTML page This page returns when URL address of the window will be requested Either HTML code or file name in the form "file:/home/user/data/file.htm" One also can using default locations like "file:rootui5sys/canv/canvas.html". | |
void | SetDisconnectCallBack (WebWindowConnectCallback_t func) |
Set call-back function for disconnecting. | |
void | SetGeometry (unsigned width, unsigned height) |
Set window geometry. Will be applied if supported by used web display (like CEF or Chromium) | |
void | SetMaxQueueLength (unsigned len=10) |
configures maximal queue length of data which can be held by window | |
void | SetNativeOnlyConn (bool on=true) |
configures that only native (own-created) connections are allowed | |
void | SetOperationTmout (float tm=50.) |
Set timeout for synchronous WebWindow operations. | |
void | SetPanelName (const std::string &name) |
Configure window to show some of existing JSROOT panels It uses "file:rootui5sys/panel/panel.html" as default HTML page At the moment only FitPanel is existing. | |
void | SetUserArgs (const std::string &args) |
Set arbitrary JSON data, which is accessible via conn.getUserArgs() method in JavaScript This JSON code injected into main HTML document into JSROOT.connectWebWindow() Must be set before RWebWindow::Show() method is called. | |
unsigned | Show (const RWebDisplayArgs &args="") |
Show window in specified location See ROOT::Experimental::RWebWindowsManager::Show for more info returns (future) connection id (or 0 when fails) | |
void | StartThread () |
Start special thread which will be used by the window to handle all callbacks One has to be sure, that access to global ROOT structures are minimized and protected with ROOT::EnableThreadSafety(); call. | |
void | StopThread () |
Stop special thread. | |
void | Sync () |
Special method to process all internal activity when window runs in separate thread. | |
void | TerminateROOT () |
Terminate ROOT session Tries to correctly close THttpServer, associated with RWebWindowsManager After that exit from process. | |
void | UseServerThreads () |
Let use THttpServer threads to process requests WARNING!!! only for expert use Should be only used when application provides proper locking and does not block. | |
int | WaitFor (WebWindowWaitFunc_t check) |
Waits until provided check function or lambdas returns non-zero value Check function has following signature: int func(double spent_tm) Waiting will be continued, if function returns zero. | |
int | WaitForTimed (WebWindowWaitFunc_t check) |
Waits until provided check function or lambdas returns non-zero value Check function has following signature: int func(double spent_tm) Waiting will be continued, if function returns zero. | |
int | WaitForTimed (WebWindowWaitFunc_t check, double duration) |
Waits until provided check function or lambdas returns non-zero value Check function has following signature: int func(double spent_tm) Waiting will be continued, if function returns zero. | |
Static Public Member Functions | |
static std::shared_ptr< RWebWindow > | Create () |
Create new RWebWindow Using default RWebWindowsManager. | |
static unsigned | ShowWindow (std::shared_ptr< RWebWindow > window, const RWebDisplayArgs &args="") |
Static method to show web window Has to be used instead of RWebWindow::Show() when window potentially can be embed into other windows Soon RWebWindow::Show() method will be done protected. | |
Private Types | |
using | ConnectionsList_t = std::vector< std::shared_ptr< WebConn > > |
enum | EQueueEntryKind { kind_None , kind_Connect , kind_Data , kind_Disconnect } |
using | timestamp_t = std::chrono::time_point< std::chrono::system_clock > |
Private Member Functions | |
std::string | _MakeSendHeader (std::shared_ptr< WebConn > &conn, bool txt, const std::string &data, int chid) |
Internal method to prepare text part of send data Should be called under locked connection mutex. | |
unsigned | AddDisplayHandle (bool headless_mode, const std::string &key, std::unique_ptr< RWebDisplayHandle > &handle) |
Add display handle and associated key Key is random number generated when starting new window When client is connected, key should be supplied to correctly identify it. | |
unsigned | AddEmbedWindow (std::shared_ptr< RWebWindow > window, int channel) |
Add embed window. | |
void | CheckDataToSend (bool only_once=false) |
Checks if new data can be send (internal use only) If necessary, provide credits to the client. | |
bool | CheckDataToSend (std::shared_ptr< WebConn > &conn) |
Checks if one should send data for specified connection Returns true when send operation was performed. | |
void | CheckInactiveConnections () |
Check if there are connection which are inactive for longer time For instance, batch browser will be stopped if no activity for 30 sec is there. | |
void | CheckPendingConnections () |
Check if started process(es) establish connection. | |
void | CheckThreadAssign () |
Internal method to verify and thread id has to be assigned from manager again Special case when ProcessMT was enabled just until thread id will be assigned. | |
void | CompleteWSSend (unsigned wsid) |
Complete websocket send operation Clear "doing send" flag and check if next operation has to be started. | |
std::shared_ptr< RWebWindowWSHandler > | CreateWSHandler (std::shared_ptr< RWebWindowsManager > mgr, unsigned id, double tmout) |
Assigns manager reference, window id and creates websocket handler, used for communication with the clients. | |
std::shared_ptr< WebConn > | FindConnection (unsigned wsid) |
Find connection with specified websocket id. | |
unsigned | FindHeadlessConnection () |
Returns connection id of window running in headless mode This can be special connection which may run picture production jobs in background Connection to that job may not be initialized yet If connection does not exists, returns 0. | |
std::shared_ptr< WebConn > | FindOrCreateConnection (unsigned wsid, bool make_new, const char *query) |
Find connection with given websocket id. | |
ConnectionsList_t | GetConnections (unsigned connid=0, bool only_active=false) const |
returns connection list (or all active connections) | |
std::string | GetConnToken () const |
Returns configured connection token. | |
bool | HasKey (const std::string &key) const |
Returns true if provided key value already exists (in processes map or in existing connections) | |
void | InvokeCallbacks (bool force=false) |
Invoke callbacks with existing data Must be called from appropriate thread. | |
unsigned | MakeHeadless (bool create_new=false) |
Start headless browser for specified window Normally only single instance is used, but many can be created See ROOT::Experimental::RWebWindowsManager::Show() docu for more info returns (future) connection id (or 0 when fails) | |
bool | ProcessBatchHolder (std::shared_ptr< THttpCallArg > &arg) |
Process special http request, used to hold headless browser running Such requests should not be replied for the long time Be aware that function called directly from THttpServer thread, which is not same thread as window. | |
bool | ProcessWS (THttpCallArg &arg) |
Processing of websockets call-backs, invoked from RWebWindowWSHandler Method invoked from http server thread, therefore appropriate mutex must be used on all relevant data. | |
void | ProvideQueueEntry (unsigned connid, EQueueEntryKind kind, std::string &&arg) |
Provide data to user callback User callback must be executed in the window thread. | |
std::shared_ptr< WebConn > | RemoveConnection (unsigned wsid) |
Remove connection with given websocket id. | |
void | RemoveEmbedWindow (unsigned connid, int channel) |
Remove RWebWindow associated with the channel. | |
void | SubmitData (unsigned connid, bool txt, std::string &&data, int chid=1) |
Internal method to send data. | |
Private Attributes | |
std::thread::id | fCallbacksThrdId |
! thread id where callbacks should be invoked | |
bool | fCallbacksThrdIdSet {false} |
! flag indicating that thread id is assigned | |
std::string | fClientVersion |
! configured client version, used as prefix in scripts URL | |
ConnectionsList_t | fConn |
! list of all accepted connections | |
WebWindowConnectCallback_t | fConnCallback |
! callback for connect event | |
unsigned | fConnCnt {0} |
! counter of new connections to assign ids | |
unsigned | fConnLimit {1} |
! number of allowed active connections | |
std::mutex | fConnMutex |
! mutex used to protect connection list | |
std::string | fConnToken |
! value of "token" URL parameter which should be provided for connecting window | |
WebWindowDataCallback_t | fDataCallback |
! main callback when data over channel 1 is arrived | |
std::string | fDefaultPage |
! HTML page (or file name) returned when window URL is opened | |
WebWindowConnectCallback_t | fDisconnCallback |
! callback for disconnect event | |
bool | fHasWindowThrd {false} |
! indicate if special window thread was started | |
unsigned | fHeight {0} |
! initial window height when displayed | |
unsigned | fId {0} |
! unique identifier | |
std::queue< QueueEntry > | fInputQueue |
! input queue for all callbacks | |
std::mutex | fInputQueueMutex |
! mutex to protect input queue | |
std::shared_ptr< RWebWindow > | fMaster |
! master window where this window is embeded | |
int | fMasterChannel {-1} |
! channel id in the master window | |
unsigned | fMasterConnId {0} |
! master connection id | |
unsigned | fMaxQueueLength {10} |
! maximal number of queue entries | |
std::shared_ptr< RWebWindowsManager > | fMgr |
! display manager | |
bool | fNativeOnlyConn {false} |
! only native connection are allowed, created by Show() method | |
float | fOperationTmout {50.} |
! timeout in seconds to perform synchronous operation, default 50s | |
std::string | fPanelName |
! panel name which should be shown in the window | |
ConnectionsList_t | fPendingConn |
! list of pending connection with pre-assigned keys | |
bool | fProcessMT {false} |
! if window event processing performed in dedicated thread | |
std::string | fProtocol |
! protocol | |
int | fProtocolCnt {-1} |
! counter for protocol recording | |
unsigned | fProtocolConnId {0} |
! connection id, which is used for writing protocol | |
std::string | fProtocolFileName |
! local file where communication protocol will be written | |
std::string | fProtocolPrefix |
! prefix for created files names | |
bool | fSendMT {false} |
! true is special threads should be used for sending data | |
std::string | fUserArgs |
! arbitrary JSON code, which is accessible via conn.getUserArgs() method | |
bool | fUseServerThreads {false} |
! indicates that server thread is using, no special window thread | |
unsigned | fWidth {0} |
! initial window width when displayed | |
std::thread | fWindowThrd |
! special thread for that window | |
std::shared_ptr< RWebWindowWSHandler > | fWSHandler |
! specialize websocket handler for all incoming connections | |
Friends | |
class | RWebDisplayHandle |
class | RWebWindowsManager |
class | RWebWindowWSHandler |
#include <ROOT/RWebWindow.hxx>
|
private |
Definition at line 110 of file RWebWindow.hxx.
|
private |
Definition at line 60 of file RWebWindow.hxx.
|
private |
Enumerator | |
---|---|
kind_None | |
kind_Connect | |
kind_Data | |
kind_Disconnect |
Definition at line 100 of file RWebWindow.hxx.
|
default |
RWebWindow constructor Should be defined here because of std::unique_ptr<RWebWindowWSHandler>
RWebWindow::~RWebWindow | ( | ) |
RWebWindow destructor Closes all connections and remove window from manager.
Definition at line 76 of file RWebWindow.cxx.
|
private |
Internal method to prepare text part of send data Should be called under locked connection mutex.
Definition at line 783 of file RWebWindow.cxx.
|
private |
Add display handle and associated key Key is random number generated when starting new window When client is connected, key should be supplied to correctly identify it.
Definition at line 420 of file RWebWindow.cxx.
|
private |
Add embed window.
Definition at line 1427 of file RWebWindow.cxx.
void RWebWindow::AssignThreadId | ( | ) |
Assign thread id which has to be used for callbacks WARNING!!! only for expert use Automatically done at the moment when any callback function is invoked Can be invoked once again if window Run method will be invoked from other thread Normally should be invoked before Show() method is called.
Definition at line 1241 of file RWebWindow.cxx.
Returns true if sending via specified connection can be performed.
connid | connection id, when 0 - all existing connections are checked |
direct | when true, checks if direct sending (without queuing) is possible |
Definition at line 1109 of file RWebWindow.cxx.
Checks if new data can be send (internal use only) If necessary, provide credits to the client.
only_once | if true, data sending performed once or until there is no data to send |
Definition at line 879 of file RWebWindow.cxx.
Checks if one should send data for specified connection Returns true when send operation was performed.
Definition at line 830 of file RWebWindow.cxx.
|
private |
Check if there are connection which are inactive for longer time For instance, batch browser will be stopped if no activity for 30 sec is there.
Definition at line 494 of file RWebWindow.cxx.
|
private |
Check if started process(es) establish connection.
After timeout such processed will be killed Method invoked from http server thread, therefore appropriate mutex must be used on all relevant data
Definition at line 459 of file RWebWindow.cxx.
|
private |
Internal method to verify and thread id has to be assigned from manager again Special case when ProcessMT was enabled just until thread id will be assigned.
Definition at line 572 of file RWebWindow.cxx.
void RWebWindow::CloseConnection | ( | unsigned | connid | ) |
Close specified connection.
connid | connection id, when 0 - all connections will be closed |
Definition at line 1072 of file RWebWindow.cxx.
void RWebWindow::CloseConnections | ( | ) |
Closes all connection to clients Normally leads to closing of all correspondent browser windows Some browsers (like firefox) do not allow by default to close window.
Definition at line 1063 of file RWebWindow.cxx.
|
private |
Complete websocket send operation Clear "doing send" flag and check if next operation has to be started.
Definition at line 764 of file RWebWindow.cxx.
|
static |
Create new RWebWindow Using default RWebWindowsManager.
Definition at line 1464 of file RWebWindow.cxx.
|
private |
Assigns manager reference, window id and creates websocket handler, used for communication with the clients.
Definition at line 131 of file RWebWindow.cxx.
|
inlineprivate |
Find connection with specified websocket id.
Definition at line 162 of file RWebWindow.hxx.
|
private |
Returns connection id of window running in headless mode This can be special connection which may run picture production jobs in background Connection to that job may not be initialized yet If connection does not exists, returns 0.
Definition at line 195 of file RWebWindow.cxx.
|
private |
Find connection with given websocket id.
Definition at line 238 of file RWebWindow.cxx.
std::string RWebWindow::GetAddr | ( | ) | const |
Returns window address which is used in URL.
Definition at line 913 of file RWebWindow.cxx.
std::string RWebWindow::GetClientVersion | ( | ) | const |
Returns current client version.
Definition at line 961 of file RWebWindow.cxx.
unsigned RWebWindow::GetConnectionId | ( | int | num = 0 | ) | const |
Returns connection id for specified connection sequence number Only active connections are returned - where clients confirms connection Total number of connections can be retrieved with NumConnections() method.
num | connection sequence number |
Definition at line 1027 of file RWebWindow.cxx.
|
private |
returns connection list (or all active connections)
connid | connection id, when 0 - all existing connections are returned |
only_active | when true, only active (already established) connections are returned |
Definition at line 1083 of file RWebWindow.cxx.
unsigned RWebWindow::GetConnLimit | ( | ) | const |
returns configured connections limit (0 - default)
Definition at line 539 of file RWebWindow.cxx.
|
private |
Returns configured connection token.
Definition at line 561 of file RWebWindow.cxx.
unsigned RWebWindow::GetDisplayConnection | ( | ) | const |
Returns first connection id where window is displayed It could be that connection(s) not yet fully established - but also not timed out Batch jobs will be ignored here Returns 0 if connection not exists.
Definition at line 218 of file RWebWindow.cxx.
|
inline |
returns configured window height (0 - default)
Definition at line 234 of file RWebWindow.hxx.
|
inline |
Returns ID for the window - unique inside window manager.
Definition at line 207 of file RWebWindow.hxx.
|
inline |
Returns window manager.
Definition at line 210 of file RWebWindow.hxx.
|
inline |
Return maximal queue length of data which can be held by window.
Definition at line 248 of file RWebWindow.hxx.
|
inline |
Returns timeout for synchronous WebWindow operations.
Definition at line 277 of file RWebWindow.hxx.
std::string RWebWindow::GetRelativeAddr | ( | const RWebWindow & | win | ) | const |
Returns relative URL address for the specified window Address can be required if one needs to access data from one window into another window Used for instance when inserting panel into canvas.
Definition at line 933 of file RWebWindow.cxx.
std::string RWebWindow::GetRelativeAddr | ( | const std::shared_ptr< RWebWindow > & | win | ) | const |
Returns relative URL address for the specified window Address can be required if one needs to access data from one window into another window Used for instance when inserting panel into canvas.
Definition at line 923 of file RWebWindow.cxx.
int RWebWindow::GetSendQueueLength | ( | unsigned | connid | ) | const |
Returns send queue length for specified connection.
connid | connection id, 0 - maximal value for all connections is returned If wrong connection id specified, -1 is return |
Definition at line 1134 of file RWebWindow.cxx.
THttpServer * RWebWindow::GetServer | ( | ) |
Return THttpServer instance serving requests to the window.
Definition at line 155 of file RWebWindow.cxx.
std::string RWebWindow::GetUrl | ( | bool | remote = true | ) |
Return URL string to access web window.
remote | if true, real HTTP server will be started automatically |
Definition at line 147 of file RWebWindow.cxx.
std::string RWebWindow::GetUserArgs | ( | ) | const |
Returns configured user arguments for web window See SetUserArgs method for more details.
Definition at line 983 of file RWebWindow.cxx.
|
inline |
returns configured window width (0 - default) actual window width can be different
Definition at line 230 of file RWebWindow.hxx.
returns true if specified connection id exists
connid | connection id (0 - any) |
only_active | when true only active connection will be checked, otherwise also pending (not yet established) connections are checked |
Definition at line 1038 of file RWebWindow.cxx.
|
private |
Returns true if provided key value already exists (in processes map or in existing connections)
Definition at line 438 of file RWebWindow.cxx.
Invoke callbacks with existing data Must be called from appropriate thread.
Definition at line 376 of file RWebWindow.cxx.
|
inline |
returns true if only native (own-created) connections are allowed
Definition at line 256 of file RWebWindow.hxx.
|
inline |
Returns true when window was shown at least once.
Definition at line 295 of file RWebWindow.hxx.
|
private |
Start headless browser for specified window Normally only single instance is used, but many can be created See ROOT::Experimental::RWebWindowsManager::Show() docu for more info returns (future) connection id (or 0 when fails)
Definition at line 176 of file RWebWindow.cxx.
Returns current number of active clients connections.
with_pending | if true, also pending (not yet established) connection accounted |
Definition at line 993 of file RWebWindow.cxx.
|
private |
Process special http request, used to hold headless browser running Such requests should not be replied for the long time Be aware that function called directly from THttpServer thread, which is not same thread as window.
Definition at line 314 of file RWebWindow.cxx.
|
private |
Processing of websockets call-backs, invoked from RWebWindowWSHandler Method invoked from http server thread, therefore appropriate mutex must be used on all relevant data.
Definition at line 582 of file RWebWindow.cxx.
|
private |
Provide data to user callback User callback must be executed in the window thread.
Definition at line 362 of file RWebWindow.cxx.
void RWebWindow::RecordData | ( | const std::string & | fname = "protocol.json" , |
const std::string & | fprefix = "" |
||
) |
Configures recording of communication data in protocol file Provided filename will be used to store JSON array with names of written files - text or binary If data was send from client, "send" entry will be placed.
JSON file will look like:
["send", "msg0.txt", "send", "msg1.txt", "msg2.txt"]
If empty file name is provided, data recording will be disabled Recorded data can be used in JSROOT directly to test client code without running C++ server
Definition at line 1012 of file RWebWindow.cxx.
|
private |
Remove connection with given websocket id.
Definition at line 285 of file RWebWindow.cxx.
Remove RWebWindow associated with the channel.
Definition at line 1448 of file RWebWindow.cxx.
Run window functionality for specified time If no action can be performed - just sleep specified time.
Definition at line 1408 of file RWebWindow.cxx.
void RWebWindow::Send | ( | unsigned | connid, |
const std::string & | data | ||
) |
Sends data to specified connection.
connid | connection id, when 0 - data will be send to all connections |
Definition at line 1208 of file RWebWindow.cxx.
Send binary data to specified connection.
connid | connection id, when 0 - data will be send to all connections |
Definition at line 1226 of file RWebWindow.cxx.
void RWebWindow::SendBinary | ( | unsigned | connid, |
std::string && | data | ||
) |
Send binary data to specified connection.
connid | connection id, when 0 - data will be send to all connections |
Definition at line 1217 of file RWebWindow.cxx.
void RWebWindow::SetCallBacks | ( | WebWindowConnectCallback_t | conn, |
WebWindowDataCallback_t | data, | ||
WebWindowConnectCallback_t | disconn = nullptr |
||
) |
Set call-backs function for connect, data and disconnect events.
Definition at line 1354 of file RWebWindow.cxx.
void RWebWindow::SetClientVersion | ( | const std::string & | vers | ) |
Set client version, used as prefix in scripts URL When changed, web browser will reload all related JS files while full URL will be different Default is empty value - no extra string in URL Version should be string like "1.2" or "ver1.subv2" and not contain any special symbols.
Definition at line 952 of file RWebWindow.cxx.
void RWebWindow::SetConnectCallBack | ( | WebWindowConnectCallback_t | func | ) |
Set call-back function for new connection.
Definition at line 1336 of file RWebWindow.cxx.
void RWebWindow::SetConnLimit | ( | unsigned | lmt = 0 | ) |
Configure maximal number of allowed connections - 0 is unlimited Will not affect already existing connections Default is 1 - the only client is allowed.
Definition at line 529 of file RWebWindow.cxx.
void RWebWindow::SetConnToken | ( | const std::string & | token = "" | ) |
Configures connection token (default none) When specified, in URL of webpage such token should be provided as &token=value parameter, otherwise web window will refuse connection.
Definition at line 551 of file RWebWindow.cxx.
void RWebWindow::SetDataCallBack | ( | WebWindowDataCallback_t | func | ) |
Set call-back function for data, received from the clients via websocket.
Function should have signature like void func(unsigned connid, const std::string &data) First argument identifies connection (unique for each window), second argument is received data
At the moment when callback is assigned, RWebWindow working thread is detected. If called not from main application thread, RWebWindow::Run() function must be regularly called from that thread.
Most simple way to assign call-back - use of c++11 lambdas like:
Definition at line 1327 of file RWebWindow.cxx.
|
inline |
Set content of default window HTML page This page returns when URL address of the window will be requested Either HTML code or file name in the form "file:/home/user/data/file.htm" One also can using default locations like "file:rootui5sys/canv/canvas.html".
Definition at line 216 of file RWebWindow.hxx.
void RWebWindow::SetDisconnectCallBack | ( | WebWindowConnectCallback_t | func | ) |
Set call-back function for disconnecting.
Definition at line 1345 of file RWebWindow.cxx.
|
inline |
Set window geometry. Will be applied if supported by used web display (like CEF or Chromium)
Definition at line 221 of file RWebWindow.hxx.
|
inline |
configures maximal queue length of data which can be held by window
Definition at line 244 of file RWebWindow.hxx.
configures that only native (own-created) connections are allowed
Definition at line 252 of file RWebWindow.hxx.
|
inline |
Set timeout for synchronous WebWindow operations.
Definition at line 280 of file RWebWindow.hxx.
void RWebWindow::SetPanelName | ( | const std::string & | name | ) |
Configure window to show some of existing JSROOT panels It uses "file:rootui5sys/panel/panel.html" as default HTML page At the moment only FitPanel is existing.
Definition at line 113 of file RWebWindow.cxx.
void RWebWindow::SetUserArgs | ( | const std::string & | args | ) |
Set arbitrary JSON data, which is accessible via conn.getUserArgs() method in JavaScript This JSON code injected into main HTML document into JSROOT.connectWebWindow() Must be set before RWebWindow::Show() method is called.
args | - arbitrary JSON data which can be provided to client side |
Definition at line 973 of file RWebWindow.cxx.
unsigned RWebWindow::Show | ( | const RWebDisplayArgs & | args = "" | ) |
Show window in specified location See ROOT::Experimental::RWebWindowsManager::Show for more info returns (future) connection id (or 0 when fails)
Definition at line 165 of file RWebWindow.cxx.
|
static |
Static method to show web window Has to be used instead of RWebWindow::Show() when window potentially can be embed into other windows Soon RWebWindow::Show() method will be done protected.
Definition at line 1496 of file RWebWindow.cxx.
void RWebWindow::StartThread | ( | ) |
Start special thread which will be used by the window to handle all callbacks One has to be sure, that access to global ROOT structures are minimized and protected with ROOT::EnableThreadSafety(); call.
Definition at line 1274 of file RWebWindow.cxx.
void RWebWindow::StopThread | ( | ) |
Stop special thread.
Definition at line 1296 of file RWebWindow.cxx.
|
private |
Internal method to send data.
connid | connection id, when 0 - data will be send to all connections |
txt | is text message should be send |
chid | channel id, 1 - normal communication, 0 - internal with highest priority |
Definition at line 1153 of file RWebWindow.cxx.
void RWebWindow::Sync | ( | ) |
Special method to process all internal activity when window runs in separate thread.
Definition at line 899 of file RWebWindow.cxx.
void RWebWindow::TerminateROOT | ( | ) |
Terminate ROOT session Tries to correctly close THttpServer, associated with RWebWindowsManager After that exit from process.
Definition at line 1474 of file RWebWindow.cxx.
void RWebWindow::UseServerThreads | ( | ) |
Let use THttpServer threads to process requests WARNING!!! only for expert use Should be only used when application provides proper locking and does not block.
Such mode provides minimal possible latency Must be called before callbacks are assigned
Definition at line 1262 of file RWebWindow.cxx.
int RWebWindow::WaitFor | ( | WebWindowWaitFunc_t | check | ) |
Waits until provided check function or lambdas returns non-zero value Check function has following signature: int func(double spent_tm) Waiting will be continued, if function returns zero.
Parameter spent_tm is time in seconds, which already spent inside the function First non-zero value breaks loop and result is returned. Runs application mainloop and short sleeps in-between
Definition at line 1370 of file RWebWindow.cxx.
int RWebWindow::WaitForTimed | ( | WebWindowWaitFunc_t | check | ) |
Waits until provided check function or lambdas returns non-zero value Check function has following signature: int func(double spent_tm) Waiting will be continued, if function returns zero.
Parameter spent_tm in lambda is time in seconds, which already spent inside the function First non-zero value breaks waiting loop and result is returned (or 0 if time is expired). Runs application mainloop and short sleeps in-between WebGui.OperationTmout rootrc parameter defines waiting time in seconds
Definition at line 1384 of file RWebWindow.cxx.
int RWebWindow::WaitForTimed | ( | WebWindowWaitFunc_t | check, |
double | duration | ||
) |
Waits until provided check function or lambdas returns non-zero value Check function has following signature: int func(double spent_tm) Waiting will be continued, if function returns zero.
Parameter spent_tm in lambda is time in seconds, which already spent inside the function First non-zero value breaks waiting loop and result is returned (or 0 if time is expired). Runs application mainloop and short sleeps in-between duration (in seconds) defines waiting time
Definition at line 1398 of file RWebWindow.cxx.
|
friend |
Definition at line 57 of file RWebWindow.hxx.
|
friend |
Definition at line 55 of file RWebWindow.hxx.
|
friend |
Definition at line 56 of file RWebWindow.hxx.
|
private |
! thread id where callbacks should be invoked
Definition at line 134 of file RWebWindow.hxx.
|
private |
! flag indicating that thread id is assigned
Definition at line 135 of file RWebWindow.hxx.
|
private |
! configured client version, used as prefix in scripts URL
Definition at line 143 of file RWebWindow.hxx.
|
private |
! list of all accepted connections
Definition at line 125 of file RWebWindow.hxx.
|
private |
! callback for connect event
Definition at line 131 of file RWebWindow.hxx.
|
private |
! counter of new connections to assign ids
Definition at line 123 of file RWebWindow.hxx.
|
private |
! number of allowed active connections
Definition at line 127 of file RWebWindow.hxx.
|
mutableprivate |
! mutex used to protect connection list
Definition at line 126 of file RWebWindow.hxx.
|
private |
! value of "token" URL parameter which should be provided for connecting window
Definition at line 128 of file RWebWindow.hxx.
|
private |
! main callback when data over channel 1 is arrived
Definition at line 132 of file RWebWindow.hxx.
|
private |
! HTML page (or file name) returned when window URL is opened
Definition at line 116 of file RWebWindow.hxx.
|
private |
! callback for disconnect event
Definition at line 133 of file RWebWindow.hxx.
|
private |
! indicate if special window thread was started
Definition at line 136 of file RWebWindow.hxx.
|
private |
! initial window height when displayed
Definition at line 141 of file RWebWindow.hxx.
|
private |
! unique identifier
Definition at line 118 of file RWebWindow.hxx.
|
private |
! input queue for all callbacks
Definition at line 138 of file RWebWindow.hxx.
|
private |
! mutex to protect input queue
Definition at line 139 of file RWebWindow.hxx.
|
private |
! master window where this window is embeded
Definition at line 113 of file RWebWindow.hxx.
|
private |
! channel id in the master window
Definition at line 115 of file RWebWindow.hxx.
|
private |
! master connection id
Definition at line 114 of file RWebWindow.hxx.
|
private |
! maximal number of queue entries
Definition at line 130 of file RWebWindow.hxx.
|
private |
! display manager
Definition at line 112 of file RWebWindow.hxx.
|
private |
! only native connection are allowed, created by Show() method
Definition at line 129 of file RWebWindow.hxx.
|
private |
! timeout in seconds to perform synchronous operation, default 50s
Definition at line 142 of file RWebWindow.hxx.
|
private |
! panel name which should be shown in the window
Definition at line 117 of file RWebWindow.hxx.
|
private |
! list of pending connection with pre-assigned keys
Definition at line 124 of file RWebWindow.hxx.
|
private |
! if window event processing performed in dedicated thread
Definition at line 120 of file RWebWindow.hxx.
|
private |
! protocol
Definition at line 148 of file RWebWindow.hxx.
|
private |
! counter for protocol recording
Definition at line 145 of file RWebWindow.hxx.
|
private |
! connection id, which is used for writing protocol
Definition at line 146 of file RWebWindow.hxx.
|
private |
! local file where communication protocol will be written
Definition at line 144 of file RWebWindow.hxx.
|
private |
! prefix for created files names
Definition at line 147 of file RWebWindow.hxx.
|
private |
! true is special threads should be used for sending data
Definition at line 121 of file RWebWindow.hxx.
|
private |
! arbitrary JSON code, which is accessible via conn.getUserArgs() method
Definition at line 149 of file RWebWindow.hxx.
|
private |
! indicates that server thread is using, no special window thread
Definition at line 119 of file RWebWindow.hxx.
|
private |
! initial window width when displayed
Definition at line 140 of file RWebWindow.hxx.
|
private |
! special thread for that window
Definition at line 137 of file RWebWindow.hxx.
|
private |
! specialize websocket handler for all incoming connections
Definition at line 122 of file RWebWindow.hxx.