-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #366 from crypto-chassis/develop
Release
- Loading branch information
Showing
9 changed files
with
80 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
set(NAME override_exchange_url_at_runtime) | ||
project(${NAME}) | ||
add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA) | ||
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_OKX) | ||
add_executable(${NAME} main.cpp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "ccapi_cpp/ccapi_session.h" | ||
namespace ccapi { | ||
Logger* Logger::logger = nullptr; // This line is needed. | ||
class MyEventHandler : public EventHandler { | ||
public: | ||
bool processEvent(const Event& event, Session* session) override { | ||
if (event.getType() == Event::Type::SESSION_STATUS) { | ||
for (const auto& message : event.getMessageList()) { | ||
if (message.getType() == Message::Type::SESSION_CONNECTION_UP) { | ||
for (const auto& element : message.getElementList()) { | ||
const std::map<std::string, std::string>& elementNameValueMap = element.getNameValueMap(); | ||
std::cout << "Connected to " + toString(elementNameValueMap.at("CONNECTION_URL")) << std::endl; | ||
} | ||
} | ||
} | ||
} | ||
return true; | ||
} | ||
}; | ||
} /* namespace ccapi */ | ||
using ::ccapi::MyEventHandler; | ||
using ::ccapi::Session; | ||
using ::ccapi::SessionConfigs; | ||
using ::ccapi::SessionOptions; | ||
using ::ccapi::Subscription; | ||
using ::ccapi::toString; | ||
int main(int argc, char** argv) { | ||
SessionOptions sessionOptions; | ||
SessionConfigs sessionConfigs; | ||
std::map<std::string, std::string> urlWebsocketBase = sessionConfigs.getUrlWebsocketBase(); | ||
urlWebsocketBase["okx"] = "wss://wsaws.okx.com:8443"; | ||
sessionConfigs.setUrlWebsocketBase(urlWebsocketBase); | ||
MyEventHandler eventHandler; | ||
Session session(sessionOptions, sessionConfigs, &eventHandler); | ||
Subscription subscription("okx", "BTC-USDT", "MARKET_DEPTH"); | ||
session.subscribe(subscription); | ||
std::this_thread::sleep_for(std::chrono::seconds(10)); | ||
session.stop(); | ||
std::cout << "Bye" << std::endl; | ||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters