Skip to content

Commit 2697ae7

Browse files
author
chengxin
committed
【ADD】测试demo集成长连接
1 parent c16b222 commit 2697ae7

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

demo/openapi_cpp_test/openapi_cpp_test.cpp

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// openapi_cpp_test.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
2+
#include "tigerapi/push_client.h"
23
#include "tigerapi/tiger_client.h"
34
#include "tigerapi/quote_client.h"
45
#include "tigerapi/trade_client.h"
@@ -238,7 +239,7 @@ class TestQuoteClient {
238239
symbols[1] = value::string(U("JD"));
239240
auto result = quote_client->get_quote_real_time_value(symbols);
240241
vector<RealtimeQuote> result1 = quote_client->get_quote_real_time(symbols);
241-
ucout << U("result: ") << result.at(0).to_string() << endl;
242+
ucout << U("result: ") << result.at(0).serialize() << endl;
242243
}
243244

244245
static void test_get_quote_delay(const std::shared_ptr<QuoteClient> quote_client) {
@@ -439,13 +440,36 @@ int main()
439440
{
440441
/************************** set config **********************/
441442
ClientConfig config = ClientConfig();
442-
config.private_key = U("");
443-
config.tiger_id = U("");
444-
config.account = U("");
445-
446-
447-
448-
443+
#if 1
444+
config.private_key = U("");
445+
config.tiger_id = U("");
446+
config.account = U("");
447+
config.socket_url = U("");
448+
config.socket_port = U("");
449+
#else
450+
config.private_key = U("");
451+
config.tiger_id = U("");
452+
config.account = U("");
453+
config.socket_url = U("");
454+
config.socket_port = U("");
455+
#endif
456+
457+
auto push_client = PushClient::create_push_client(config);
458+
push_client->connect(config);
459+
std::string input;
460+
while (true)
461+
{
462+
std::cout << "Enter command (type 'exit' to quit): ";
463+
std::getline(std::cin, input);
464+
465+
if (input == "exit") {
466+
std::cout << "Exiting loop." << std::endl;
467+
push_client->disconnect();
468+
break;
469+
}
470+
// Process other commands or input here
471+
std::cout << "You entered: " << input << std::endl;
472+
}
449473

450474
//config.lang = U("en_US");
451475

@@ -459,8 +483,8 @@ int main()
459483
/**
460484
* ʹ�÷�װ��Ľ��׽ӿ� TradeClient
461485
*/
462-
std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
463-
TestTradeClient::test_trade(trade_client);
486+
//std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
487+
//TestTradeClient::test_trade(trade_client);
464488

465489
/**
466490
* ֱ��ʹ��δ��װ�� TigerApi

demo/openapi_cpp_test/openapi_cpp_test.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
<ClCompile>
8787
<WarningLevel>Level3</WarningLevel>
8888
<SDLCheck>true</SDLCheck>
89-
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
89+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
9090
<ConformanceMode>true</ConformanceMode>
9191
<AdditionalIncludeDirectories>..\..\include;..\..\..\vcpkg\installed\x86-windows\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
9292
</ClCompile>

0 commit comments

Comments
 (0)