forked from johanvon/mariotcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.c
More file actions
37 lines (34 loc) · 834 Bytes
/
function.c
File metadata and controls
37 lines (34 loc) · 834 Bytes
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
/*
* function.c
*
* Date: 2013-3-1
* Author: feng jianhua
* Mail: 56683216@qq.com
*
* Ð޸ļǼ£º
*/
#include "function.h"
#include "protocol.h"
#include "config.h"
#include "collect.h"
sint32 login(CONN* c) {
HEAD *hreq = (HEAD*) c->in_buf;
if (hreq->pkglen != sizeof(HEAD) + sizeof(LOGIN_REQ)) {
slog_err_t_w(c->owner->qlog, "invalid login pkg.");
close_err_conn(c);
return -1;
}
++report[c->ind].online;
HEAD *hrsp = (HEAD *) c->out_buf;
hrsp->stx = hreq->stx;
hrsp->akg_id = hreq->akg_id;
hrsp->pkglen = sizeof(HEAD) + sizeof(LOGIN_RSP);
LOGIN_RSP *lrsp = (LOGIN_RSP*) (c->out_buf + sizeof(HEAD));
bufferevent_write(c->bufev, c->out_buf, hrsp->pkglen);
return 0;
}
sint32 logout(CONN* c) {
if(report[c->ind].online > 0)
--report[c->ind].online;
return 0;
}