33using namespace std::string_literals;
42 fHold->SetTextContent(
"console.log('execute holder script'); if (window) setTimeout (window.close, 1000); if (window) window.close();");
43 fHold->NotifyCondition();
83 std::vector<MasterConn> lst;
89 for (
auto &entry : lst)
90 fMaster->RemoveEmbedWindow(entry.connid, entry.channel);
109 for (
auto &conn : lst) {
110 conn->fActive =
false;
111 for (
auto &elem: conn->fEmbed)
112 elem.second->RemoveMasterConnection();
113 conn->fEmbed.clear();
116 fMgr->Unregister(*
this);
129 if (!
fConn.empty()) {
142std::shared_ptr<RWebWindowWSHandler>
161 return fMgr->GetUrl(*
this, remote);
169 return fMgr->GetServer();
179 return fMgr->ShowWindow(*
this, args);
196 connid =
fMgr->ShowWindow(*
this, args);
212 if (entry->fHeadlessMode)
213 return entry->fConnId;
216 for (
auto &conn :
fConn) {
217 if (conn->fHeadlessMode)
218 return conn->fConnId;
235 if (!entry->fHeadlessMode)
236 return entry->fConnId;
239 for (
auto &conn :
fConn) {
240 if (!conn->fHeadlessMode)
241 return conn->fConnId;
254 for (
auto &conn :
fConn) {
255 if (conn->fWSId == wsid)
263 std::shared_ptr<WebConn> key;
264 std::string keyvalue;
284 fConn.emplace_back(key);
286 fConn.emplace_back(std::make_shared<WebConn>(++
fConnCnt, wsid));
299 std::shared_ptr<WebConn> res;
304 for (
size_t n = 0;
n <
fConn.size(); ++
n)
305 if (
fConn[
n]->fWSId == wsid) {
306 res = std::move(
fConn[
n]);
308 res->fActive =
false;
314 for (
auto &elem: res->fEmbed)
315 elem.second->RemoveMasterConnection(res->fConnId);
344 std::vector<MasterConn> lst;
351 if (!connid || entry.connid == connid)
352 lst.emplace_back(entry);
373 if (iter->connid == connid) {
393 std::string query = arg->GetQuery();
395 if (query.compare(0, 4,
"key=") != 0)
398 std::string key = query.substr(4);
400 std::shared_ptr<THttpCallArg> prev;
402 bool found_key =
false;
408 if (entry->fKey == key) {
411 prev = std::move(entry->fHold);
416 for (
auto &conn :
fConn) {
417 if (conn->fKey == key) {
419 prev = std::move(conn->fHold);
427 prev->SetTextContent(
"console.log('execute holder script'); if (window) window.close();");
428 prev->NotifyCondition();
470 connid = entry.fConnId;
472 arg = std::move(entry.fData);
503 auto conn = std::make_shared<WebConn>(++
fConnCnt, headless_mode, key);
505 std::swap(conn->fDisplayHandle, handle);
522 if (entry->fKey == key)
526 for (
auto &conn :
fConn) {
527 if (conn->fKey == key)
543 return conn ? true :
false;
559 key = std::to_string(rnd.
Integer(0x100000));
560 }
while ((--ntry > 0) &&
HasKey(key));
562 if (ntry <= 0) key.clear();
577 float tmout =
fMgr->GetLaunchTmout();
584 auto pred = [&](std::shared_ptr<WebConn> &
e) {
585 std::chrono::duration<double> diff =
stamp -
e->fSendStamp;
587 if (diff.count() > tmout) {
589 selected.emplace_back(
e);
610 double batch_tmout = 20.;
612 std::vector<std::shared_ptr<WebConn>> clr;
617 auto pred = [&](std::shared_ptr<WebConn> &conn) {
618 std::chrono::duration<double> diff =
stamp - conn->fSendStamp;
620 if ((diff.count() > batch_tmout) && conn->fHeadlessMode) {
621 conn->fActive =
false;
622 clr.emplace_back(conn);
631 for (
auto &entry : clr)
723 if (conn->fKeyUsed > 0) {
724 R__LOG_ERROR(
WebGUILog()) <<
"key " << key <<
" was used for establishing connection, call ShowWindow again";
752 bool do_clear_on_close =
false;
753 if (conn->fKeyUsed < 0) {
765 if (do_clear_on_close)
791 char *str_end =
nullptr;
793 unsigned long ackn_oper = std::strtoul(buf, &str_end, 10);
794 if (!str_end || *str_end !=
':') {
799 unsigned long can_send = std::strtoul(str_end + 1, &str_end, 10);
800 if (!str_end || *str_end !=
':') {
805 unsigned long nchannel = std::strtoul(str_end + 1, &str_end, 10);
806 if (!str_end || *str_end !=
':') {
811 Long_t processed_len = (str_end + 1 - buf);
823 std::lock_guard<std::mutex> grd(conn->fMutex);
825 conn->fSendCredits += ackn_oper;
827 conn->fClientCredits = (
int)can_send;
828 conn->fRecvStamp =
stamp;
836 if ((nchannel != 0) || (cdata.find(
"READY=") == 0)) {
849 if ((cdata.compare(0, 6,
"READY=") == 0) && !conn->fReady) {
851 std::string key = cdata.substr(6);
858 if (!key.empty() && !conn->fKey.empty() && (conn->fKey != key)) {
859 R__LOG_ERROR(
WebGUILog()) <<
"Key mismatch after established connection " << key <<
" != " << conn->fKey;
872 }
else if (cdata.compare(0, 8,
"CLOSECH=") == 0) {
873 int channel = std::stoi(cdata.substr(8));
874 auto iter = conn->fEmbed.find(channel);
875 if (iter != conn->fEmbed.end()) {
877 conn->fEmbed.erase(iter);
879 }
else if (cdata.compare(0, 7,
"RESIZE=") == 0) {
880 auto p = cdata.find(
",");
881 if (
p != std::string::npos) {
882 auto width = std::stoi(cdata.substr(7,
p - 7));
883 auto height = std::stoi(cdata.substr(
p + 1));
884 if ((
width > 0) && (
height > 0) && conn->fDisplayHandle)
887 }
else if (cdata ==
"GENERATE_KEY") {
896 SubmitData(conn->fConnId,
true,
"NEW_KEY="s + newkey, -1);
902 }
else if (
fPanelName.length() && (conn->fReady < 10)) {
903 if (cdata ==
"PANEL_READY") {
911 }
else if (nchannel == 1) {
913 }
else if (nchannel > 1) {
915 auto embed_window = conn->fEmbed[nchannel];
917 embed_window->ProvideQueueEntry(conn->fConnId,
kind_Data, std::move(cdata));
937 std::lock_guard<std::mutex> grd(conn->fMutex);
938 conn->fDoingSend =
false;
957 if (conn->fSendCredits <= 0) {
962 if (conn->fDoingSend) {
968 buf.reserve(
data.length() + 100);
970 buf.append(std::to_string(conn->fRecvCount));
972 buf.append(std::to_string(conn->fSendCredits));
974 conn->fRecvCount = 0;
975 conn->fSendCredits--;
977 buf.append(std::to_string(chid));
982 }
else if (
data.length()==0) {
983 buf.append(
"$$nullbinary$$");
985 buf.append(
"$$binary$$");
997 std::string hdr,
data;
1000 std::lock_guard<std::mutex> grd(conn->fMutex);
1002 if (!conn->fActive || (conn->fSendCredits <= 0) || conn->fDoingSend)
return false;
1004 if (!conn->fQueue.empty()) {
1007 if (!hdr.empty() && !item.
fText)
1010 }
else if ((conn->fClientCredits < 3) && (conn->fRecvCount > 1)) {
1015 if (hdr.empty())
return false;
1017 conn->fDoingSend =
true;
1023 res =
fWSHandler->SendCharStarWS(conn->fWSId, hdr.c_str());
1025 res =
fWSHandler->SendHeaderWS(conn->fWSId, hdr.c_str(),
data.data(),
data.length());
1029 if (res >=0)
return true;
1032 std::lock_guard<std::mutex> grd(conn->fMutex);
1033 conn->fDoingSend =
false;
1051 for (
auto &conn : arr)
1057 }
while (!only_once);
1104 std::string res(
"../");
1105 res.append(
win.GetAddr());
1166 auto sz =
fConn.size();
1206 return ((num >= 0) && (num < (
int)
fConn.size()) &&
fConn[num]->fActive) ?
fConn[num]->fConnId : 0;
1216 std::vector<unsigned> res;
1224 if (entry.connid != excludeid)
1225 res.emplace_back(entry.connid);
1227 for (
auto & entry :
fConn)
1228 if (entry->fActive && (entry->fConnId != excludeid))
1229 res.emplace_back(entry->fConnId);
1244 for (
auto &conn :
fConn) {
1245 if (connid && (conn->fConnId != connid))
1247 if (conn->fActive || !only_active)
1253 if (!connid || (conn->fConnId == connid))
1292 for (
auto &conn :
fConn) {
1293 if ((conn->fActive || !only_active) && (!connid || (conn->fConnId == connid)))
1294 arr.push_back(conn);
1299 if (!connid || (conn->fConnId == connid))
1300 arr.push_back(conn);
1317 for (
auto &conn : arr) {
1319 std::lock_guard<std::mutex> grd(conn->fMutex);
1321 if (
direct && (!conn->fQueue.empty() || (conn->fSendCredits == 0) || conn->fDoingSend))
1324 if (conn->fQueue.size() >= maxqlen)
1341 std::lock_guard<std::mutex> grd(conn->fMutex);
1342 int len = conn->fQueue.size();
1343 if (
len > maxq) maxq =
len;
1360 auto cnt = lst.size();
1361 for (
auto & entry : lst)
1363 fMaster->SubmitData(entry.connid, txt, std::string(
data), entry.channel);
1365 fMaster->SubmitData(entry.connid, txt, std::move(
data), entry.channel);
1370 auto cnt = arr.size();
1373 bool clear_queue =
false;
1382 for (
auto &conn : arr) {
1388 fname.append(
"msg");
1391 fname.append(
"_ch");
1392 fname.append(std::to_string(chid));
1394 fname.append(txt ?
".txt" :
".bin");
1396 std::ofstream ofs(fname);
1397 ofs.write(
data.c_str(),
data.length());
1409 conn->fSendStamp =
stamp;
1411 std::lock_guard<std::mutex> grd(conn->fMutex);
1414 while (!conn->fQueue.empty())
1418 if (conn->fQueue.size() < maxqlen) {
1420 conn->fQueue.emplace(chid, txt, std::string(
data));
1422 conn->fQueue.emplace(chid, txt, std::move(
data));
1461 std::copy((
const char *)
data, (
const char *)
data +
len, buf.begin());
1462 SubmitData(connid,
false, std::move(buf), 1);
1481 }
else if (
fMgr->IsUseHttpThread()) {
1483 R__LOG_ERROR(
WebGUILog()) <<
"create web window from main thread when THttpServer created with special thread - not supported";
1516 std::thread thrd([
this] {
1618 return fMgr->WaitFor(*
this, check);
1646 return fMgr->WaitFor(*
this, check,
true, duration);
1679 if (arr.size() == 0)
1683 if (arr[0]->fEmbed.find(channel) != arr[0]->fEmbed.end())
1686 arr[0]->fEmbed[channel] = window;
1688 return arr[0]->fConnId;
1698 for (
auto &conn : arr) {
1699 auto iter = conn->fEmbed.find(channel);
1700 if (iter != conn->fEmbed.end())
1701 conn->fEmbed.erase(iter);
1730 std::swap(arr1,
fConn);
1748 if (args.
fMaster && window->fMaster && window->fMaster != args.
fMaster) {
1757 window->RemoveMasterConnection(connid);
1771 return window->Show(args);
1792 return msg.compare(0, 11,
"FILEDIALOG:") == 0;
#define R__LOG_WARNING(...)
#define R__LOG_ERROR(...)
#define R__LOG_DEBUG(DEBUGLEVEL,...)
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t stamp
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t win
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
R__EXTERN TSystem * gSystem
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
EBrowserKind GetBrowserKind() const
returns configured browser kind, see EBrowserKind for supported values
unsigned fMasterConnection
! used master connection
int fMasterChannel
! used master channel
std::shared_ptr< RWebWindow > fMaster
! master window
@ kEmbedded
window will be embedded into other, no extra browser need to be started
void SetHeadless(bool on=true)
set headless mode
static int GetBoolEnv(const std::string &name, int dfl=-1)
Parse boolean gEnv variable which should be "yes" or "no".
Represents web window, which can be shown in web browser or any other supported environment.
bool CheckDataToSend(std::shared_ptr< WebConn > &conn)
Checks if one should send data for specified connection Returns true when send operation was performe...
int WaitFor(WebWindowWaitFunc_t check)
Waits until provided check function or lambdas returns non-zero value Check function has following si...
unsigned GetId() const
Returns ID for the window - unique inside window manager.
std::vector< MasterConn > GetMasterConnections(unsigned connid=0) const
Get list of master connections.
void AddMasterConnection(std::shared_ptr< RWebWindow > window, unsigned connid, int channel)
Add new master connection If there are many connections - only same master is allowed.
std::mutex fConnMutex
! mutex used to protect connection list
WebWindowDataCallback_t fDataCallback
! main callback when data over channel 1 is arrived
void CheckInactiveConnections()
Check if there are connection which are inactive for longer time For instance, batch browser will be ...
unsigned fId
! unique identifier
bool fHasWindowThrd
! indicate if special window thread was started
std::vector< MasterConn > fMasterConns
! master connections
void SetClearOnClose(const std::shared_ptr< void > &handle=nullptr)
Set handle which is cleared when last active connection is closed Typically can be used to destroy we...
void StartThread()
Start special thread which will be used by the window to handle all callbacks One has to be sure,...
unsigned fConnCnt
! counter of new connections to assign ids
unsigned fProtocolConnId
! connection id, which is used for writing protocol
ConnectionsList_t GetWindowConnections(unsigned connid=0, bool only_active=false) const
returns connection list (or all active connections)
bool fSendMT
! true is special threads should be used for sending data
std::thread::id fCallbacksThrdId
! thread id where callbacks should be invoked
std::queue< QueueEntry > fInputQueue
! input queue for all callbacks
void SetConnToken(const std::string &token="")
Configures connection token (default none) When specified, in URL of webpage such token should be pro...
unsigned MakeHeadless(bool create_new=false)
Start headless browser for specified window Normally only single instance is used,...
std::string GetUrl(bool remote=true)
Return URL string to access web window.
void CloseConnections()
Closes all connection to clients Normally leads to closing of all correspondent browser windows Some ...
std::shared_ptr< RWebWindow > fMaster
! master window where this window is embedded
int NumConnections(bool with_pending=false) const
Returns current number of active clients connections.
bool fCallbacksThrdIdSet
! flag indicating that thread id is assigned
std::string fUserArgs
! arbitrary JSON code, which is accessible via conn.getUserArgs() method
void SetDefaultPage(const std::string &page)
Set content of default window HTML page This page returns when URL address of the window will be requ...
unsigned fConnLimit
! number of allowed active connections
void InvokeCallbacks(bool force=false)
Invoke callbacks with existing data Must be called from appropriate thread.
std::string GetClientVersion() const
Returns current client version.
void SetConnectCallBack(WebWindowConnectCallback_t func)
Set call-back function for new connection.
void Sync()
Special method to process all internal activity when window runs in separate thread.
void UseServerThreads()
Let use THttpServer threads to process requests WARNING!!! only for expert use Should be only used wh...
void TerminateROOT()
Terminate ROOT session Tries to correctly close THttpServer, associated with RWebWindowsManager After...
void Send(unsigned connid, const std::string &data)
Sends data to specified connection.
unsigned Show(const RWebDisplayArgs &args="")
Show window in specified location.
THttpServer * GetServer()
Return THttpServer instance serving requests to the window.
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 cl...
std::vector< std::shared_ptr< WebConn > > ConnectionsList_t
void AssignThreadId()
Assign thread id which has to be used for callbacks WARNING!!! only for expert use Automatically done...
bool IsNativeOnlyConn() const
returns true if only native (own-created) connections are allowed
void SendBinary(unsigned connid, const void *data, std::size_t len)
Send binary data to specified connection.
static std::shared_ptr< RWebWindow > Create()
Create new RWebWindow Using default RWebWindowsManager.
std::string fClientVersion
! configured client version, used as prefix in scripts URL
bool ProcessBatchHolder(std::shared_ptr< THttpCallArg > &arg)
Process special http request, used to hold headless browser running Such requests should not be repli...
unsigned AddEmbedWindow(std::shared_ptr< RWebWindow > window, unsigned connid, int channel)
Add embed window.
std::shared_ptr< WebConn > FindConnection(unsigned wsid)
Find connection with specified websocket id.
void SetDisconnectCallBack(WebWindowConnectCallback_t func)
Set call-back function for disconnecting.
std::vector< unsigned > GetConnections(unsigned excludeid=0) const
returns vector with all existing connections ids One also can exclude specified connection from retur...
void SetDataCallBack(WebWindowDataCallback_t func)
Set call-back function for data, received from the clients via websocket.
float fOperationTmout
! timeout in seconds to perform synchronous operation, default 50s
static std::function< bool(const std::shared_ptr< RWebWindow > &, unsigned, const std::string &)> gStartDialogFunc
void SetUserArgs(const std::string &args)
Set arbitrary JSON data, which is accessible via conn.getUserArgs() method in JavaScript This JSON co...
std::string fConnToken
! value of "token" URL parameter which should be provided for connecting window
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...
std::shared_ptr< RWebWindowWSHandler > fWSHandler
! specialize websocket handler for all incoming connections
void StopThread()
Stop special thread.
void SubmitData(unsigned connid, bool txt, std::string &&data, int chid=1)
Internal method to send data.
~RWebWindow()
RWebWindow destructor Closes all connections and remove window from manager.
static bool EmbedFileDialog(const std::shared_ptr< RWebWindow > &window, unsigned connid, const std::string &args)
Create dialog instance to use as embedded dialog inside provided widget Loads libROOTBrowserv7 and tr...
void CloseConnection(unsigned connid)
Close specified connection.
ConnectionsList_t fPendingConn
! list of pending connection with pre-assigned keys
unsigned GetConnectionId(int num=0) const
Returns connection id for specified connection sequence number Only active connections are returned -...
std::string GetConnToken() const
Returns configured connection token.
float GetOperationTmout() const
Returns timeout for synchronous WebWindow operations.
void SetConnLimit(unsigned lmt=0)
Configure maximal number of allowed connections - 0 is unlimited Will not affect already existing con...
void SetPanelName(const std::string &name)
Configure window to show some of existing JSROOT panels It uses "file:rootui5sys/panel/panel....
RWebWindow()
RWebWindow constructor Should be defined here because of std::unique_ptr<RWebWindowWSHandler>
std::shared_ptr< WebConn > FindOrCreateConnection(unsigned wsid, bool make_new, const char *query)
Find connection with given websocket id.
std::string fProtocolPrefix
! prefix for created files names
int GetSendQueueLength(unsigned connid) const
Returns send queue length for specified connection.
std::shared_ptr< WebConn > RemoveConnection(unsigned wsid)
Remove connection with given websocket id.
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 c...
std::string fProtocol
! protocol
std::shared_ptr< WebConn > _FindConnWithKey(const std::string &key) const
Find connection with specified key.
bool CanSend(unsigned connid, bool direct=true) const
Returns true if sending via specified connection can be performed.
std::string GetUserArgs() const
Returns configured user arguments for web window See SetUserArgs method for more details.
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 J...
bool fUseProcessEvents
! all window functionality will run through process events
bool HasKey(const std::string &key) const
Returns true if provided key value already exists (in processes map or in existing connections)
unsigned GetDisplayConnection() const
Returns first connection id where window is displayed It could be that connection(s) not yet fully es...
unsigned GetConnLimit() const
returns configured connections limit (0 - default)
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 ...
static void SetStartDialogFunc(std::function< bool(const std::shared_ptr< RWebWindow > &, unsigned, const std::string &)>)
Configure func which has to be used for starting dialog.
std::string fPanelName
! panel name which should be shown in the window
void Run(double tm=0.)
Run window functionality for specified time If no action can be performed - just sleep specified time...
std::string GetAddr() const
Returns window address which is used in URL.
std::shared_ptr< RWebWindowsManager > fMgr
! display manager
std::string fProtocolFileName
! local file where communication protocol will be written
ConnectionsList_t fConn
! list of all accepted connections
WebWindowConnectCallback_t fConnCallback
! callback for connect event
void CheckPendingConnections()
Check if started process(es) establish connection.
std::shared_ptr< void > fClearOnClose
! entry which is cleared when last connection is closed
std::mutex fInputQueueMutex
! mutex to protect input queue
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.
std::chrono::time_point< std::chrono::system_clock > timestamp_t
bool ProcessWS(THttpCallArg &arg)
Processing of websockets call-backs, invoked from RWebWindowWSHandler Method invoked from http server...
bool HasConnection(unsigned connid=0, bool only_active=true) const
returns true if specified connection id exists
std::thread fWindowThrd
! special thread for that window
void ProvideQueueEntry(unsigned connid, EQueueEntryKind kind, std::string &&arg)
Provide data to user callback User callback must be executed in the window thread.
void CompleteWSSend(unsigned wsid)
Complete websocket send operation Clear "doing send" flag and check if next operation has to be start...
bool fUseServerThreads
! indicates that server thread is using, no special window thread
unsigned FindHeadlessConnection()
Returns connection id of window running in headless mode This can be special connection which may run...
int WaitForTimed(WebWindowWaitFunc_t check)
Waits until provided check function or lambdas returns non-zero value Check function has following si...
bool fProcessMT
! if window event processing performed in dedicated thread
int fProtocolCnt
! counter for protocol recording
void SetClientVersion(const std::string &vers)
Set client version, used as prefix in scripts URL When changed, web browser will reload all related J...
void RemoveMasterConnection(unsigned connid=0)
Remove master connection - if any.
void RemoveEmbedWindow(unsigned connid, int channel)
Remove RWebWindow associated with the channelfEmbed.
void SetCallBacks(WebWindowConnectCallback_t conn, WebWindowDataCallback_t data, WebWindowConnectCallback_t disconn=nullptr)
Set call-backs function for connect, data and disconnect events.
std::string GenerateKey() const
Generate new unique key for the window.
WebWindowConnectCallback_t fDisconnCallback
! callback for disconnect event
unsigned GetMaxQueueLength() const
Return maximal queue length of data which can be held by window.
static bool IsFileDialogMessage(const std::string &msg)
Check if this could be the message send by client to start new file dialog If returns true,...
static bool IsMainThrd()
Returns true when called from main process Main process recognized at the moment when library is load...
static std::shared_ptr< RWebWindowsManager > & Instance()
Returns default window manager Used to display all standard ROOT elements like TCanvas or TFitPanel.
Contains arguments for single HTTP call.
UInt_t GetWSId() const
get web-socket id
const void * GetPostData() const
return pointer on posted with request data
const char * GetQuery() const
returns request query (string after ? in request URL)
Long_t GetPostDataLength() const
return length of posted with request data
Bool_t IsMethod(const char *name) const
returns kTRUE if post method is used
Online http server for arbitrary ROOT application.
Random number generator class based on M.
void SetSeed(ULong_t seed=0) override
Set the random generator sequence if seed is 0 (default value) a TUUID is generated and used to fill ...
virtual UInt_t Integer(UInt_t imax)
Returns a random integer uniformly distributed on the interval [ 0, imax-1 ].
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
This class represents a WWW compatible URL.
const char * GetValueFromOptions(const char *key) const
Return a value for a given key from the URL options.
void SetOptions(const char *opt)
Bool_t HasOption(const char *key) const
Returns true if the given key appears in the URL options list.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
std::function< void(unsigned, const std::string &)> WebWindowDataCallback_t
function signature for call-backs from the window clients first argument is connection id,...
ROOT::Experimental::RLogChannel & WebGUILog()
Log channel for WebGUI diagnostics.
std::function< void(unsigned)> WebWindowConnectCallback_t
function signature for connect/disconnect call-backs argument is connection id
std::function< int(double)> WebWindowWaitFunc_t
function signature for waiting call-backs Such callback used when calling thread need to waits for so...
std::string fData
! text or binary data
std::shared_ptr< THttpCallArg > fHold
! request used to hold headless browser
~WebConn()
Destructor for WebConn Notify special HTTP request which blocks headless browser from exit.