Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
http: make longpoll socket running
Now websocket and longpoll socket can be exchanged to large extent.
Big advantage of longpoll - one could run it over fastcgi or via proxy
internet connection. Will be supported within TWebCanvas
  • Loading branch information
linev committed Apr 18, 2017
commit 36ee70807b83bd61bcd6c2a61c0c4cb642bc1f85
2 changes: 1 addition & 1 deletion net/http/inc/THttpEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class THttpWSEngine : public TNamed {

virtual void SendCharStar(const char *str);

virtual Bool_t PreviewData(THttpCallArg *) { return kTRUE; }
virtual Bool_t PreviewData(THttpCallArg *) { return kFALSE; }

// --------- method to work with Canvas (temporary solution)

Expand Down
11 changes: 9 additions & 2 deletions net/http/src/THttpServer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ class TLongPollEngine : public THttpWSEngine {

virtual ~TLongPollEngine() {}

virtual UInt_t GetId() const { return TString::Hash((void *)this, sizeof(void *)); }
virtual UInt_t GetId() const
{
const void *ptr = (const void *) this;
return TString::Hash((void *) &ptr, sizeof(void *));
}

virtual void ClearHandle()
{
Expand Down Expand Up @@ -111,6 +115,7 @@ class TLongPollEngine : public THttpWSEngine {
virtual Bool_t PreviewData(THttpCallArg *arg)
{
// function called in the user code before processing correspondent websocket data
// returns kTRUE when user should ignore such http request - it is for internal use

if (fPoll) {
// if there are pending request, reply it immediately
Expand All @@ -129,7 +134,8 @@ class TLongPollEngine : public THttpWSEngine {
fPoll = arg;
}

return kTRUE;
// if arguments has "&dummy" string, user should not process it
return strstr(arg->GetQuery(), "&dummy") != 0;
}

};
Expand Down Expand Up @@ -762,6 +768,7 @@ void THttpServer::ProcessRequest(THttpCallArg *arg)
// try to emulate websocket connect
// if accepted, reply with connection id, which must be used in the following communications
arg->SetMethod("WS_CONNECT");

if (canv->GetCanvasImp()->ProcessWSRequest(arg)) {
arg->SetMethod("WS_READY");

Expand Down