44 const void *ptr = (
const void *)
this;
53 std::shared_ptr<THttpCallArg> poll;
56 std::lock_guard<std::mutex> grd(
fMutex);
57 poll = std::move(
fPoll);
62 poll->NotifyCondition();
76 std::copy((
const char *)buf, (
const char *)buf + len, res.begin());
80 int hdrlen = hdr ? strlen(hdr) : 0;
81 std::string hdrstr =
"bin:";
82 hdrstr.append(std::to_string(hdrlen));
84 while ((hdrstr.length() + 1 + hdrlen) % 8 != 0)
90 res.resize(hdrstr.length() + len);
91 std::copy(hdrstr.begin(), hdrstr.begin() + hdrstr.length(), res.begin());
92 std::copy((
const char *)buf, (
const char *)buf + len, res.begin() + hdrstr.length());
102 std::shared_ptr<THttpCallArg> poll;
105 std::lock_guard<std::mutex> grd(
fMutex);
106 poll = std::move(
fPoll);
110 Error(
"Send",
"Operation invoked before polling request obtained");
116 poll->SetBinaryContent(std::move(buf2));
117 poll->NotifyCondition();
125 std::shared_ptr<THttpCallArg> poll;
128 std::lock_guard<std::mutex> grd(
fMutex);
129 poll = std::move(
fPoll);
133 Error(
"SendHeader",
"Operation invoked before polling request obtained");
139 poll->SetBinaryContent(std::move(buf2));
141 poll->SetExtraHeader(
"LongpollHeader", hdr);
142 poll->NotifyCondition();
151 std::shared_ptr<THttpCallArg> poll;
154 std::lock_guard<std::mutex> grd(
fMutex);
155 poll = std::move(
fPoll);
159 Error(
"SendCharStart",
"Operation invoked before polling request obtained");
163 std::string sendbuf(
fRaw ?
"txt:" :
"");
166 if (
fRaw) poll->SetBinaryContent(std::move(sendbuf));
167 else poll->SetTextContent(std::move(sendbuf));
168 poll->NotifyCondition();
178 if (!strstr(arg->GetQuery(),
"&dummy"))
183 std::shared_ptr<THttpCallArg> poll;
186 std::lock_guard<std::mutex> grd(
fMutex);
187 poll = std::move(
fPoll);
192 Fatal(
"PreviewData",
"Submit same THttpCallArg object once again");
195 Error(
"PreviewData",
"Get next dummy request when previous not completed");
200 poll->NotifyCondition();
222 std::lock_guard<std::mutex> grd(
fMutex);
void Error(const char *location, const char *msgfmt,...)
void Fatal(const char *location, const char *msgfmt,...)
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 and can be immediately invoked.
THttpLongPollEngine(bool raw=false)
constructor
static const std::string gLongPollNope
!< hold polling request, which can be immediately used for the next sending
void ClearHandle(Bool_t) override
clear request, normally called shortly before destructor
void SendCharStar(const char *buf) override
Send const char data Either do it immediately or keep in internal buffer.
Bool_t PreProcess(std::shared_ptr< THttpCallArg > &arg) override
Preview data for given socket Method called by WS handler before processing websocket data Returns kT...
UInt_t GetId() const override
returns ID of the engine, created from this pointer
void PostProcess(std::shared_ptr< THttpCallArg > &arg) override
Normally requests from client does not replied directly for longpoll socket Therefore one can use suc...
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.