Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
THttpLongPollEngine.h
Go to the documentation of this file.
1 // $Id$
2 // Author: Sergey Linev 8/01/2018
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2017, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_THttpLongPollEngine
13 #define ROOT_THttpLongPollEngine
14 
15 #include "THttpWSEngine.h"
16 
17 #include <string>
18 #include <queue>
19 #include <mutex>
20 
21 class THttpServer;
22 
23 class THttpLongPollEngine : public THttpWSEngine {
24  friend class THttpServer;
25 
26 protected:
27 
28  bool fRaw{false}; ///!< if true, only content can be used for data transfer
29  std::mutex fMutex; ///!< protect polling request to use it from different threads
30  std::shared_ptr<THttpCallArg> fPoll; ///!< hold polling request, which can be immediately used for the next sending
31  static const std::string gLongPollNope; ///!< default reply on the longpoll request
32 
33  std::string MakeBuffer(const void *buf, int len, const char *hdr = nullptr);
34 
35  virtual Bool_t CanSendDirectly() override;
36 
37 public:
38  THttpLongPollEngine(bool raw = false);
39  virtual ~THttpLongPollEngine() = default;
40 
41  UInt_t GetId() const override;
42 
43  void ClearHandle(Bool_t) override;
44 
45  void Send(const void *buf, int len) override;
46 
47  void SendCharStar(const char *buf) override;
48 
49  void SendHeader(const char *hdr, const void *buf, int len) override;
50 
51  Bool_t PreProcess(std::shared_ptr<THttpCallArg> &arg) override;
52 
53  void PostProcess(std::shared_ptr<THttpCallArg> &arg) override;
54 };
55 
56 #endif