Repository navigation
Expand file tree
/
Copy pathlogin.cpp
More file actions
132 lines (113 loc) · 2.73 KB
/
Copy pathlogin.cpp
File metadata and controls
132 lines (113 loc) · 2.73 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
/**
*============================================================
* @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 <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)
{
{
char outbuf[13000];
bin2hex(outbuf,(char*)avail_data,avail_len ,2000);
INFO_LOG("get_pkg_len[%s]", outbuf );
}
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)
{
{
char outbuf[13000];
bin2hex(outbuf,(char*)data,len,2000);
INFO_LOG("I[%s]", outbuf );
}
//返回版本信息
if((*(uint16_t*)( ((char*) data)+4) == 1)) {
std::vector<std::string> file_name_list;
file_name_list.push_back("../conf/tm_dirty.dat");
const char * version=get_version_send_buf("LOGIN-20110805",file_name_list );
return send_pkg_to_client(fdsess, version, 256);
}
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);
}