44 const void *ptr = (
const void *)
this;
55 std::shared_ptr<THttpCallArg> poll;
58 std::lock_guard<std::mutex> grd(
fMutex);
59 poll = std::move(
fPoll);
64 poll->NotifyCondition();
79 std::copy((
const char *)buf, (
const char *)buf +
len, res.begin());
83 int hdrlen = hdr ? strlen(hdr) : 0;
84 std::string hdrstr =
"bin:";
85 hdrstr.append(std::to_string(hdrlen));
87 while ((hdrstr.length() + 1 + hdrlen) % 8 != 0)
93 res.resize(hdrstr.length() +
len);
94 std::copy(hdrstr.begin(), hdrstr.begin() + hdrstr.length(), res.begin());
95 std::copy((
const char *)buf, (
const char *)buf +
len, res.begin() + hdrstr.length());
105 std::shared_ptr<THttpCallArg> poll;
110 std::lock_guard<std::mutex> grd(
fMutex);
112 poll = std::move(
fPoll);
115 std::swap(
fBuf, sendbuf);
121 Error(
"Send",
"Operation invoked before polling request obtained");
125 poll->SetBinaryContent(std::move(sendbuf));
126 poll->NotifyCondition();
134 std::shared_ptr<THttpCallArg> poll;
139 std::lock_guard<std::mutex> grd(
fMutex);
141 poll = std::move(
fPoll);
145 std::swap(
fBuf, sendbuf);
151 Error(
"SendHeader",
"Operation invoked before polling request obtained");
155 poll->SetBinaryContent(std::move(sendbuf));
157 poll->SetExtraHeader(
"LongpollHeader", hdr);
158 poll->NotifyCondition();
168 std::shared_ptr<THttpCallArg> poll;
170 std::string sendbuf(
fRaw ?
"txt:" :
"");
174 std::lock_guard<std::mutex> grd(
fMutex);
176 poll = std::move(
fPoll);
179 std::swap(
fBuf, sendbuf);
185 Error(
"SendCharStart",
"Operation invoked before polling request obtained");
189 if (
fRaw) poll->SetBinaryContent(std::move(sendbuf));
190 else poll->SetTextContent(std::move(sendbuf));
191 poll->NotifyCondition();
202 if (!strstr(arg->GetQuery(),
"&dummy"))
205 std::shared_ptr<THttpCallArg> poll;
208 if (arg->CanPostpone()) {
209 std::lock_guard<std::mutex> grd(
fMutex);
215 poll = std::move(
fPoll);
226 poll->NotifyCondition();
242 std::string sendbuf, sendhdr;
245 std::lock_guard<std::mutex> grd(
fMutex);
249 std::swap(sendbuf,
fBuf);
255 arg->SetTextContent(std::move(sendbuf));
257 arg->SetBinaryContent(std::move(sendbuf));
258 if (!sendhdr.empty())
259 arg->SetExtraHeader(
"LongpollHeader", sendhdr.c_str());
272 std::lock_guard<std::mutex> grd(
fMutex);
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
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
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.
THttpLongPollEngine(bool raw=false)
constructor
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
Internal instance used to exchange WS functionality between THttpServer and THttpWSHandler.
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.