13#ifndef ROOT7_RWebWindowWSHandler
14#define ROOT7_RWebWindowWSHandler
24using namespace std::string_literals;
43 auto token =
fWindow.GetConnToken();
50 arg->SetContent(
"refused");
56 if (
fWindow.IsRequireAuthKey()) {
62 arg->SetContent(
"refused");
68 auto version =
fWindow.GetClientVersion();
69 if (!version.empty()) {
71 std::string search =
"from './jsrootsys/"s;
72 std::string replace =
"from './"s + version +
"/jsrootsys/"s;
73 arg->ReplaceAllinContent(search, replace);
75 search =
"from './rootui5sys/"s;
76 replace =
"from './"s + version +
"/rootui5sys/"s;
77 arg->ReplaceAllinContent(search, replace);
79 search =
"jsrootsys/scripts/JSRoot.core."s;
80 replace = version +
"/jsrootsys/scripts/JSRoot.core."s;
81 arg->ReplaceAllinContent(search, replace,
true);
82 arg->AddNoCacheHeader();
85 std::string more_args;
87 std::string wskind = arg->GetWSKind();
88 if ((wskind ==
"websocket") && (
GetBoolEnv(
"WebGui.WSLongpoll") == 1))
90 if (!wskind.empty() && (wskind !=
"websocket"))
91 more_args.append(
"socket_kind: \""s + wskind +
"\","s);
92 std::string wsplatform = arg->GetWSPlatform();
93 if (!wsplatform.empty() && (wsplatform !=
"http"))
94 more_args.append(
"platform: \""s + wsplatform +
"\","s);
95 const char *ui5source =
gEnv->GetValue(
"WebGui.openui5src",
"");
96 if (ui5source && *ui5source)
97 more_args.append(
"openui5src: \""s + ui5source +
"\","s);
98 const char *ui5libs =
gEnv->GetValue(
"WebGui.openui5libs",
"");
99 if (ui5libs && *ui5libs)
100 more_args.append(
"openui5libs: \""s + ui5libs +
"\","s);
101 const char *ui5theme =
gEnv->GetValue(
"WebGui.openui5theme",
"");
102 if (ui5theme && *ui5theme)
103 more_args.append(
"openui5theme: \""s + ui5theme +
"\","s);
105 more_args.append(
"dark: true,"s);
106 int credits =
gEnv->GetValue(
"WebGui.ConnCredits", 10);
107 if ((credits > 0) && (credits != 10))
108 more_args.append(
"credits: "s + std::to_string(credits) +
","s);
110 more_args.append(
"winW:"s + std::to_string(
fWindow.GetWidth()) +
",winH:"s + std::to_string(
fWindow.GetHeight()) +
","s);
112 more_args.append(
"winX:"s + std::to_string(
fWindow.GetX()) +
",winY:"s + std::to_string(
fWindow.GetY()) +
","s);
114 more_args.append(
"debug: true,");
115 auto user_args =
fWindow.GetUserArgs();
116 if (!user_args.empty())
117 more_args.append(
"user_args: "s + user_args +
","s);
120 if (!more_args.empty()) {
121 std::string search =
"connectWebWindow({"s;
122 std::string replace = search + more_args;
123 arg->ReplaceAllinContent(search, replace,
true);
124 arg->AddNoCacheHeader();
151 return fWindow.ProcessWS(*arg);
bool Bool_t
Boolean (0=false, 1=true) (bool).
std::string GetCodeVersion() override
Method generate extra suffix for all kinds of loaded code.
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.
static std::string gJSROOTsettings
! custom settings for JSROOT
Contains arguments for single HTTP call.
Bool_t IsDisabled() const
Returns true when processing of websockets is disabled, set shortly before handler need to be destroy...
THttpWSHandler(const char *name, const char *title, Bool_t syncmode=kTRUE)
normal constructor
const char * Data() const
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.