13#ifndef ROOT7_RWebWindowWSHandler
14#define ROOT7_RWebWindowWSHandler
24using namespace std::string_literals;
47 arg->SetContent(
"refused");
54 if (!version.empty()) {
56 std::string search =
"from './jsrootsys/"s;
57 std::string replace =
"from './"s + version +
"/jsrootsys/"s;
58 arg->ReplaceAllinContent(search, replace);
60 search =
"from './rootui5sys/"s;
61 replace =
"from './"s + version +
"/rootui5sys/"s;
62 arg->ReplaceAllinContent(search, replace);
64 search =
"jsrootsys/scripts/JSRoot.core."s;
65 replace = version +
"/jsrootsys/scripts/JSRoot.core."s;
66 arg->ReplaceAllinContent(search, replace,
true);
67 arg->AddNoCacheHeader();
70 std::string more_args;
72 std::string wskind = arg->GetWSKind();
73 if ((wskind ==
"websocket") && (
GetBoolEnv(
"WebGui.WSLongpoll") == 1))
75 if (!wskind.empty() && (wskind !=
"websocket"))
76 more_args.append(
"socket_kind: \""s + wskind +
"\","s);
77 std::string wsplatform = arg->GetWSPlatform();
78 if (!wsplatform.empty() && (wsplatform !=
"http"))
79 more_args.append(
"platform: \""s + wsplatform +
"\","s);
80 const char *ui5source =
gEnv->
GetValue(
"WebGui.openui5src",
"");
81 if (ui5source && *ui5source)
82 more_args.append(
"openui5src: \""s + ui5source +
"\","s);
83 const char *ui5libs =
gEnv->
GetValue(
"WebGui.openui5libs",
"");
84 if (ui5libs && *ui5libs)
85 more_args.append(
"openui5libs: \""s + ui5libs +
"\","s);
86 const char *ui5theme =
gEnv->
GetValue(
"WebGui.openui5theme",
"");
87 if (ui5theme && *ui5theme)
88 more_args.append(
"openui5theme: \""s + ui5theme +
"\","s);
90 if ((credits > 0) && (credits != 10))
91 more_args.append(
"credits: "s + std::to_string(credits) +
","s);
95 more_args.append(
"winX:"s + std::to_string(
fWindow.
GetX()) +
",winY:"s + std::to_string(
fWindow.
GetY()) +
","s);
97 if (!user_args.empty())
98 more_args.append(
"user_args: "s + user_args +
","s);
99 if (!more_args.empty()) {
100 std::string search =
"connectWebWindow({"s;
101 std::string replace = search + more_args;
102 arg->ReplaceAllinContent(search, replace,
true);
103 arg->AddNoCacheHeader();
just wrapper to deliver websockets call-backs to the RWebWindow class
RWebWindow & fWindow
! window reference
~RWebWindowWSHandler() override=default
Bool_t AllowMTSend() const override
Allows usage of special threads for send operations.
Bool_t CanServeFiles() const override
returns true when window allowed to serve files relative to default page
Bool_t ProcessWS(THttpCallArg *arg) override
Process websocket request - called from THttpServer thread THttpWSHandler interface.
Bool_t ProcessBatchHolder(std::shared_ptr< THttpCallArg > &arg) override
Method used to accept or reject root_batch_holder.js request.
Bool_t AllowMTProcess() const override
Allow processing of WS actions in arbitrary thread.
void VerifyDefaultPageContent(std::shared_ptr< THttpCallArg > &arg) override
Method called when default page content is prepared for use By default no-cache header is provided.
void CompleteWSSend(UInt_t wsid) override
React on completion of multi-threaded send operation.
static int GetBoolEnv(const std::string &name, int dfl=-1)
Parse boolean gEnv variable which should be "yes" or "no".
TString GetDefaultPageContent() override
returns content of default web-page THttpWSHandler interface
RWebWindowWSHandler(RWebWindow &wind, const char *name)
constructor
Represents web window, which can be shown in web browser or any other supported environment.
std::string fDefaultPage
! HTML page (or file name) returned when window URL is opened
bool fSendMT
! true is special threads should be used for sending data
std::string GetClientVersion() const
Returns current client version.
int GetX() const
returns configured window X position (-1 - default)
bool ProcessBatchHolder(std::shared_ptr< THttpCallArg > &arg)
Process special http request, used to hold headless browser running Such requests should not be repli...
unsigned GetHeight() const
returns configured window height (0 - default)
std::string GetConnToken() const
Returns configured connection token.
std::string GetUserArgs() const
Returns configured user arguments for web window See SetUserArgs method for more details.
int GetY() const
returns configured window Y position (-1 - default)
bool ProcessWS(THttpCallArg &arg)
Processing of websockets call-backs, invoked from RWebWindowWSHandler Method invoked from http server...
unsigned GetWidth() const
returns configured window width (0 - default) actual window width can be different
void CompleteWSSend(unsigned wsid)
Complete websocket send operation Clear "doing send" flag and check if next operation has to be start...
bool fProcessMT
! if window event processing performed in dedicated thread
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Contains arguments for single HTTP call.
Class for user-side handling of websocket with THttpServer.
Bool_t IsDisabled() const
Returns true when processing of websockets is disabled, set shortly before handler need to be destroy...
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.