-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRouterServer.h
More file actions
136 lines (109 loc) · 2.57 KB
/
RouterServer.h
File metadata and controls
136 lines (109 loc) · 2.57 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#ifndef _RouterServer_H_
#define _RouterServer_H_
//
#include <iostream>
//
#include "globe.h"
#include "Functor.h"
#include "RouterHelper.h"
#include "servant/Application.h"
#include "OuterFactoryImp.h"
//
using namespace std;
using namespace tars;
/**
* tcp长连接路由分发
**/
class RouterServer : public Application
{
public:
/**
*
**/
virtual ~RouterServer() {};
/**
*
**/
virtual void initialize();
/**
*
**/
virtual void destroyApp();
public:
/*
* 配置变更,重新加载配置
*/
bool reloadSvrConfig(const string &command, const string ¶ms, string &result);
/*
* 远程加载房间列表配置
*/
bool loadRemoteRoomList(const string &command, const string ¶ms, string &result);
/**
* 显示已有连接账户
*/
bool showConnUsers(const string &command, const string ¶ms, string &result);
/**
* 主动关闭用户连接
*/
bool killUsers(const string &command, const string ¶ms, string &result);
/**
* 设置白单开关
*/
bool OpenWhiteList(const string &command, const string ¶ms, string &result);
public:
/**
* 初始化所有线程
*/
void initialThread();
/**
* 结束所有线程
*/
void destroyThread();
/**
* 设置连接池超时
*/
void setConnTimeout();
public:
/**
* 获取连接映射
*/
tars::Int64 GetUidFromClientIDMap(const tars::Int64 clientId);
/**
* 清除连接映射
*/
tars::Int64 PopUidFromClientIDMap(const tars::Int64 clientId);
/**
* 更新连接映射
*/
int SetUidToClientIDMap(const tars::Int64 clientId, const tars::Int64 userId);
/**
* 获取映射信息<uid, cid>
*/
int GetClientInfoList(std::map<long, long> &users);
public:
/**
* 获取外部对象
*/
OuterFactoryImp *getOutPtr();
private:
//定时处理对象
Functor _functor;
//线程池
TC_ThreadPool _tpool;
//线程锁
TC_ThreadMutex m_ThreadMutex;
//<cid, uid>
map<tars::Int64, tars::Int64> m_cid2UidMap;
//<cid, ptr>
map<tars::Int64, ConnStructPtr> m_cid2PtrMap;
//外部对象工厂
OuterFactoryImp *m_pOuter;
};
//application
extern RouterServer g_app;
//用户连接池
extern CConnMap g_connMap;
//本地PushObj的具体地址
extern string g_sLocalPushObj;
////////////////////////////////////////////
#endif