Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
THttpLongPollEngine Class Reference

Emulation of websocket with long poll requests.

Allows to send data from server to client without explicit request

Created automatically as fallback solution when normal WebSopcket connection cannot be established

Definition at line 23 of file THttpLongPollEngine.h.

Public Member Functions

 THttpLongPollEngine (bool raw=false)
 constructor
virtual ~THttpLongPollEngine ()=default
void ClearHandle (Bool_t) override
 Clear request.
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.
Bool_t PreProcess (std::shared_ptr< THttpCallArg > &arg) override
 Preview data for given socket.
void Send (const void *buf, int len) override
 Send binary data via connection.
void SendCharStar (const char *buf) override
 Send const char data.
void SendHeader (const char *hdr, const void *buf, int len) override
 Send binary data with text header via connection.

Protected Types

enum  EBufKind { kNoBuf , kTxtBuf , kBinBuf }

Protected Member Functions

virtual Bool_t CanSendDirectly () override
 Indicate that polling requests is there or buffer empty and can be immediately invoked.
std::string MakeBuffer (const void *buf, int len, const char *hdr=nullptr)
 !< default reply on the longpoll request
virtual Bool_t SupportSendThrd () const
 Indicate if engine require extra thread to complete postponed thread operation.

Protected Attributes

std::string fBuf
 !< if buffered data available
std::string fBufHeader
 !< buffered data
EBufKind fBufKind {kNoBuf}
 !< hold polling request, which can be immediately used for the next sending
std::mutex fMutex
 !< if true, only content can be used for data transfer
std::shared_ptr< THttpCallArgfPoll
 !< protect polling request to use it from different threads
bool fRaw {false}

Static Protected Attributes

static const std::string gLongPollNope = "<<nope>>"
 !< buffered header

Private Types

enum  { kNone , kData , kHeader , kText }

Private Attributes

std::condition_variable fCond
 ! condition used to sync with sending thread
std::string fData
 ! data (binary or text)
bool fDisabled {false}
 ! true shortly before cleanup, set under locked fMutex from WSHandler
bool fHasSendThrd {false}
 ! if thread was started one have to call join method for it
std::string fHdr
 ! header
bool fMTSend {false}
 ! true when send operation runs, set under locked fMutex from WSHandler
bool fSending {false}
 ! performing send operation in other thread
std::thread fSendThrd
 ! dedicated thread for all send operations
bool fWaiting {false}
 ! if condition wait is called
enum THttpWSEngine:: { ... }  kNone
 ! kind of operation

Friends

class THttpServer

#include </home/stephan/code/root-2/net/http/src/THttpLongPollEngine.h>

Inheritance diagram for THttpLongPollEngine:
THttpWSEngine

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
privateinherited
Enumerator
kNone 
kData 
kHeader 
kText 

Definition at line 41 of file THttpWSEngine.h.

◆ EBufKind

Enumerator
kNoBuf 
kTxtBuf 
kBinBuf 

Definition at line 28 of file THttpLongPollEngine.h.

Constructor & Destructor Documentation

◆ THttpLongPollEngine()

THttpLongPollEngine::THttpLongPollEngine ( bool raw = false)

constructor

Definition at line 34 of file THttpLongPollEngine.cxx.

◆ ~THttpLongPollEngine()

virtual THttpLongPollEngine::~THttpLongPollEngine ( )
virtualdefault

Member Function Documentation

◆ CanSendDirectly()

Bool_t THttpLongPollEngine::CanSendDirectly ( )
overrideprotectedvirtual

Indicate that polling requests is there or buffer empty and can be immediately invoked.

Reimplemented from THttpWSEngine.

Definition at line 269 of file THttpLongPollEngine.cxx.

◆ ClearHandle()

void THttpLongPollEngine::ClearHandle ( Bool_t )
overridevirtual

Clear request.

normally called shortly before destructor

Implements THttpWSEngine.

Definition at line 52 of file THttpLongPollEngine.cxx.

◆ GetId()

UInt_t THttpLongPollEngine::GetId ( ) const
overridevirtual

Returns ID of the engine, created from this pointer.

Implements THttpWSEngine.

Definition at line 41 of file THttpLongPollEngine.cxx.

◆ MakeBuffer()

std::string THttpLongPollEngine::MakeBuffer ( const void * buf,
int len,
const char * hdr = nullptr )
protected

!< default reply on the longpoll request

Create raw buffer which should be send as reply.

For the raw mode all information must be send via binary response

Definition at line 72 of file THttpLongPollEngine.cxx.

◆ PostProcess()

void THttpLongPollEngine::PostProcess ( std::shared_ptr< THttpCallArg > & arg)
overridevirtual

Post process http request.

Normally requests from client does not replied directly for longpoll socket Therefore one can use such request to send data, which was submitted before to the queue

Reimplemented from THttpWSEngine.

Definition at line 238 of file THttpLongPollEngine.cxx.

◆ PreProcess()

Bool_t THttpLongPollEngine::PreProcess ( std::shared_ptr< THttpCallArg > & arg)
overridevirtual

Preview data for given socket.

Method called by WS handler before processing websocket data Returns kTRUE when user should ignore such http request - it is for internal use

Reimplemented from THttpWSEngine.

Definition at line 199 of file THttpLongPollEngine.cxx.

◆ Send()

void THttpLongPollEngine::Send ( const void * buf,
int len )
overridevirtual

Send binary data via connection.

Implements THttpWSEngine.

Definition at line 102 of file THttpLongPollEngine.cxx.

◆ SendCharStar()

void THttpLongPollEngine::SendCharStar ( const char * buf)
overridevirtual

Send const char data.

Either do it immediately or keep in internal buffer

Reimplemented from THttpWSEngine.

Definition at line 165 of file THttpLongPollEngine.cxx.

◆ SendHeader()

void THttpLongPollEngine::SendHeader ( const char * hdr,
const void * buf,
int len )
overridevirtual

Send binary data with text header via connection.

Implements THttpWSEngine.

Definition at line 131 of file THttpLongPollEngine.cxx.

◆ SupportSendThrd()

virtual Bool_t THttpWSEngine::SupportSendThrd ( ) const
inlineprotectedvirtualinherited

Indicate if engine require extra thread to complete postponed thread operation.

Reimplemented in TCivetwebWSEngine.

Definition at line 49 of file THttpWSEngine.h.

◆ THttpServer

friend class THttpServer
friend

Definition at line 24 of file THttpLongPollEngine.h.

Member Data Documentation

◆ fBuf

std::string THttpLongPollEngine::fBuf
protected

!< if buffered data available

Definition at line 34 of file THttpLongPollEngine.h.

◆ fBufHeader

std::string THttpLongPollEngine::fBufHeader
protected

!< buffered data

Definition at line 35 of file THttpLongPollEngine.h.

◆ fBufKind

EBufKind THttpLongPollEngine::fBufKind {kNoBuf}
protected

!< hold polling request, which can be immediately used for the next sending

Definition at line 33 of file THttpLongPollEngine.h.

◆ fCond

std::condition_variable THttpWSEngine::fCond
privateinherited

! condition used to sync with sending thread

Definition at line 38 of file THttpWSEngine.h.

◆ fData

std::string THttpWSEngine::fData
privateinherited

! data (binary or text)

Definition at line 42 of file THttpWSEngine.h.

◆ fDisabled

bool THttpWSEngine::fDisabled {false}
privateinherited

! true shortly before cleanup, set under locked fMutex from WSHandler

Definition at line 32 of file THttpWSEngine.h.

◆ fHasSendThrd

bool THttpWSEngine::fHasSendThrd {false}
privateinherited

! if thread was started one have to call join method for it

Definition at line 35 of file THttpWSEngine.h.

◆ fHdr

std::string THttpWSEngine::fHdr
privateinherited

! header

Definition at line 43 of file THttpWSEngine.h.

◆ fMTSend

bool THttpWSEngine::fMTSend {false}
privateinherited

! true when send operation runs, set under locked fMutex from WSHandler

Definition at line 31 of file THttpWSEngine.h.

◆ fMutex

std::mutex THttpLongPollEngine::fMutex
protected

!< if true, only content can be used for data transfer

Definition at line 31 of file THttpLongPollEngine.h.

◆ fPoll

std::shared_ptr<THttpCallArg> THttpLongPollEngine::fPoll
protected

!< protect polling request to use it from different threads

Definition at line 32 of file THttpLongPollEngine.h.

◆ fRaw

bool THttpLongPollEngine::fRaw {false}
protected

Definition at line 30 of file THttpLongPollEngine.h.

◆ fSending

bool THttpWSEngine::fSending {false}
privateinherited

! performing send operation in other thread

Definition at line 40 of file THttpWSEngine.h.

◆ fSendThrd

std::thread THttpWSEngine::fSendThrd
privateinherited

! dedicated thread for all send operations

Definition at line 34 of file THttpWSEngine.h.

◆ fWaiting

bool THttpWSEngine::fWaiting {false}
privateinherited

! if condition wait is called

Definition at line 39 of file THttpWSEngine.h.

◆ gLongPollNope

const std::string THttpLongPollEngine::gLongPollNope = "<<nope>>"
staticprotected

!< buffered header

Definition at line 36 of file THttpLongPollEngine.h.

◆ []

enum { ... } THttpWSEngine::kNone

! kind of operation


The documentation for this class was generated from the following files: