Upgrade ccapi from 5.31.2 -> 5.45.1
This commit is contained in:
1 parent
a1b923c826
commit
f21c6594c0
98 files changed
+9664
-2200
No files matched your search
@@ -46,8 +46,8 @@
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_HUOBI_COIN_SWAP
|
||||
#include "ccapi_cpp/service/ccapi_market_data_service_huobi_coin_swap.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_OKEX
|
||||
#include "ccapi_cpp/service/ccapi_market_data_service_okex.h"
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_OKX
|
||||
#include "ccapi_cpp/service/ccapi_market_data_service_okx.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_ERISX
|
||||
#include "ccapi_cpp/service/ccapi_market_data_service_erisx.h"
|
||||
@@ -79,9 +79,30 @@
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BYBIT
|
||||
#include "ccapi_cpp/service/ccapi_market_data_service_bybit.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BYBIT_DERIVATIVES
|
||||
#include "ccapi_cpp/service/ccapi_market_data_service_bybit_derivatives.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_ASCENDEX
|
||||
#include "ccapi_cpp/service/ccapi_market_data_service_ascendex.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BITGET
|
||||
#include "ccapi_cpp/service/ccapi_market_data_service_bitget.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BITGET_FUTURES
|
||||
#include "ccapi_cpp/service/ccapi_market_data_service_bitget_futures.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BITMART
|
||||
#include "ccapi_cpp/service/ccapi_market_data_service_bitmart.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_MEXC
|
||||
#include "ccapi_cpp/service/ccapi_market_data_service_mexc.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_MEXC_FUTURES
|
||||
#include "ccapi_cpp/service/ccapi_market_data_service_mexc_futures.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_WHITEBIT
|
||||
#include "ccapi_cpp/service/ccapi_market_data_service_whitebit.h"
|
||||
#endif
|
||||
#endif
|
||||
// end: enable exchanges for market data
|
||||
|
||||
@@ -114,6 +135,9 @@
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BINANCE
|
||||
#include "ccapi_cpp/service/ccapi_execution_management_service_binance.h"
|
||||
#endif
|
||||
// #ifdef CCAPI_ENABLE_EXCHANGE_BINANCE_MARGIN
|
||||
// #include "ccapi_cpp/service/ccapi_execution_management_service_binance_margin.h"
|
||||
// #endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BINANCE_USDS_FUTURES
|
||||
#include "ccapi_cpp/service/ccapi_execution_management_service_binance_usds_futures.h"
|
||||
#endif
|
||||
@@ -129,8 +153,8 @@
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_HUOBI_COIN_SWAP
|
||||
#include "ccapi_cpp/service/ccapi_execution_management_service_huobi_coin_swap.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_OKEX
|
||||
#include "ccapi_cpp/service/ccapi_execution_management_service_okex.h"
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_OKX
|
||||
#include "ccapi_cpp/service/ccapi_execution_management_service_okx.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_ERISX
|
||||
#include "ccapi_cpp/service/ccapi_execution_management_service_erisx.h"
|
||||
@@ -162,9 +186,30 @@
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BYBIT
|
||||
#include "ccapi_cpp/service/ccapi_execution_management_service_bybit.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BYBIT_DERIVATIVES
|
||||
#include "ccapi_cpp/service/ccapi_execution_management_service_bybit_derivatives.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_ASCENDEX
|
||||
#include "ccapi_cpp/service/ccapi_execution_management_service_ascendex.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BITGET
|
||||
#include "ccapi_cpp/service/ccapi_execution_management_service_bitget.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BITGET_FUTURES
|
||||
#include "ccapi_cpp/service/ccapi_execution_management_service_bitget_futures.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BITMART
|
||||
#include "ccapi_cpp/service/ccapi_execution_management_service_bitmart.h"
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_MEXC
|
||||
#include "ccapi_cpp/service/ccapi_execution_management_service_mexc.h"
|
||||
#endif
|
||||
// #ifdef CCAPI_ENABLE_EXCHANGE_MEXC_FUTURES
|
||||
// #include "ccapi_cpp/service/ccapi_execution_management_service_mexc_futures.h"
|
||||
// #endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_WHITEBIT
|
||||
#include "ccapi_cpp/service/ccapi_execution_management_service_whitebit.h"
|
||||
#endif
|
||||
#endif
|
||||
// end: enable exchanges for execution management
|
||||
|
||||
@@ -218,10 +263,13 @@ class Session {
|
||||
: sessionOptions(sessionOptions),
|
||||
sessionConfigs(sessionConfigs),
|
||||
eventHandler(eventHandler),
|
||||
#ifndef CCAPI_USE_SINGLE_THREAD
|
||||
eventDispatcher(eventDispatcher),
|
||||
#endif
|
||||
eventQueue(sessionOptions.maxEventQueueSize),
|
||||
serviceContextPtr(new ServiceContext()) {
|
||||
CCAPI_LOGGER_FUNCTION_ENTER;
|
||||
#ifndef CCAPI_USE_SINGLE_THREAD
|
||||
if (this->eventHandler) {
|
||||
if (!this->eventDispatcher) {
|
||||
this->eventDispatcher = new EventDispatcher();
|
||||
@@ -232,14 +280,17 @@ class Session {
|
||||
throw std::runtime_error("undefined behavior");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
this->start();
|
||||
CCAPI_LOGGER_FUNCTION_EXIT;
|
||||
}
|
||||
virtual ~Session() {
|
||||
CCAPI_LOGGER_FUNCTION_ENTER;
|
||||
#ifndef CCAPI_USE_SINGLE_THREAD
|
||||
if (this->useInternalEventDispatcher) {
|
||||
delete this->eventDispatcher;
|
||||
}
|
||||
#endif
|
||||
CCAPI_LOGGER_FUNCTION_EXIT;
|
||||
}
|
||||
virtual void start() {
|
||||
@@ -304,9 +355,9 @@ class Session {
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_MARKET_DATA][CCAPI_EXCHANGE_NAME_HUOBI_COIN_SWAP] =
|
||||
std::make_shared<MarketDataServiceHuobiCoinSwap>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_OKEX
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_MARKET_DATA][CCAPI_EXCHANGE_NAME_OKEX] =
|
||||
std::make_shared<MarketDataServiceOkex>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_OKX
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_MARKET_DATA][CCAPI_EXCHANGE_NAME_OKX] =
|
||||
std::make_shared<MarketDataServiceOkx>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_ERISX
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_MARKET_DATA][CCAPI_EXCHANGE_NAME_ERISX] =
|
||||
@@ -348,10 +399,38 @@ class Session {
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_MARKET_DATA][CCAPI_EXCHANGE_NAME_BYBIT] =
|
||||
std::make_shared<MarketDataServiceBybit>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BYBIT_DERIVATIVES
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_MARKET_DATA][CCAPI_EXCHANGE_NAME_BYBIT_DERIVATIVES] =
|
||||
std::make_shared<MarketDataServiceBybitDerivatives>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_ASCENDEX
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_MARKET_DATA][CCAPI_EXCHANGE_NAME_ASCENDEX] =
|
||||
std::make_shared<MarketDataServiceAscendex>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BITGET
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_MARKET_DATA][CCAPI_EXCHANGE_NAME_BITGET] =
|
||||
std::make_shared<MarketDataServiceBitget>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BITGET_FUTURES
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_MARKET_DATA][CCAPI_EXCHANGE_NAME_BITGET_FUTURES] =
|
||||
std::make_shared<MarketDataServiceBitgetFutures>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BITMART
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_MARKET_DATA][CCAPI_EXCHANGE_NAME_BITMART] =
|
||||
std::make_shared<MarketDataServiceBitmart>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_MEXC
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_MARKET_DATA][CCAPI_EXCHANGE_NAME_MEXC] =
|
||||
std::make_shared<MarketDataServiceMexc>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_MEXC_FUTURES
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_MARKET_DATA][CCAPI_EXCHANGE_NAME_MEXC_FUTURES] =
|
||||
std::make_shared<MarketDataServiceMexcFutures>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_WHITEBIT
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_MARKET_DATA][CCAPI_EXCHANGE_NAME_WHITEBIT] =
|
||||
std::make_shared<MarketDataServiceWhitebit>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_COINBASE
|
||||
@@ -378,7 +457,6 @@ class Session {
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_BITFINEX] =
|
||||
std::make_shared<ExecutionManagementServiceBitfinex>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BITMEX
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_BITMEX] =
|
||||
std::make_shared<ExecutionManagementServiceBitmex>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
@@ -391,6 +469,10 @@ class Session {
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_BINANCE] =
|
||||
std::make_shared<ExecutionManagementServiceBinance>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
// #ifdef CCAPI_ENABLE_EXCHANGE_BINANCE_MARGIN
|
||||
// this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_BINANCE_MARGIN] =
|
||||
// std::make_shared<ExecutionManagementServiceBinanceMargin>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
// #endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BINANCE_USDS_FUTURES
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_BINANCE_USDS_FUTURES] =
|
||||
std::make_shared<ExecutionManagementServiceBinanceUsdsFutures>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
@@ -411,9 +493,9 @@ class Session {
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_HUOBI_COIN_SWAP] =
|
||||
std::make_shared<ExecutionManagementServiceHuobiCoinSwap>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_OKEX
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_OKEX] =
|
||||
std::make_shared<ExecutionManagementServiceOkex>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_OKX
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_OKX] =
|
||||
std::make_shared<ExecutionManagementServiceOkx>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_ERISX
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_ERISX] =
|
||||
@@ -452,14 +534,43 @@ class Session {
|
||||
std::make_shared<ExecutionManagementServiceCryptocom>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BYBIT
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_CRYPTOCOM] =
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_BYBIT] =
|
||||
std::make_shared<ExecutionManagementServiceBybit>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BYBIT_DERIVATIVES
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_BYBIT_DERIVATIVES] =
|
||||
std::make_shared<ExecutionManagementServiceBybitDerivatives>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_ASCENDEX
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_ASCENDEX] =
|
||||
std::make_shared<ExecutionManagementServiceAscendex>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BITGET
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_BITGET] =
|
||||
std::make_shared<ExecutionManagementServiceBitget>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BITGET_FUTURES
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_BITGET_FUTURES] =
|
||||
std::make_shared<ExecutionManagementServiceBitgetFutures>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_BITMART
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_BITMART] =
|
||||
std::make_shared<ExecutionManagementServiceBitmart>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_MEXC
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_MEXC] =
|
||||
std::make_shared<ExecutionManagementServiceMexc>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
#endif
|
||||
// #ifdef CCAPI_ENABLE_EXCHANGE_MEXC_FUTURES
|
||||
// this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_MEXC_FUTURES] =
|
||||
// std::make_shared<ExecutionManagementServiceMexcFutures>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
// #endif
|
||||
// #ifdef CCAPI_ENABLE_EXCHANGE_WHITEBIT
|
||||
// this->serviceByServiceNameExchangeMap[CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_WHITEBIT] =
|
||||
// std::make_shared<ExecutionManagementServiceWhitebit>(this->internalEventHandler, sessionOptions, sessionConfigs, this->serviceContextPtr);
|
||||
// #endif
|
||||
#endif
|
||||
|
||||
#ifdef CCAPI_ENABLE_SERVICE_FIX
|
||||
#ifdef CCAPI_ENABLE_EXCHANGE_COINBASE
|
||||
this->serviceByServiceNameExchangeMap[CCAPI_FIX][CCAPI_EXCHANGE_NAME_COINBASE] =
|
||||
@@ -492,9 +603,11 @@ class Session {
|
||||
CCAPI_LOGGER_FUNCTION_EXIT;
|
||||
}
|
||||
virtual void stop() {
|
||||
#ifndef CCAPI_USE_SINGLE_THREAD
|
||||
if (this->useInternalEventDispatcher) {
|
||||
this->eventDispatcher->stop();
|
||||
}
|
||||
#endif
|
||||
for (const auto& x : this->serviceByServiceNameExchangeMap) {
|
||||
for (const auto& y : x.second) {
|
||||
y.second->stop();
|
||||
@@ -560,11 +673,23 @@ class Session {
|
||||
"unsupported exchange fields: " + toString(unsupportedExchangeFieldSet));
|
||||
return;
|
||||
}
|
||||
for (const auto& subscription : subscriptionList) {
|
||||
auto exchange = subscription.getExchange();
|
||||
if (exchange == CCAPI_EXCHANGE_NAME_BYBIT_DERIVATIVES) {
|
||||
const auto& instrumentType = subscription.getInstrumentType();
|
||||
std::vector<std::string> instrumentTypeList = {"usdt-contract", "usdc-contract", "usdc-options"};
|
||||
if (std::find(instrumentTypeList.begin(), instrumentTypeList.end(), instrumentType) == instrumentTypeList.end()) {
|
||||
this->onError(Event::Type::SUBSCRIPTION_STATUS, Message::Type::SUBSCRIPTION_FAILURE,
|
||||
"unsupported exchange instrument types: " + toString(instrumentType) + ". Allowed values: " + toString(instrumentTypeList) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
CCAPI_LOGGER_TRACE("subscriptionListByExchangeMap = " + toString(subscriptionListByExchangeMap));
|
||||
for (auto& subscriptionListByExchange : subscriptionListByExchangeMap) {
|
||||
auto exchange = subscriptionListByExchange.first;
|
||||
auto subscriptionList = subscriptionListByExchange.second;
|
||||
std::map<std::string, wspp::lib::shared_ptr<Service> >& serviceByExchangeMap = this->serviceByServiceNameExchangeMap.at(serviceName);
|
||||
std::map<std::string, std::shared_ptr<Service> >& serviceByExchangeMap = this->serviceByServiceNameExchangeMap.at(serviceName);
|
||||
if (serviceByExchangeMap.find(exchange) == serviceByExchangeMap.end()) {
|
||||
this->onError(Event::Type::SUBSCRIPTION_STATUS, Message::Type::SUBSCRIPTION_FAILURE, "please enable exchange: " + exchange);
|
||||
return;
|
||||
@@ -581,7 +706,7 @@ class Session {
|
||||
for (auto& subscriptionListByExchange : subscriptionListByExchangeMap) {
|
||||
auto exchange = subscriptionListByExchange.first;
|
||||
auto subscriptionList = subscriptionListByExchange.second;
|
||||
std::map<std::string, wspp::lib::shared_ptr<Service> >& serviceByExchangeMap = this->serviceByServiceNameExchangeMap.at(serviceName);
|
||||
std::map<std::string, std::shared_ptr<Service> >& serviceByExchangeMap = this->serviceByServiceNameExchangeMap.at(serviceName);
|
||||
if (serviceByExchangeMap.find(exchange) == serviceByExchangeMap.end()) {
|
||||
this->onError(Event::Type::SUBSCRIPTION_STATUS, Message::Type::SUBSCRIPTION_FAILURE, "please enable exchange: " + exchange);
|
||||
return;
|
||||
@@ -600,7 +725,7 @@ class Session {
|
||||
return;
|
||||
}
|
||||
auto exchange = subscription.getExchange();
|
||||
std::map<std::string, wspp::lib::shared_ptr<Service> >& serviceByExchangeMap = this->serviceByServiceNameExchangeMap.at(serviceName);
|
||||
std::map<std::string, std::shared_ptr<Service> >& serviceByExchangeMap = this->serviceByServiceNameExchangeMap.at(serviceName);
|
||||
if (serviceByExchangeMap.find(exchange) == serviceByExchangeMap.end()) {
|
||||
this->onError(Event::Type::FIX_STATUS, Message::Type::FIX_FAILURE, "please enable exchange: " + exchange);
|
||||
return;
|
||||
@@ -623,14 +748,10 @@ class Session {
|
||||
#ifdef CCAPI_USE_SINGLE_THREAD
|
||||
bool shouldContinue = true;
|
||||
try {
|
||||
shouldContinue = this->eventHandler->processEvent(event, this);
|
||||
this->eventHandler->processEvent(event, this);
|
||||
} catch (const std::runtime_error& e) {
|
||||
CCAPI_LOGGER_ERROR(e.what());
|
||||
}
|
||||
if (!shouldContinue) {
|
||||
CCAPI_LOGGER_DEBUG("about to pause the event dispatcher");
|
||||
this->eventDispatcher->pause();
|
||||
}
|
||||
#else
|
||||
this->eventDispatcher->dispatch([that = this, event = std::move(event)] {
|
||||
bool shouldContinue = true;
|
||||
@@ -660,7 +781,7 @@ class Session {
|
||||
this->onError(Event::Type::FIX_STATUS, Message::Type::FIX_FAILURE, "please enable service: " + serviceName + ", and the exchanges that you want");
|
||||
return;
|
||||
}
|
||||
std::map<std::string, wspp::lib::shared_ptr<Service> >& serviceByExchangeMap = this->serviceByServiceNameExchangeMap.at(serviceName);
|
||||
std::map<std::string, std::shared_ptr<Service> >& serviceByExchangeMap = this->serviceByServiceNameExchangeMap.at(serviceName);
|
||||
auto exchange = request.getExchange();
|
||||
if (serviceByExchangeMap.find(exchange) == serviceByExchangeMap.end()) {
|
||||
this->onError(Event::Type::FIX_STATUS, Message::Type::FIX_FAILURE, "please enable exchange: " + exchange);
|
||||
@@ -684,7 +805,7 @@ class Session {
|
||||
this->onError(Event::Type::REQUEST_STATUS, Message::Type::REQUEST_FAILURE, "please enable service: " + serviceName + ", and the exchanges that you want");
|
||||
return;
|
||||
}
|
||||
std::map<std::string, wspp::lib::shared_ptr<Service> >& serviceByExchangeMap = this->serviceByServiceNameExchangeMap.at(serviceName);
|
||||
std::map<std::string, std::shared_ptr<Service> >& serviceByExchangeMap = this->serviceByServiceNameExchangeMap.at(serviceName);
|
||||
auto exchange = request.getExchange();
|
||||
if (serviceByExchangeMap.find(exchange) == serviceByExchangeMap.end()) {
|
||||
this->onError(Event::Type::REQUEST_STATUS, Message::Type::REQUEST_FAILURE, "please enable exchange: " + exchange);
|
||||
@@ -720,7 +841,7 @@ class Session {
|
||||
"please enable service: " + serviceName + ", and the exchanges that you want", eventQueuePtr);
|
||||
return;
|
||||
}
|
||||
std::map<std::string, wspp::lib::shared_ptr<Service> >& serviceByExchangeMap = this->serviceByServiceNameExchangeMap.at(serviceName);
|
||||
std::map<std::string, std::shared_ptr<Service> >& serviceByExchangeMap = this->serviceByServiceNameExchangeMap.at(serviceName);
|
||||
auto exchange = request.getExchange();
|
||||
if (serviceByExchangeMap.find(exchange) == serviceByExchangeMap.end()) {
|
||||
this->onError(Event::Type::REQUEST_STATUS, Message::Type::REQUEST_FAILURE, "please enable exchange: " + exchange, eventQueuePtr);
|
||||
@@ -767,10 +888,17 @@ class Session {
|
||||
#ifndef SWIG
|
||||
virtual void setTimer(const std::string& id, long delayMilliSeconds, std::function<void(const boost::system::error_code&)> errorHandler,
|
||||
std::function<void()> successHandler) {
|
||||
wspp::lib::asio::post(this->serviceContextPtr->tlsClientPtr->get_io_service(), [this, id, delayMilliSeconds, errorHandler, successHandler]() {
|
||||
boost::asio::post(*this->serviceContextPtr->ioContextPtr, [this, id, delayMilliSeconds, errorHandler, successHandler]() {
|
||||
std::shared_ptr<steady_timer> timerPtr(new steady_timer(*this->serviceContextPtr->ioContextPtr, boost::asio::chrono::milliseconds(delayMilliSeconds)));
|
||||
timerPtr->async_wait([this, id, errorHandler, successHandler](const boost::system::error_code& ec) {
|
||||
if (this->eventHandler) {
|
||||
#ifdef CCAPI_USE_SINGLE_THREAD
|
||||
if (ec) {
|
||||
errorHandler(ec);
|
||||
} else {
|
||||
successHandler();
|
||||
}
|
||||
#else
|
||||
this->eventDispatcher->dispatch([ec, errorHandler, successHandler] {
|
||||
if (ec) {
|
||||
errorHandler(ec);
|
||||
@@ -778,6 +906,7 @@ class Session {
|
||||
successHandler();
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
||||
this->delayTimerByIdMap.erase(id);
|
||||
});
|
||||
@@ -785,13 +914,24 @@ class Session {
|
||||
});
|
||||
}
|
||||
virtual void cancelTimer(const std::string& id) {
|
||||
wspp::lib::asio::post(this->serviceContextPtr->tlsClientPtr->get_io_service(), [this, id]() {
|
||||
boost::asio::post(*this->serviceContextPtr->ioContextPtr, [this, id]() {
|
||||
if (this->delayTimerByIdMap.find(id) != this->delayTimerByIdMap.end()) {
|
||||
this->delayTimerByIdMap[id]->cancel();
|
||||
this->delayTimerByIdMap.erase(id);
|
||||
}
|
||||
});
|
||||
}
|
||||
void purgeHttpConnectionPool(const std::string& serviceName = "", const std::string& exchangeName = "") {
|
||||
for (const auto& x : this->serviceByServiceNameExchangeMap) {
|
||||
if (serviceName.empty() || serviceName == x.first) {
|
||||
for (const auto& y : x.second) {
|
||||
if (exchangeName.empty() || exchangeName == y.first) {
|
||||
y.second->purgeHttpConnectionPool();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifndef CCAPI_EXPOSE_INTERNAL
|
||||
|
||||
@@ -800,10 +940,12 @@ class Session {
|
||||
SessionOptions sessionOptions;
|
||||
SessionConfigs sessionConfigs;
|
||||
EventHandler* eventHandler;
|
||||
#ifndef CCAPI_USE_SINGLE_THREAD
|
||||
EventDispatcher* eventDispatcher;
|
||||
bool useInternalEventDispatcher{};
|
||||
wspp::lib::shared_ptr<ServiceContext> serviceContextPtr;
|
||||
std::map<std::string, std::map<std::string, wspp::lib::shared_ptr<Service> > > serviceByServiceNameExchangeMap;
|
||||
#endif
|
||||
std::shared_ptr<ServiceContext> serviceContextPtr;
|
||||
std::map<std::string, std::map<std::string, std::shared_ptr<Service> > > serviceByServiceNameExchangeMap;
|
||||
std::thread t;
|
||||
Queue<Event> eventQueue;
|
||||
std::function<void(Event& event, Queue<Event>* eventQueue)> internalEventHandler;
|
||||
|
||||
Reference in new issue
Block a user