-
Notifications
You must be signed in to change notification settings - Fork 0
/
session.h
41 lines (32 loc) · 938 Bytes
/
session.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// Created by weitao on 8/1/16.
//
#pragma once
#include <memory>
#include <functional>
#include "timer/timer.h"
#include "net/buffer.h"
#include "logger/logger.h"
namespace snow
{
class session : public std::enable_shared_from_this<session>
{
public:
typedef std::function<void(const buffer&)> response_handle_type;
void set_response_handler(const response_handle_type& handler) {
m_response_handler = handler;
}
void set_timeout(std::size_t timeout) {
}
void send_to_client(const char* data, std::size_t len) {
SNOW_LOG_DEBUG << "send to client bytes " << len;
if(m_response_handler) {
m_response_handler(buffer(data, len));
}
}
virtual void process(const char* data, std::size_t len) = 0;
private:
timer m_timer;
response_handle_type m_response_handler;
};
}