Upgrade ccapi to v6.12.0
This commit is contained in:
1 parent
8069cc893f
commit
90492733fd
109 files changed
+4172
-8930
No files matched your search
@@ -55,13 +55,13 @@ class ExecutionManagementService : public Service {
|
||||
if (credential.empty()) {
|
||||
credential = that->credentialDefault;
|
||||
}
|
||||
#ifndef CCAPI_USE_BOOST_BEAST_WEBSOCKET
|
||||
#ifdef CCAPI_LEGACY_USE_WEBSOCKETPP
|
||||
WsConnection wsConnection(that->baseUrlWs, "", {subscription}, credential);
|
||||
that->prepareConnect(wsConnection);
|
||||
#else
|
||||
std::shared_ptr<beast::websocket::stream<beast::ssl_stream<beast::tcp_stream>>> streamPtr(nullptr);
|
||||
try {
|
||||
streamPtr = that->createStream<beast::websocket::stream<beast::ssl_stream<beast::tcp_stream>>>(that->serviceContextPtr->ioContextPtr, that->serviceContextPtr->sslContextPtr, that->hostWs);
|
||||
streamPtr = that->createWsStream(that->serviceContextPtr->ioContextPtr, that->serviceContextPtr->sslContextPtr);
|
||||
} catch (const beast::error_code& ec) {
|
||||
CCAPI_LOGGER_TRACE("fail");
|
||||
that->onError(Event::Type::SUBSCRIPTION_STATUS, Message::Type::SUBSCRIPTION_FAILURE, ec, "create stream", {subscription.getCorrelationId()});
|
||||
@@ -115,10 +115,11 @@ class ExecutionManagementService : public Service {
|
||||
Request::Operation operation = request.getOperation();
|
||||
message.setType(this->requestOperationToMessageTypeMap.at(operation));
|
||||
auto castedOperation = static_cast<int>(operation);
|
||||
if (castedOperation >= Request::operationTypeExecutionManagementOrder && castedOperation < Request::operationTypeExecutionManagementAccount) {
|
||||
if (castedOperation >= CCAPI_REQUEST_OPERATION_TYPE_EXECUTION_MANAGEMENT_ORDER &&
|
||||
castedOperation < CCAPI_REQUEST_OPERATION_TYPE_EXECUTION_MANAGEMENT_ACCOUNT) {
|
||||
this->extractOrderInfoFromRequest(elementList, request, operation, document);
|
||||
message.setElementList(elementList);
|
||||
} else if (castedOperation >= Request::operationTypeExecutionManagementAccount) {
|
||||
} else if (castedOperation >= CCAPI_REQUEST_OPERATION_TYPE_EXECUTION_MANAGEMENT_ACCOUNT) {
|
||||
this->extractAccountInfoFromRequest(elementList, request, operation, document);
|
||||
message.setElementList(elementList);
|
||||
}
|
||||
@@ -163,8 +164,8 @@ class ExecutionManagementService : public Service {
|
||||
this->eventHandler(event, eventQueuePtr);
|
||||
}
|
||||
}
|
||||
virtual void extractOrderInfo(Element& element, const rj::Value& x,
|
||||
const std::map<std::string, std::pair<std::string, JsonDataType> >& extractionFieldNameMap) {
|
||||
virtual void extractOrderInfo(Element& element, const rj::Value& x, const std::map<std::string, std::pair<std::string, JsonDataType>>& extractionFieldNameMap,
|
||||
const std::map<std::string, std::function<std::string(const std::string&)>> conversionMap = {}) {
|
||||
for (const auto& y : extractionFieldNameMap) {
|
||||
auto it = x.FindMember(y.second.first.c_str());
|
||||
if (it != x.MemberEnd() && !it->value.IsNull()) {
|
||||
@@ -175,6 +176,10 @@ class ExecutionManagementService : public Service {
|
||||
if (y.first == CCAPI_EM_ORDER_SIDE) {
|
||||
value = UtilString::toLower(value).rfind("buy", 0) == 0 ? CCAPI_EM_ORDER_SIDE_BUY : CCAPI_EM_ORDER_SIDE_SELL;
|
||||
}
|
||||
auto it2 = conversionMap.find(y.first);
|
||||
if (it2 != conversionMap.end()) {
|
||||
value = it2->second(value);
|
||||
}
|
||||
element.insert(y.first, value);
|
||||
}
|
||||
}
|
||||
@@ -185,7 +190,7 @@ class ExecutionManagementService : public Service {
|
||||
auto errorMessage = "Websocket unimplemented operation " + Request::operationToString(request.getOperation()) + " for exchange " + request.getExchange();
|
||||
throw std::runtime_error(errorMessage);
|
||||
}
|
||||
#ifndef CCAPI_USE_BOOST_BEAST_WEBSOCKET
|
||||
#ifdef CCAPI_LEGACY_USE_WEBSOCKETPP
|
||||
virtual void logonToExchange(const WsConnection& wsConnection, const TimePoint& now, const std::map<std::string, std::string>& credential) {
|
||||
CCAPI_LOGGER_INFO("about to logon to exchange");
|
||||
CCAPI_LOGGER_INFO("exchange is " + this->exchangeName);
|
||||
@@ -194,7 +199,7 @@ class ExecutionManagementService : public Service {
|
||||
for (const auto& sendString : sendStringList) {
|
||||
CCAPI_LOGGER_INFO("sendString = " + sendString);
|
||||
ErrorCode ec;
|
||||
#ifndef CCAPI_USE_BOOST_BEAST_WEBSOCKET
|
||||
#ifdef CCAPI_LEGACY_USE_WEBSOCKETPP
|
||||
this->send(wsConnection.hdl, sendString, wspp::frame::opcode::text, ec);
|
||||
#else
|
||||
this->send(wsConnectionPtr, sendString, ec);
|
||||
@@ -208,7 +213,7 @@ class ExecutionManagementService : public Service {
|
||||
WsConnection& wsConnection = this->getWsConnectionFromConnectionPtr(this->serviceContextPtr->tlsClientPtr->get_con_from_hdl(hdl));
|
||||
auto subscription = wsConnection.subscriptionList.at(0);
|
||||
this->onTextMessage(wsConnection, subscription, textMessage, timeReceived);
|
||||
this->onPongByMethod(PingPongMethod::WEBSOCKET_APPLICATION_LEVEL, hdl, textMessage, timeReceived);
|
||||
this->onPongByMethod(PingPongMethod::WEBSOCKET_APPLICATION_LEVEL, hdl, textMessage, timeReceived, false);
|
||||
}
|
||||
void onOpen(wspp::connection_hdl hdl) override {
|
||||
CCAPI_LOGGER_FUNCTION_ENTER;
|
||||
@@ -252,7 +257,7 @@ class ExecutionManagementService : public Service {
|
||||
void onTextMessage(std::shared_ptr<WsConnection> wsConnectionPtr, boost::beast::string_view textMessageView, const TimePoint& timeReceived) override {
|
||||
auto subscription = wsConnectionPtr->subscriptionList.at(0);
|
||||
this->onTextMessage(wsConnectionPtr, subscription, textMessageView, timeReceived);
|
||||
this->onPongByMethod(PingPongMethod::WEBSOCKET_APPLICATION_LEVEL, wsConnectionPtr, timeReceived);
|
||||
this->onPongByMethod(PingPongMethod::WEBSOCKET_APPLICATION_LEVEL, wsConnectionPtr, timeReceived, false);
|
||||
}
|
||||
void onOpen(std::shared_ptr<WsConnection> wsConnectionPtr) override {
|
||||
CCAPI_LOGGER_FUNCTION_ENTER;
|
||||
@@ -329,7 +334,7 @@ class ExecutionManagementService : public Service {
|
||||
that->onError(Event::Type::REQUEST_STATUS, Message::Type::REQUEST_FAILURE, "Websocket connection was not found", {correlationId});
|
||||
return;
|
||||
}
|
||||
#ifndef CCAPI_USE_BOOST_BEAST_WEBSOCKET
|
||||
#ifdef CCAPI_LEGACY_USE_WEBSOCKETPP
|
||||
auto& wsConnection = it->second;
|
||||
#else
|
||||
auto wsConnectionPtr = it->second;
|
||||
@@ -353,7 +358,7 @@ class ExecutionManagementService : public Service {
|
||||
document.Accept(writer);
|
||||
std::string sendString = stringBuffer.GetString();
|
||||
CCAPI_LOGGER_TRACE("sendString = " + sendString);
|
||||
#ifndef CCAPI_USE_BOOST_BEAST_WEBSOCKET
|
||||
#ifdef CCAPI_LEGACY_USE_WEBSOCKETPP
|
||||
that->send(wsConnection.hdl, sendString, wspp::frame::opcode::text, ec);
|
||||
#else
|
||||
that->send(wsConnectionPtr, sendString, ec);
|
||||
@@ -389,10 +394,10 @@ class ExecutionManagementService : public Service {
|
||||
std::string getAccountBalancesTarget;
|
||||
std::string getAccountPositionsTarget;
|
||||
std::map<std::string, std::string> correlationIdByConnectionIdMap;
|
||||
#ifndef CCAPI_USE_BOOST_BEAST_WEBSOCKET
|
||||
#ifdef CCAPI_LEGACY_USE_WEBSOCKETPP
|
||||
std::map<std::string, WsConnection> wsConnectionByCorrelationIdMap;
|
||||
#else
|
||||
std::map<std::string, std::shared_ptr<WsConnection> >
|
||||
std::map<std::string, std::shared_ptr<WsConnection>>
|
||||
wsConnectionByCorrelationIdMap; // TODO(cryptochassis): for consistency, to be renamed to wsConnectionPtrByCorrelationIdMap
|
||||
#endif
|
||||
std::map<std::string, int> wsRequestIdByConnectionIdMap;
|
||||
|
||||
Reference in new issue
Block a user