11#include " ../include/tigerapi/client_config.h"
22#include " ../include/tigerapi/properties.h"
3+ #include " ../include/tigerapi/enums.h"
34
45TIGER_API::ClientConfig::ClientConfig (bool sandbox_debug /* = false*/ )
56 : sandbox_debug(sandbox_debug) {
@@ -8,13 +9,22 @@ TIGER_API::ClientConfig::ClientConfig(bool sandbox_debug /*= false*/)
89 // server_url = SANDBOX_TIGER_SERVER_URL;
910 // server_public_key = SANDBOX_TIGER_PUBLIC_KEY;
1011 }
12+ if (is_us ()) {
13+ server_url = US_TIGER_SERVER_URL;
14+ socket_url = US_TIGER_SOCKET_HOST;
15+ socket_port = US_TIGER_SOCKET_PORT;
16+ }
1117};
1218
1319TIGER_API::ClientConfig::ClientConfig (utility::string_t tiger_id, utility::string_t private_key, utility::string_t account)
1420 : tiger_id(std::move(tiger_id)),
1521 private_key(std::move(private_key)),
1622 account(std::move(account)) {
17-
23+ if (is_us ()) {
24+ server_url = US_TIGER_SERVER_URL;
25+ socket_url = US_TIGER_SOCKET_HOST;
26+ socket_port = US_TIGER_SOCKET_PORT;
27+ }
1828};
1929
2030TIGER_API::ClientConfig::ClientConfig (utility::string_t tiger_id, utility::string_t private_key, utility::string_t account, bool sandbox_debug /* = false*/ , utility::string_t lang /* = U("en_US")*/ )
@@ -30,13 +40,24 @@ TIGER_API::ClientConfig::ClientConfig(utility::string_t tiger_id, utility::strin
3040 // socket_url = SANDBOX_TIGER_SOCKET_HOST;
3141 // socket_port = SANDBOX_TIGER_SOCKET_PORT;
3242 }
43+ if (is_us ()) {
44+ server_url = US_TIGER_SERVER_URL;
45+ socket_url = US_TIGER_SOCKET_HOST;
46+ socket_port = US_TIGER_SOCKET_PORT;
47+ }
3348};
3449
3550TIGER_API::ClientConfig::ClientConfig (bool sandbox_debug, const utility::string_t props_path)
3651 : sandbox_debug(sandbox_debug),
3752 props_path(props_path) {
38- load_props ();
53+ load_props ();
3954 load_token ();
55+ if (is_us ()) {
56+ server_url = US_TIGER_SERVER_URL;
57+ socket_url = US_TIGER_SOCKET_HOST;
58+ socket_port = US_TIGER_SOCKET_PORT;
59+ }
60+ LOG (INFO) << U (" ClientConfig initialized with props_path: " ) << props_path << endl;
4061};
4162
4263void TIGER_API::ClientConfig::check ()
@@ -176,6 +197,9 @@ void TIGER_API::ClientConfig::load_token()
176197 if (full_path.empty ()) {
177198 return ;
178199 }
200+ if (!std::filesystem::exists (Utils::str16to8 (full_path))) {
201+ return ;
202+ }
179203 try {
180204 std::ifstream file (Utils::str16to8 (full_path));
181205 if (!file.is_open ()) {
@@ -219,3 +243,8 @@ void TIGER_API::ClientConfig::save_token(const utility::string_t& new_token)
219243 LOG (ERROR) << U (" Failed to save token file: " ) << Utils::str8to16 (e.what ()) << endl;
220244 }
221245}
246+
247+ bool TIGER_API::ClientConfig::is_us ()
248+ {
249+ return !license.empty () && license == enum_to_str (License::TBUS);
250+ }
0 commit comments