5 #ifndef __HTTP_SESSION_H__
6 #define __HTTP_SESSION_H__
8 #include <boost/scoped_ptr.hpp>
9 #include <tbb/concurrent_queue.h>
10 #include <tbb/atomic.h>
28 const uint8_t *data,
size_t size,
size_t *sent) {
30 if (!hs)
return false;
31 return hs->Send(data, size, sent);
36 return hs->get_client_context();
39 const std::string& ctx) {
41 if (!hs)
return false;
42 hs->set_client_context(ctx);
59 typedef std::map<std::string, HttpSessionPtr>
map_type;
72 map_type::iterator it =
GetMap()->find(s);
73 if (it ==
GetMap()->end()) {
static int req_handler_task_id_
boost::asio::const_buffer Buffer
tbb::atomic< bool > req_queue_empty_
static map_type * GetMap()
static tbb::atomic< long > GetPendingTaskCount()
static tbb::mutex map_mutex_
boost::intrusive_ptr< HttpSession > HttpSessionPtr
std::map< std::string, HttpSessionPtr > map_type
boost::function< void(HttpSession *session, enum TcpSession::Event event)> SessionEventCb
boost::asio::ssl::stream< boost::asio::ip::tcp::socket > SslSocket
static std::string get_client_context(std::string const &s)
const std::string get_client_context()
virtual void OnRead(Buffer buffer)
HttpSession(HttpServer *server, SslSocket *sock, bool async_ready=true)
static map_type * context_map_
void OnSessionEvent(TcpSession *session, enum TcpSession::Event event)
const std::string get_context()
boost::scoped_ptr< RequestBuilder > request_builder_
static bool set_client_context(std::string const &s, const std::string &ctx)
static tbb::atomic< long > task_count_
std::string client_context_str_
static bool SendSession(std::string const &s, const uint8_t *data, size_t size, size_t *sent)
void set_client_context(const std::string &client_ctx)
DISALLOW_COPY_AND_ASSIGN(HttpSession)
tbb::concurrent_queue< HttpRequest * > request_queue_
static HttpSessionPtr GetSession(std::string const &s)
void RegisterEventCb(SessionEventCb cb)