Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
THttpLongPollEngine.h
Go to the documentation of this file.
1// $Id$
2// Author: Sergey Linev 8/01/2018
3
4/*************************************************************************
5 * Copyright (C) 1995-2017, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_THttpLongPollEngine
13#define ROOT_THttpLongPollEngine
14
15#include "THttpWSEngine.h"
16
17#include <string>
18#include <queue>
19#include <mutex>
20
21class THttpServer;
22
24 friend class THttpServer;
25
26protected:
27
29
30 bool fRaw{false}; ///!< if true, only content can be used for data transfer
31 std::mutex fMutex; ///!< protect polling request to use it from different threads
32 std::shared_ptr<THttpCallArg> fPoll; ///!< hold polling request, which can be immediately used for the next sending
33 EBufKind fBufKind{kNoBuf}; ///!< if buffered data available
34 std::string fBuf; ///!< buffered data
35 std::string fBufHeader; ///!< buffered header
36 static const std::string gLongPollNope; ///!< default reply on the longpoll request
37
38 std::string MakeBuffer(const void *buf, int len, const char *hdr = nullptr);
39
40 virtual Bool_t CanSendDirectly() override;
41
42public:
43 THttpLongPollEngine(bool raw = false);
44 virtual ~THttpLongPollEngine() = default;
45
46 UInt_t GetId() const override;
47
48 void ClearHandle(Bool_t) override;
49
50 void Send(const void *buf, int len) override;
51
52 void SendCharStar(const char *buf) override;
53
54 void SendHeader(const char *hdr, const void *buf, int len) override;
55
56 Bool_t PreProcess(std::shared_ptr<THttpCallArg> &arg) override;
57
58 void PostProcess(std::shared_ptr<THttpCallArg> &arg) override;
59};
60
61#endif
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
Emulation of websocket with long poll requests.
std::string fBufHeader
!< buffered data
std::string MakeBuffer(const void *buf, int len, const char *hdr=nullptr)
!< default reply on the longpoll request
std::shared_ptr< THttpCallArg > fPoll
!< protect polling request to use it from different threads
void Send(const void *buf, int len) override
Send binary data via connection.
void SendHeader(const char *hdr, const void *buf, int len) override
Send binary data with text header via connection.
std::mutex fMutex
!< if true, only content can be used for data transfer
virtual Bool_t CanSendDirectly() override
Indicate that polling requests is there or buffer empty and can be immediately invoked.
static const std::string gLongPollNope
!< buffered header
void ClearHandle(Bool_t) override
Clear request.
void SendCharStar(const char *buf) override
Send const char data.
Bool_t PreProcess(std::shared_ptr< THttpCallArg > &arg) override
Preview data for given socket.
EBufKind fBufKind
!< hold polling request, which can be immediately used for the next sending
UInt_t GetId() const override
Returns ID of the engine, created from this pointer.
void PostProcess(std::shared_ptr< THttpCallArg > &arg) override
Post process http request.
std::string fBuf
!< if buffered data available
virtual ~THttpLongPollEngine()=default
Online http server for arbitrary ROOT application.
Definition THttpServer.h:31
Internal instance used to exchange WS functionality between THttpServer and THttpWSHandler.