forked from ideawu/icomet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.h
More file actions
72 lines (56 loc) · 1.6 KB
/
server.h
File metadata and controls
72 lines (56 loc) · 1.6 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef ICOMET_SERVER_H
#define ICOMET_SERVER_H
#include <vector>
#include <map>
#include <list>
#include <evhttp.h>
#include <event2/http.h>
#include "util/list.h"
#include "util/objpool.h"
#include "channel.h"
#include "subscriber.h"
#include "presence.h"
#define DEFAULT_JSONP_CALLBACK "icomet_cb"
#define CHANNEL_CHECK_INTERVAL 1
class Server
{
private:
ObjPool<Subscriber> sub_pool;
std::vector<Channel> channel_slots;
// mapping cname(channel_name) to channel
std::map<std::string, Channel *> cname_channels;
int subscribers;
LinkedList<Channel *> used_channels;
LinkedList<Channel *> free_channels;
Channel* get_channel(int cid);
Channel* get_channel_by_name(const std::string &name);
Channel* new_channel(const std::string &cname);
void free_channel(Channel *channel);
LinkedList<PresenceSubscriber *> psubs;
void add_presence(PresenceType type, const std::string &cname);
//void flush_presence();
int sub(struct evhttp_request *req, Subscriber::Type sub_type);
public:
enum{
AUTH_NONE = 0,
AUTH_TOKEN = 1
};
int auth;
Server();
~Server();
int check_timeout();
int sub_end(Subscriber *sub);
int ping(struct evhttp_request *req);
int poll(struct evhttp_request *req);
int iframe(struct evhttp_request *req);
int stream(struct evhttp_request *req);
int pub(struct evhttp_request *req);
int sign(struct evhttp_request *req);
int close(struct evhttp_request *req);
int clear(struct evhttp_request *req);
int info(struct evhttp_request *req);
int check(struct evhttp_request *req);
int psub(struct evhttp_request *req);
int psub_end(PresenceSubscriber *psub);
};
#endif