Repository navigation
Expand file tree
/
Copy pathlogin.cpp
More file actions
111 lines (96 loc) · 2.15 KB
/
Copy pathlogin.cpp
File metadata and controls
111 lines (96 loc) · 2.15 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
/**
*============================================================
* @file login.cpp
* @brief 通用的登录服务器框架代码,不许更改,具体的登录细节实现通过login_impl.hpp和login_impl.cpp来完成
*
* compiler gcc4.1.2
* platform Linux
*
* copyright: TaoMee, Inc. ShangHai CN. All rights reserved.
*
*============================================================
*/
extern "C" {
#include <libtaomee/log.h>
#include <libtaomee/conf_parser/config.h>
#include <libtaomee/timer.h>
#include <async_serv/net_if.h>
}
//#include <libtaomee++/project/main_login/user_manager.hpp>
#include "login_impl.hpp"
/**
* @brief AsyncServer框架要求实现的接口之一。
*
*/
extern "C" int init_service(int isparent)
{
if(!isparent) {
setup_timer();
// initiate service
if (login.init() == false) {
return -1;
}
}
return 0;
}
/**
* @brief AsyncServer框架要求实现的接口之一。
*
*/
extern "C" int fini_service(int isparent)
{
if (!isparent) {
destroy_timer();
// finalize service
login.fini();
}
return 0;
}
/**
* @brief AsyncServer框架要求实现的接口之一。
*
*/
extern "C" void proc_events()
{
handle_timer();
}
/**
* @brief AsyncServer框架要求实现的接口之一。
*
*/
extern "C" int get_pkg_len(int fd, const void* avail_data, int avail_len, int isparent)
{
return login.get_pkg_len(fd, avail_data, avail_len, isparent);
}
/**
* @brief AsyncServer框架要求实现的接口之一。
*
*/
extern "C" int proc_pkg_from_client(void* data, int len, fdsession_t* fdsess)
{
return login.dispatch(data, fdsess);
}
/**
* @brief AsyncServer框架要求实现的接口之一。
*
*/
extern "C" void proc_pkg_from_serv(int fd, void* data, int len)
{
login.proc_pkg_from_serv(fd, data, len);
}
/**
* @brief AsyncServer框架要求实现的接口之一。
*
*/
extern "C" void on_client_conn_closed(int fd)
{
user_mng.dealloc_user(fd);
}
/**
* @brief AsyncServer框架要求实现的接口之一。
*
*/
extern "C" void on_fd_closed(int fd)
{
login.on_fd_closed(fd);
}