43 const void *ptr = (
const void *)
this;
52 std::shared_ptr<THttpCallArg> poll;
55 std::lock_guard<std::mutex> grd(
fMutex);
56 poll = std::move(
fPoll);
61 poll->NotifyCondition();
75 std::copy((
const char *)buf, (
const char *)buf + len, res.begin());
79 int hdrlen = hdr ? strlen(hdr) : 0;
80 std::string hdrstr =
"bin:";
81 hdrstr.append(std::to_string(hdrlen));
83 while ((hdrstr.length() + 1 + hdrlen) % 8 != 0)
89 res.resize(hdrstr.length() + len);
90 std::copy(hdrstr.begin(), hdrstr.begin() + hdrstr.length(), res.begin());
91 std::copy((
const char *)buf, (
const char *)buf + len, res.begin() + hdrstr.length());
101 std::shared_ptr<THttpCallArg> poll;
104 std::lock_guard<std::mutex> grd(
fMutex);
105 poll = std::move(
fPoll);
109 Error(
"Send",
"Operation invoked before polling request obtained");
115 poll->SetBinaryContent(std::move(buf2));
116 poll->NotifyCondition();
124 std::shared_ptr<THttpCallArg> poll;
127 std::lock_guard<std::mutex> grd(
fMutex);
128 poll = std::move(
fPoll);
132 Error(
"SendHeader",
"Operation invoked before polling request obtained");
138 poll->SetBinaryContent(std::move(buf2));
140 poll->SetExtraHeader(
"LongpollHeader", hdr);
141 poll->NotifyCondition();
150 std::shared_ptr<THttpCallArg> poll;
153 std::lock_guard<std::mutex> grd(
fMutex);
154 poll = std::move(
fPoll);
158 Error(
"SendCharStart",
"Operation invoked before polling request obtained");
162 std::string sendbuf(
fRaw ?
"txt:" :
"");
165 if (
fRaw) poll->SetBinaryContent(std::move(sendbuf));
166 else poll->SetTextContent(std::move(sendbuf));
167 poll->NotifyCondition();
177 if (!strstr(arg->GetQuery(),
"&dummy"))
182 std::shared_ptr<THttpCallArg> poll;
185 std::lock_guard<std::mutex> grd(
fMutex);
186 poll = std::move(
fPoll);
191 Fatal(
"PreviewData",
"Submit same THttpCallArg object once again");
194 Error(
"PreviewData",
"Get next dummy request when previous not completed");
199 poll->NotifyCondition();
221 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.