-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtxf_timer_info.cpp
More file actions
105 lines (94 loc) · 1.89 KB
/
txf_timer_info.cpp
File metadata and controls
105 lines (94 loc) · 1.89 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
#include "txf_timer_info.h"
#include "statsvr_mcd_proc.h"
#include <algorithm>
int TransferTimer::do_next_step(string& req_data)
{
switch (m_cur_step)
{
case STATE_INIT:
{
if (init(req_data, req_data.size()))
{
ON_ERROR_PARSE_PACKET();
return -1;
}
if ("getChatProxyAddress" == m_cmd)
{
if (on_get_cp_addr())
{
m_cur_step = STATE_END;
return -1;
}
on_stat();
m_cur_step = STATE_END;
return 1;
}
else
{
LogError("Error unknown cmd: %s", m_cmd.c_str());
ON_ERROR_PARSE_PACKET();
return -1;
}
}
default:
{
LogError("error state: %d", m_cur_step);
return -1;
}
}
return 0;
}
int TransferTimer::on_not_online()
{
Json::Value data;
data["identity"] = m_identity;
data["userID"] = m_userID;
data["serviceID"] = m_serviceID;
return on_send_error_reply(ERROR_USER_NOT_ONLINE, "User Not Online", data);
}
int TransferTimer::on_rsp_cp_addr()
{
Json::Value data;
data["identity"] = m_identity;
if ("user" == m_identity)
{
data["userID"] = m_userID;
data["chatProxyIp"] = m_userInfo.cpIP;
data["chatProxyPort"] = m_userInfo.cpPort;
}
else
{
data["serviceID"] = m_serviceID;
data["chatProxyIp"] = m_serviceInfo.cpIP;
data["chatProxyPort"] = m_serviceInfo.cpPort;
}
return on_send_reply(data);
}
int TransferTimer::on_get_cp_addr()
{
if ("user" == m_identity)
{
if (CAppConfig::Instance()->GetUser(m_userID, m_userInfo))
{
return on_not_online();
}
}
else if ("service" == m_identity)
{
if (CAppConfig::Instance()->GetService(m_serviceID, m_serviceInfo))
{
return on_not_online();
}
}
else
{
//
LogError("Unknown identity: %s!", m_identity.c_str());
ON_ERROR_PARSE_DATA("identity");
return SS_ERROR;
}
return on_rsp_cp_addr();
}
TransferTimer::~TransferTimer()
{
}