Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RWebWindow.hxx
Go to the documentation of this file.
1// Author: Sergey Linev <s.linev@gsi.de>
2// Date: 2017-10-16
3// Warning: This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
4
5/*************************************************************************
6 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#ifndef ROOT7_RWebWindow
14#define ROOT7_RWebWindow
15
17
18#include <memory>
19#include <vector>
20#include <string>
21#include <queue>
22#include <map>
23#include <functional>
24#include <mutex>
25#include <thread>
26#include <chrono>
27
28class THttpCallArg;
29class THttpServer;
30
31namespace ROOT {
32namespace Experimental {
33
34
35/// function signature for connect/disconnect call-backs
36/// argument is connection id
37using WebWindowConnectCallback_t = std::function<void(unsigned)>;
38
39/// function signature for call-backs from the window clients
40/// first argument is connection id, second is received data
41using WebWindowDataCallback_t = std::function<void(unsigned, const std::string &)>;
42
43/// function signature for waiting call-backs
44/// Such callback used when calling thread need to waits for some special data,
45/// but wants to run application event loop
46/// As argument, spent time in second will be provided
47/// Waiting will be performed until function returns non-zero value
48using WebWindowWaitFunc_t = std::function<int(double)>;
49
52
54
55 friend class RWebWindowsManager;
56 friend class RWebWindowWSHandler;
57 friend class RWebDisplayHandle;
58
59private:
60 using timestamp_t = std::chrono::time_point<std::chrono::system_clock>;
61
62 struct QueueItem {
63 int fChID{1}; ///<! channel
64 bool fText{true}; ///<! is text data
65 std::string fData; ///<! text or binary data
66 QueueItem(int chid, bool txt, std::string &&data) : fChID(chid), fText(txt), fData(data) {}
67 };
68
69 struct WebConn {
70 unsigned fConnId{0}; ///<! connection id (unique inside the window)
71 bool fHeadlessMode{false}; ///<! indicate if connection represent batch job
72 std::string fKey; ///<! key value supplied to the window (when exists)
73 std::unique_ptr<RWebDisplayHandle> fDisplayHandle; ///<! handle assigned with started web display (when exists)
74 std::shared_ptr<THttpCallArg> fHold; ///<! request used to hold headless browser
75 timestamp_t fSendStamp; ///<! last server operation, always used from window thread
76 bool fActive{false}; ///<! flag indicates if connection is active
77 unsigned fWSId{0}; ///<! websocket id
78 int fReady{0}; ///<! 0 - not ready, 1..9 - interim, 10 - done
79 mutable std::mutex fMutex; ///<! mutex must be used to protect all following data
80 timestamp_t fRecvStamp; ///<! last receive operation, protected with connection mutex
81 int fRecvCount{0}; ///<! number of received packets, should return back with next sending
82 int fSendCredits{0}; ///<! how many send operation can be performed without confirmation from other side
83 int fClientCredits{0}; ///<! number of credits received from client
84 bool fDoingSend{false}; ///<! true when performing send operation
85 std::queue<QueueItem> fQueue; ///<! output queue
86 std::map<int,std::shared_ptr<RWebWindow>> fEmbed; ///<! map of embed window for that connection, key value is channel id
87 WebConn() = default;
88 WebConn(unsigned connid) : fConnId(connid) {}
89 WebConn(unsigned connid, unsigned wsid) : fConnId(connid), fActive(true), fWSId(wsid) {}
90 WebConn(unsigned connid, bool headless_mode, const std::string &key)
91 : fConnId(connid), fHeadlessMode(headless_mode), fKey(key)
92 {
94 }
95 ~WebConn();
96
97 void ResetStamps() { fSendStamp = fRecvStamp = std::chrono::system_clock::now(); }
98 };
99
101
102 struct QueueEntry {
103 unsigned fConnId{0}; ///<! connection id
104 EQueueEntryKind fKind{kind_None}; ///<! kind of data
105 std::string fData; ///<! data for given connection
106 QueueEntry() = default;
107 QueueEntry(unsigned connid, EQueueEntryKind kind, std::string &&data) : fConnId(connid), fKind(kind), fData(data) {}
108 };
109
110 using ConnectionsList_t = std::vector<std::shared_ptr<WebConn>>;
111
112 std::shared_ptr<RWebWindowsManager> fMgr; ///<! display manager
113 std::shared_ptr<RWebWindow> fMaster; ///<! master window where this window is embeded
114 unsigned fMasterConnId{0}; ///<! master connection id
115 int fMasterChannel{-1}; ///<! channel id in the master window
116 std::string fDefaultPage; ///<! HTML page (or file name) returned when window URL is opened
117 std::string fPanelName; ///<! panel name which should be shown in the window
118 unsigned fId{0}; ///<! unique identifier
119 bool fUseServerThreads{false}; ///<! indicates that server thread is using, no special window thread
120 bool fProcessMT{false}; ///<! if window event processing performed in dedicated thread
121 bool fSendMT{false}; ///<! true is special threads should be used for sending data
122 std::shared_ptr<RWebWindowWSHandler> fWSHandler; ///<! specialize websocket handler for all incoming connections
123 unsigned fConnCnt{0}; ///<! counter of new connections to assign ids
124 ConnectionsList_t fPendingConn; ///<! list of pending connection with pre-assigned keys
125 ConnectionsList_t fConn; ///<! list of all accepted connections
126 mutable std::mutex fConnMutex; ///<! mutex used to protect connection list
127 unsigned fConnLimit{1}; ///<! number of allowed active connections
128 std::string fConnToken; ///<! value of "token" URL parameter which should be provided for connecting window
129 bool fNativeOnlyConn{false}; ///<! only native connection are allowed, created by Show() method
130 unsigned fMaxQueueLength{10}; ///<! maximal number of queue entries
131 WebWindowConnectCallback_t fConnCallback; ///<! callback for connect event
132 WebWindowDataCallback_t fDataCallback; ///<! main callback when data over channel 1 is arrived
133 WebWindowConnectCallback_t fDisconnCallback; ///<! callback for disconnect event
134 std::thread::id fCallbacksThrdId; ///<! thread id where callbacks should be invoked
135 bool fCallbacksThrdIdSet{false}; ///<! flag indicating that thread id is assigned
136 bool fHasWindowThrd{false}; ///<! indicate if special window thread was started
137 std::thread fWindowThrd; ///<! special thread for that window
138 std::queue<QueueEntry> fInputQueue; ///<! input queue for all callbacks
139 std::mutex fInputQueueMutex; ///<! mutex to protect input queue
140 unsigned fWidth{0}; ///<! initial window width when displayed
141 unsigned fHeight{0}; ///<! initial window height when displayed
142 float fOperationTmout{50.}; ///<! timeout in seconds to perform synchronous operation, default 50s
143 std::string fClientVersion; ///<! configured client version, used as prefix in scripts URL
144 std::string fProtocolFileName; ///<! local file where communication protocol will be written
145 int fProtocolCnt{-1}; ///<! counter for protocol recording
146 unsigned fProtocolConnId{0}; ///<! connection id, which is used for writing protocol
147 std::string fProtocolPrefix; ///<! prefix for created files names
148 std::string fProtocol; ///<! protocol
149 std::string fUserArgs; ///<! arbitrary JSON code, which is accessible via conn.getUserArgs() method
150
151 std::shared_ptr<RWebWindowWSHandler> CreateWSHandler(std::shared_ptr<RWebWindowsManager> mgr, unsigned id, double tmout);
152
153 bool ProcessWS(THttpCallArg &arg);
154
155 void CompleteWSSend(unsigned wsid);
156
157 ConnectionsList_t GetConnections(unsigned connid = 0, bool only_active = false) const;
158
159 std::shared_ptr<WebConn> FindOrCreateConnection(unsigned wsid, bool make_new, const char *query);
160
161 /// Find connection with specified websocket id
162 std::shared_ptr<WebConn> FindConnection(unsigned wsid) { return FindOrCreateConnection(wsid, false, nullptr); }
163
164 std::shared_ptr<WebConn> RemoveConnection(unsigned wsid);
165
166 std::string _MakeSendHeader(std::shared_ptr<WebConn> &conn, bool txt, const std::string &data, int chid);
167
168 void ProvideQueueEntry(unsigned connid, EQueueEntryKind kind, std::string &&arg);
169
170 void InvokeCallbacks(bool force = false);
171
172 void SubmitData(unsigned connid, bool txt, std::string &&data, int chid = 1);
173
174 bool CheckDataToSend(std::shared_ptr<WebConn> &conn);
175
176 void CheckDataToSend(bool only_once = false);
177
178 bool HasKey(const std::string &key) const;
179
181
183
184 unsigned AddDisplayHandle(bool headless_mode, const std::string &key, std::unique_ptr<RWebDisplayHandle> &handle);
185
186 unsigned AddEmbedWindow(std::shared_ptr<RWebWindow> window, int channel);
187
188 void RemoveEmbedWindow(unsigned connid, int channel);
189
190 bool ProcessBatchHolder(std::shared_ptr<THttpCallArg> &arg);
191
192 std::string GetConnToken() const;
193
194 unsigned MakeHeadless(bool create_new = false);
195
196 unsigned FindHeadlessConnection();
197
198 void CheckThreadAssign();
199
200public:
201
203
204 ~RWebWindow();
205
206 /// Returns ID for the window - unique inside window manager
207 unsigned GetId() const { return fId; }
208
209 /// Returns window manager
210 std::shared_ptr<RWebWindowsManager> GetManager() const { return fMgr; }
211
212 /// Set content of default window HTML page
213 /// This page returns when URL address of the window will be requested
214 /// Either HTML code or file name in the form "file:/home/user/data/file.htm"
215 /// One also can using default locations like "file:rootui5sys/canv/canvas.html"
216 void SetDefaultPage(const std::string &page) { fDefaultPage = page; }
217
218 void SetPanelName(const std::string &name);
219
220 /// Set window geometry. Will be applied if supported by used web display (like CEF or Chromium)
221 void SetGeometry(unsigned width, unsigned height)
222 {
223 fWidth = width;
224 fHeight = height;
225 }
226
227 /////////////////////////////////////////////////////////////////////////
228 /// returns configured window width (0 - default)
229 /// actual window width can be different
230 unsigned GetWidth() const { return fWidth; }
231
232 /////////////////////////////////////////////////////////////////////////
233 /// returns configured window height (0 - default)
234 unsigned GetHeight() const { return fHeight; }
235
236 void SetConnLimit(unsigned lmt = 0);
237
238 unsigned GetConnLimit() const;
239
240 void SetConnToken(const std::string &token = "");
241
242 /////////////////////////////////////////////////////////////////////////
243 /// configures maximal queue length of data which can be held by window
244 void SetMaxQueueLength(unsigned len = 10) { fMaxQueueLength = len; }
245
246 /////////////////////////////////////////////////////////////////////////
247 /// Return maximal queue length of data which can be held by window
248 unsigned GetMaxQueueLength() const { return fMaxQueueLength; }
249
250 /////////////////////////////////////////////////////////////////////////
251 /// configures that only native (own-created) connections are allowed
252 void SetNativeOnlyConn(bool on = true) { fNativeOnlyConn = on; }
253
254 /////////////////////////////////////////////////////////////////////////
255 /// returns true if only native (own-created) connections are allowed
256 bool IsNativeOnlyConn() const { return fNativeOnlyConn; }
257
258 void SetClientVersion(const std::string &vers);
259
260 std::string GetClientVersion() const;
261
262 void SetUserArgs(const std::string &args);
263
264 std::string GetUserArgs() const;
265
266 int NumConnections(bool with_pending = false) const;
267
268 unsigned GetConnectionId(int num = 0) const;
269
270 bool HasConnection(unsigned connid = 0, bool only_active = true) const;
271
272 void CloseConnections();
273
274 void CloseConnection(unsigned connid);
275
276 /// Returns timeout for synchronous WebWindow operations
277 float GetOperationTmout() const { return fOperationTmout; }
278
279 /// Set timeout for synchronous WebWindow operations
280 void SetOperationTmout(float tm = 50.) { fOperationTmout = tm; }
281
282 std::string GetUrl(bool remote = true);
283
285
286 void Sync();
287
288 void Run(double tm = 0.);
289
290 unsigned Show(const RWebDisplayArgs &args = "");
291
292 unsigned GetDisplayConnection() const;
293
294 /// Returns true when window was shown at least once
295 bool IsShown() const { return GetDisplayConnection() != 0; }
296
297 bool CanSend(unsigned connid, bool direct = true) const;
298
299 int GetSendQueueLength(unsigned connid) const;
300
301 void Send(unsigned connid, const std::string &data);
302
303 void SendBinary(unsigned connid, const void *data, std::size_t len);
304
305 void SendBinary(unsigned connid, std::string &&data);
306
307 void RecordData(const std::string &fname = "protocol.json", const std::string &fprefix = "");
308
309 std::string GetAddr() const;
310
311 std::string GetRelativeAddr(const std::shared_ptr<RWebWindow> &win) const;
312
313 std::string GetRelativeAddr(const RWebWindow &win) const;
314
316
318
320
322
323 void AssignThreadId();
324
325 void UseServerThreads();
326
327 int WaitFor(WebWindowWaitFunc_t check);
328
330
331 int WaitForTimed(WebWindowWaitFunc_t check, double duration);
332
333 void StartThread();
334
335 void StopThread();
336
337 void TerminateROOT();
338
339 static std::shared_ptr<RWebWindow> Create();
340
341 static unsigned ShowWindow(std::shared_ptr<RWebWindow> window, const RWebDisplayArgs &args = "");
342
343};
344
345} // namespace Experimental
346} // namespace ROOT
347
348#endif
typedef void(GLAPIENTRYP _GLUfuncptr)(void)
include TDocParser_001 C image html pict1_TDocParser_001 png width
char name[80]
Definition TGX11.cxx:110
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
Handle of created web-based display Depending from type of web display, holds handle of started brows...
just wrapper to deliver websockets call-backs to the RWebWindow class
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...
std::vector< std::shared_ptr< WebConn > > ConnectionsList_t
int WaitFor(WebWindowWaitFunc_t check)
Waits until provided check function or lambdas returns non-zero value Check function has following si...
std::string fDefaultPage
! HTML page (or file name) returned when window URL is opened
unsigned AddEmbedWindow(std::shared_ptr< RWebWindow > window, int channel)
Add embed window.
std::shared_ptr< RWebWindow > fMaster
! master window where this window is embeded
void CheckInactiveConnections()
Check if there are connection which are inactive for longer time For instance, batch browser will be ...
ConnectionsList_t GetConnections(unsigned connid=0, bool only_active=false) const
returns connection list (or all active connections)
std::string fUserArgs
! arbitrary JSON code, which is accessible via conn.getUserArgs() method
int fMasterChannel
! channel id in the master window
void StartThread()
Start special thread which will be used by the window to handle all callbacks One has to be sure,...
float GetOperationTmout() const
Returns timeout for synchronous WebWindow operations.
std::shared_ptr< WebConn > FindConnection(unsigned wsid)
Find connection with specified websocket id.
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 ...
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...
std::thread fWindowThrd
! special thread for that window
int NumConnections(bool with_pending=false) const
Returns current number of active clients connections.
unsigned GetId() const
Returns ID for the window - unique inside window manager.
ConnectionsList_t fConn
! list of all accepted connections
void InvokeCallbacks(bool force=false)
Invoke callbacks with existing data Must be called from appropriate thread.
std::string fProtocolPrefix
! prefix for created files names
std::string GetClientVersion() const
Returns current client version.
void SetConnectCallBack(WebWindowConnectCallback_t func)
Set call-back function for new connection.
WebWindowConnectCallback_t fConnCallback
! callback for connect event
unsigned GetMaxQueueLength() const
Return maximal queue length of data which can be held by window.
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...
unsigned fConnLimit
! number of allowed active connections
void Send(unsigned connid, const std::string &data)
Sends data to specified connection.
bool fCallbacksThrdIdSet
! flag indicating that thread id is assigned
unsigned Show(const RWebDisplayArgs &args="")
Show window in specified location See ROOT::Experimental::RWebWindowsManager::Show for more info retu...
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...
unsigned fMasterConnId
! master connection id
void AssignThreadId()
Assign thread id which has to be used for callbacks WARNING!!! only for expert use Automatically done...
bool fSendMT
! true is special threads should be used for sending data
void SendBinary(unsigned connid, const void *data, std::size_t len)
Send binary data to specified connection.
unsigned fWidth
! initial window width when displayed
static std::shared_ptr< RWebWindow > Create()
Create new RWebWindow Using default RWebWindowsManager.
std::thread::id fCallbacksThrdId
! thread id where callbacks should be invoked
std::chrono::time_point< std::chrono::system_clock > timestamp_t
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 fConnCnt
! counter of new connections to assign ids
unsigned fMaxQueueLength
! maximal number of queue entries
void SetDisconnectCallBack(WebWindowConnectCallback_t func)
Set call-back function for disconnecting.
std::string fPanelName
! panel name which should be shown in the window
void SetDataCallBack(WebWindowDataCallback_t func)
Set call-back function for data, received from the clients via websocket.
unsigned fProtocolConnId
! connection id, which is used for writing protocol
void SetUserArgs(const std::string &args)
Set arbitrary JSON data, which is accessible via conn.getUserArgs() method in JavaScript This JSON co...
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...
void StopThread()
Stop special thread.
WebWindowDataCallback_t fDataCallback
! main callback when data over channel 1 is arrived
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.
std::shared_ptr< RWebWindowsManager > GetManager() const
Returns window manager.
void CloseConnection(unsigned connid)
Close specified connection.
unsigned GetConnectionId(int num=0) const
Returns connection id for specified connection sequence number Only active connections are returned -...
bool IsShown() const
Returns true when window was shown at least once.
std::string GetConnToken() const
Returns configured connection token.
void SetMaxQueueLength(unsigned len=10)
configures maximal queue length of data which can be held by window
ConnectionsList_t fPendingConn
! list of pending connection with pre-assigned keys
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.
bool fHasWindowThrd
! indicate if special window thread was started
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...
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...
unsigned GetHeight() const
returns configured window height (0 - default)
void CheckThreadAssign()
Internal method to verify and thread id has to be assigned from manager again Special case when Proce...
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...
void SetOperationTmout(float tm=50.)
Set timeout for synchronous WebWindow operations.
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 ...
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.
bool fNativeOnlyConn
! only native connection are allowed, created by Show() method
void SetGeometry(unsigned width, unsigned height)
Set window geometry. Will be applied if supported by used web display (like CEF or Chromium)
unsigned GetWidth() const
returns configured window width (0 - default) actual window width can be different
std::shared_ptr< RWebWindowWSHandler > fWSHandler
! specialize websocket handler for all incoming connections
bool fUseServerThreads
! indicates that server thread is using, no special window thread
std::string fProtocolFileName
! local file where communication protocol will be written
unsigned fHeight
! initial window height when displayed
std::shared_ptr< RWebWindowsManager > fMgr
! display manager
void CheckPendingConnections()
Check if started process(es) establish connection.
std::string fConnToken
! value of "token" URL parameter which should be provided for connecting window
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.
bool IsNativeOnlyConn() const
returns true if only native (own-created) connections are allowed
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
int fProtocolCnt
! counter for protocol recording
std::queue< QueueEntry > fInputQueue
! input queue for all callbacks
bool fProcessMT
! if window event processing performed in dedicated thread
std::string fProtocol
! protocol
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...
unsigned fId
! unique identifier
float fOperationTmout
! timeout in seconds to perform synchronous operation, default 50s
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...
WebWindowConnectCallback_t fDisconnCallback
! callback for disconnect event
void SetNativeOnlyConn(bool on=true)
configures that only native (own-created) connections are allowed
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 RemoveEmbedWindow(unsigned connid, int channel)
Remove RWebWindow associated with the channel.
void SetCallBacks(WebWindowConnectCallback_t conn, WebWindowDataCallback_t data, WebWindowConnectCallback_t disconn=nullptr)
Set call-backs function for connect, data and disconnect events.
std::mutex fConnMutex
! mutex used to protect connection list
Central instance to create and show web-based windows like Canvas or FitPanel.
std::function< void(unsigned)> WebWindowConnectCallback_t
function signature for connect/disconnect call-backs argument is connection id
std::function< void(unsigned, const std::string &)> WebWindowDataCallback_t
function signature for call-backs from the window clients first 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...
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
QueueEntry(unsigned connid, EQueueEntryKind kind, std::string &&data)
EQueueEntryKind fKind
! kind of data
std::string fData
! data for given connection
std::string fData
! text or binary data
QueueItem(int chid, bool txt, std::string &&data)
std::queue< QueueItem > fQueue
! output queue
WebConn(unsigned connid, unsigned wsid)
int fReady
! 0 - not ready, 1..9 - interim, 10 - done
int fClientCredits
! number of credits received from client
std::mutex fMutex
! mutex must be used to protect all following data
timestamp_t fRecvStamp
! last receive operation, protected with connection mutex
int fSendCredits
! how many send operation can be performed without confirmation from other side
unsigned fConnId
! connection id (unique inside the window)
bool fDoingSend
! true when performing send operation
~WebConn()
Destructor for WebConn Notify special HTTP request which blocks headless browser from exit.
WebConn(unsigned connid, bool headless_mode, const std::string &key)
std::string fKey
! key value supplied to the window (when exists)
std::shared_ptr< THttpCallArg > fHold
! request used to hold headless browser
int fRecvCount
! number of received packets, should return back with next sending
timestamp_t fSendStamp
! last server operation, always used from window thread
bool fActive
! flag indicates if connection is active
std::unique_ptr< RWebDisplayHandle > fDisplayHandle
! handle assigned with started web display (when exists)
bool fHeadlessMode
! indicate if connection represent batch job
std::map< int, std::shared_ptr< RWebWindow > > fEmbed
! map of embed window for that connection, key value is channel id