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
@@ -1,6 +1,6 @@
|
||||
#ifndef INCLUDE_CCAPI_CPP_CCAPI_WS_CONNECTION_H_
|
||||
#define INCLUDE_CCAPI_CPP_CCAPI_WS_CONNECTION_H_
|
||||
#ifndef CCAPI_USE_BOOST_BEAST_WEBSOCKET
|
||||
#ifdef CCAPI_LEGACY_USE_WEBSOCKETPP
|
||||
#include <string>
|
||||
|
||||
#include "ccapi_cpp/ccapi_logger.h"
|
||||
@@ -91,31 +91,9 @@ class WsConnection CCAPI_FINAL {
|
||||
: url(url), group(group), subscriptionList(subscriptionList), credential(credential), streamPtr(streamPtr) {
|
||||
this->id = this->url + "||" + this->group + "||" + ccapi::toString(this->subscriptionList) + "||" + ccapi::toString(this->credential);
|
||||
this->correlationIdList.reserve(subscriptionList.size());
|
||||
std::transform(subscriptionList.cbegin(), subscriptionList.cend(), this->correlationIdList.begin(),
|
||||
std::transform(subscriptionList.cbegin(), subscriptionList.cend(), std::back_inserter(this->correlationIdList),
|
||||
[](Subscription subscription) { return subscription.getCorrelationId(); });
|
||||
auto splitted1 = UtilString::split(url, "://");
|
||||
auto foundSlash = splitted1.at(1).find_first_of('/');
|
||||
auto foundQuestionMark = splitted1.at(1).find_first_of('?');
|
||||
if (foundSlash == std::string::npos && foundQuestionMark == std::string::npos) {
|
||||
this->path = "/";
|
||||
} else if (foundSlash == std::string::npos && foundQuestionMark != std::string::npos) {
|
||||
this->path = "/" + splitted1.at(1).substr(foundQuestionMark);
|
||||
} else if (foundSlash != std::string::npos && foundQuestionMark == std::string::npos) {
|
||||
this->path = splitted1.at(1).substr(foundSlash);
|
||||
} else {
|
||||
this->path = splitted1.at(1).substr(foundSlash);
|
||||
}
|
||||
auto splitted2 = UtilString::split(UtilString::split(splitted1.at(1), "/").at(0), ":");
|
||||
this->host = splitted2.at(0);
|
||||
if (splitted2.size() == 2) {
|
||||
this->port = splitted2.at(1);
|
||||
} else {
|
||||
if (splitted1.at(0) == "https" || splitted1.at(0) == "wss") {
|
||||
this->port = CCAPI_HTTPS_PORT_DEFAULT;
|
||||
} else {
|
||||
this->port = CCAPI_HTTP_PORT_DEFAULT;
|
||||
}
|
||||
}
|
||||
this->setUrlParts();
|
||||
}
|
||||
WsConnection() {}
|
||||
std::string toString() const {
|
||||
@@ -127,7 +105,10 @@ class WsConnection CCAPI_FINAL {
|
||||
oss << streamPtr;
|
||||
std::string output = "WsConnection [id = " + id + ", url = " + url + ", group = " + group + ", subscriptionList = " + ccapi::toString(subscriptionList) +
|
||||
", credential = " + ccapi::toString(shortCredential) + ", status = " + statusToString(status) +
|
||||
", headers = " + ccapi::toString(headers) + ", streamPtr = " + oss.str() + "]";
|
||||
", headers = " + ccapi::toString(headers) + ", streamPtr = " + oss.str() + ", remoteCloseCode = " + std::to_string(remoteCloseCode) +
|
||||
", remoteCloseReason = " + std::string(remoteCloseReason.reason.c_str()) +
|
||||
", hostHttpHeaderValue = " + ccapi::toString(hostHttpHeaderValue) + ", path = " + ccapi::toString(path) +
|
||||
", host = " + ccapi::toString(host) + ", port = " + ccapi::toString(port) + "]";
|
||||
return output;
|
||||
}
|
||||
enum class Status {
|
||||
@@ -164,8 +145,43 @@ class WsConnection CCAPI_FINAL {
|
||||
}
|
||||
return output;
|
||||
}
|
||||
std::string getUrl() const { return url; }
|
||||
void setUrl(const std::string& url) {
|
||||
this->url = url;
|
||||
this->setUrlParts();
|
||||
}
|
||||
void setUrlParts() {
|
||||
auto splitted1 = UtilString::split(url, "://");
|
||||
if (splitted1.size() >= 2) {
|
||||
auto foundSlash = splitted1.at(1).find_first_of('/');
|
||||
auto foundQuestionMark = splitted1.at(1).find_first_of('?');
|
||||
if (foundSlash == std::string::npos && foundQuestionMark == std::string::npos) {
|
||||
this->path = "/";
|
||||
} else if (foundSlash == std::string::npos && foundQuestionMark != std::string::npos) {
|
||||
this->path = "/" + splitted1.at(1).substr(foundQuestionMark);
|
||||
} else if (foundSlash != std::string::npos && foundQuestionMark == std::string::npos) {
|
||||
this->path = splitted1.at(1).substr(foundSlash);
|
||||
} else {
|
||||
this->path = splitted1.at(1).substr(foundSlash);
|
||||
}
|
||||
auto splitted2 = UtilString::split(UtilString::split(splitted1.at(1), "/").at(0), ":");
|
||||
this->host = splitted2.at(0);
|
||||
if (splitted2.size() == 2) {
|
||||
this->port = splitted2.at(1);
|
||||
} else {
|
||||
if (splitted1.at(0) == "https" || splitted1.at(0) == "wss") {
|
||||
this->port = CCAPI_HTTPS_PORT_DEFAULT;
|
||||
} else {
|
||||
this->port = CCAPI_HTTP_PORT_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void appendUrlPart(const std::string& urlPart) {
|
||||
this->url += urlPart;
|
||||
this->setUrlParts();
|
||||
}
|
||||
std::string id;
|
||||
std::string url;
|
||||
std::string group;
|
||||
std::vector<Subscription> subscriptionList;
|
||||
std::vector<std::string> correlationIdList;
|
||||
@@ -173,12 +189,16 @@ class WsConnection CCAPI_FINAL {
|
||||
std::map<std::string, std::string> headers;
|
||||
std::map<std::string, std::string> credential;
|
||||
std::shared_ptr<beast::websocket::stream<beast::ssl_stream<beast::tcp_stream> > > streamPtr;
|
||||
beast::websocket::close_code remoteCloseCode;
|
||||
beast::websocket::close_reason remoteCloseReason;
|
||||
beast::websocket::close_code remoteCloseCode{};
|
||||
beast::websocket::close_reason remoteCloseReason{};
|
||||
std::string hostHttpHeaderValue;
|
||||
std::string path;
|
||||
std::string host;
|
||||
std::string port;
|
||||
#ifndef CCAPI_EXPOSE_INTERNAL
|
||||
private:
|
||||
#endif
|
||||
std::string url;
|
||||
};
|
||||
} /* namespace ccapi */
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user