Skip to content

Commit dd63dad

Browse files
committed
简单修改
1 parent 7821fe8 commit dd63dad

File tree

4 files changed

+84
-24
lines changed

4 files changed

+84
-24
lines changed

public/tools/curl/manage_curl.cpp

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "manage_curl.h"
22
#include <thread>
33
#include "ijson.h"
4+
#include "md5.h"
45

56
namespace ngl
67
{
@@ -219,11 +220,19 @@ namespace ngl
219220

220221
void manage_curl::param(std::string& astrparam, const char* akey, const char* aval)
221222
{
223+
if (astrparam.empty() == false)
224+
{
225+
astrparam = astrparam + '&';
226+
}
222227
astrparam = astrparam + akey + "=" + aval;
223228
}
224229

225230
void manage_curl::param(std::string& astrparam, const char* akey, int aval)
226231
{
232+
if (astrparam.empty() == false)
233+
{
234+
astrparam = astrparam + '&';
235+
}
227236
astrparam = astrparam + akey + "=" + boost::lexical_cast<std::string>(aval);
228237
}
229238

@@ -239,11 +248,10 @@ namespace ngl
239248

240249
void test_manage_curl()
241250
{
242-
return;
243251
ngl::_http* lhttp = ngl::manage_curl::make_http();
244252
ngl::manage_curl::set_mode(*lhttp, ngl::ENUM_MODE_HTTPS);
245253
ngl::manage_curl::set_type(*lhttp, ngl::ENUM_TYPE_POST);
246-
ngl::manage_curl::set_url(*lhttp, "https://api.vsgame.vn/cp/user_login_auth");
254+
ngl::manage_curl::set_url(*lhttp, "https://xxxxx/external/index/auth");
247255

248256

249257
std::string lparm;
@@ -253,18 +261,28 @@ namespace ngl
253261
//ngl::manage_curl::param(lparm, "token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmaWZ1bi5nYW1lcyIsImF1ZCI6ImZpZnVuLmdhbWVzIiwiaWF0IjoxNjkzOTIwMTQ0LCJleHAiOjE2OTY1MTIxNDQsIm5iZiI6MTY5MzkyMDE0NCwicGxhdGZvcm1fdWlkIjoyOTY5NDQ4LCJwbGF0Zm9ybV9hY2NvdW50Ijoiemh1Z29uZzMiLCJnYW1lX2lkIjo0NSwiZ2FtZV91aWQiOjQzNjg1MDYsInV1aWQiOiJlZjA5Yzg1MmQ4ZjRkYWE5Y2JiNGY2MjM1MjBlNjQ1OSJ9.nXnFg3gu1DdPVWtvcq4u6SmXNse0fUQ3OyMr3QvN0JE");
254262
//ngl::manage_curl::param(lparm, "uid", "2969448");
255263

256-
ijson ltempjson;
257-
ltempjson << std::make_pair("game_id", 45);
258-
ltempjson << std::make_pair("sign", "1b529b390bc85f2743bcac7ca9e60142");
259-
ltempjson << std::make_pair("timestamp", 1693994993);
260-
ltempjson << std::make_pair("token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmaWZ1bi5nYW1lcyIsImF1ZCI6ImZpZnVuLmdhbWVzIiwiaWF0IjoxNjkzOTkyODUzLCJleHAiOjE2OTY1ODQ4NTMsIm5iZiI6MTY5Mzk5Mjg1MywicGxhdGZvcm1fdWlkIjoyOTY5NDQ4LCJwbGF0Zm9ybV9hY2NvdW50Ijoiemh1Z29uZzMiLCJnYW1lX2lkIjo0NSwiZ2FtZV91aWQiOjQzNjg1MDYsInV1aWQiOiJlZjA5Yzg1MmQ4ZjRkYWE5Y2JiNGY2MjM1MjBlNjQ1OSJ9.AuBDG_20qpg_9xIfpSmFE8kwVw-wUUXDzYl2UBOmUPA");
261-
ltempjson << std::make_pair("uid", 2969448);
262-
263-
ltempjson.set_nonformatstr(true);
264-
std::string lparmkkk;
265-
ltempjson >> lparmkkk;
266-
ngl::manage_curl::set_param(*lhttp, lparmkkk);
267-
264+
//ijson ltempjson;
265+
//ltempjson << std::make_pair("appid", 44);
266+
//ltempjson << std::make_pair("uid", 1406739);
267+
//ltempjson << std::make_pair("sessionid", "i461qbg8pia3pe04fdenue1hu4");
268+
269+
270+
//std::string ltemp;
271+
//md5(appid.uid.sessionid.login_key);
272+
//ltemp = boost::lexical_cast<std::string>(44) + "1406739" + "i461qbg8pia3pe04fdenue1hu4" + "2475836ac498942dbd06bc93f143adea";
273+
//ngl::md5 varMd5(ltemp);
274+
//ltempjson << std::make_pair("token", varMd5.values());
275+
276+
//ltempjson.set_nonformatstr(true);
277+
//std::string lparmkkk;
278+
//ltempjson >> lparmkkk;
279+
//ngl::manage_curl::set_param(*lhttp, R"({ "appid":44, "uid" : 1406739, "sessionid" : "i461qbg8pia3pe04fdenue1hu4", "token" : "677d6d7bb4edd5cc4aa80079d5c63982" })");
280+
//ngl::manage_curl::set_param(*lhttp, lparmkkk);
281+
ngl::manage_curl::param(lparm, "appid", 11);
282+
ngl::manage_curl::param(lparm, "uid", 11111);
283+
ngl::manage_curl::param(lparm, "sessionid", "xxxx");
284+
ngl::manage_curl::param(lparm, "token", "11111111111111111111111111");
285+
ngl::manage_curl::set_param(*lhttp, lparm);
268286
bool lbool = true;
269287

270288
ngl::manage_curl::set_callback(*lhttp, [&lbool](int anum, ngl::_http& aparm)

public/tools/tab/json/ojson.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,42 @@ namespace ngl
2323

2424
bool ojson::operator >> (std::pair<const char*, int8_t>& adata)
2525
{
26-
return _fun_number(adata);
26+
return _fun_number32(adata);
2727
}
2828

2929
bool ojson::operator >> (std::pair<const char*, int16_t>& adata)
3030
{
31-
return _fun_number(adata);
31+
return _fun_number32(adata);
3232
}
3333

3434
bool ojson::operator >> (std::pair<const char*, int32_t>& adata)
3535
{
36-
return _fun_number(adata);
36+
return _fun_number32(adata);
3737
}
3838

3939
bool ojson::operator >> (std::pair<const char*, int64_t>& adata)
4040
{
41-
return _fun_number(adata);
41+
return _fun_number64(adata);
4242
}
4343

4444
bool ojson::operator >> (std::pair<const char*, uint8_t>& adata)
4545
{
46-
return _fun_number(adata);
46+
return _fun_number32(adata);
4747
}
4848

4949
bool ojson::operator >> (std::pair<const char*, uint16_t>& adata)
5050
{
51-
return _fun_number(adata);
51+
return _fun_number32(adata);
5252
}
5353

5454
bool ojson::operator >> (std::pair<const char*, uint32_t>& adata)
5555
{
56-
return _fun_number(adata);
56+
return _fun_number32(adata);
5757
}
5858

5959
bool ojson::operator >> (std::pair<const char*, uint64_t>& adata)
6060
{
61-
return _fun_number(adata);
61+
return _fun_number64(adata);
6262
}
6363

6464
bool ojson::operator >> (std::pair<const char*, float>& adata)

public/tools/tab/json/ojson.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,22 @@ namespace ngl
1515
virtual ~ojson();
1616

1717
template <typename T>
18-
bool _fun_number(std::pair<const char*, T>& adata)
18+
bool _fun_number32(std::pair<const char*, T>& adata)
1919
{
2020
cJSON* ret = cJSON_GetObjectItem(m_json, adata.first);
2121
if (nullptr == ret || ret->type != cJSON_Number)
2222
return false;
23-
adata.second = ret->valueint;
23+
adata.second = (T)ret->valueint;
24+
return true;
25+
}
26+
27+
template <typename T>
28+
bool _fun_number64(std::pair<const char*, T>& adata)
29+
{
30+
cJSON* ret = cJSON_GetObjectItem(m_json, adata.first);
31+
if (nullptr == ret || ret->type != cJSON_Number)
32+
return false;
33+
adata.second = (T)ret->valuedouble;
2434
return true;
2535
}
2636

server/node/core/main.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,40 @@ Dumper lDumper;
55

66
#include "rfun.h"
77

8+
#include "ojson.h"
9+
#include "ijson.h"
10+
#include "manage_curl.h"
11+
12+
#include <boost/lexical_cast.hpp>
13+
#include "operator_file.h"
14+
815
int main(int argc, char** argv)
916
{
17+
{
18+
std::string lstr;
19+
for (int i = 0; i < 5000; ++i)
20+
{
21+
if (i != 0)
22+
lstr += '#';
23+
lstr += boost::lexical_cast<std::string>(830202986 + i);
24+
lstr += '*';
25+
lstr += boost::lexical_cast<std::string>(8302);
26+
lstr += '*';
27+
lstr += boost::lexical_cast<std::string>(11277 + i);
28+
lstr += '*';
29+
lstr += boost::lexical_cast<std::string>(3112 + i);
30+
lstr += "libohhhhh";
31+
lstr += boost::lexical_cast<std::string>(4209 + i);
32+
}
33+
ngl::writefile lfile("1.txt");
34+
lfile.write(lstr);
35+
}
36+
37+
38+
39+
40+
ngl::test_manage_curl();
41+
1042
std::cout <<
1143
typeid(pbnet::PROBUFF_NET_GET_TIME_RESPONSE).name()
1244
<< std::endl;

0 commit comments

Comments
 (0)