Skip to content

Commit ac83fc0

Browse files
Clean duplicated on_handshake method
1 parent d9f4db8 commit ac83fc0

2 files changed

Lines changed: 9 additions & 28 deletions

File tree

src/etp/AbstractClientSessionCRTP.h

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace ETP_NS
5252
}
5353
},
5454
std::bind(
55-
&AbstractClientSessionCRTP::on_handshake,
55+
&ClientSession::on_handshake,
5656
std::static_pointer_cast<AbstractClientSessionCRTP>(shared_from_this()),
5757
std::placeholders::_1));
5858
#else
@@ -74,7 +74,7 @@ namespace ETP_NS
7474
derived().ws().async_handshake(responseType,
7575
etpServerHost + ":" + etpServerPort, etpServerTarget,
7676
std::bind(
77-
&AbstractClientSessionCRTP::on_handshake,
77+
&ClientSession::on_handshake,
7878
std::static_pointer_cast<AbstractClientSessionCRTP>(shared_from_this()),
7979
std::placeholders::_1));
8080
#endif
@@ -109,25 +109,6 @@ namespace ETP_NS
109109
std::placeholders::_2));
110110
}
111111

112-
void on_handshake(boost::system::error_code ec)
113-
{
114-
if (ec) {
115-
std::cerr << "on_handshake : " << ec.message() << std::endl;
116-
std::cerr << "Sometimes some ETP server require a trailing slash at the end of their URL. Did you also check your optional \"data-partition-id\" additional Header Field?" << std::endl;
117-
return;
118-
}
119-
120-
if (!responseType.count(boost::beast::http::field::sec_websocket_protocol) ||
121-
responseType[boost::beast::http::field::sec_websocket_protocol] != "etp12.energistics.org")
122-
std::cerr << "The client MUST specify the Sec-Websocket-Protocol header value of etp12.energistics.org, and the server MUST reply with the same" << std::endl;
123-
124-
successfulConnection = true;
125-
webSocketSessionClosed = false;
126-
127-
send(requestSession, 0, 0x02);
128-
do_read();
129-
}
130-
131112
void setMaxWebSocketMessagePayloadSize(int64_t value) final {
132113
maxWebSocketMessagePayloadSize = value;
133114
derived().ws().read_message_max(value);

src/etp/ssl/HttpsClientSession.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ namespace ETP_NS
118118
tcp::resolver::results_type results)
119119
{
120120
if (ec) {
121-
std::cerr << "resolve : " << ec.message() << std::endl;
121+
std::cerr << "HTTP over SSL resolve : " << ec.message() << std::endl;
122122
return;
123123
}
124124

@@ -141,7 +141,7 @@ namespace ETP_NS
141141
on_connect(boost::system::error_code ec)
142142
{
143143
if (ec) {
144-
std::cerr << "connect : " << ec.message() << std::endl;
144+
std::cerr << "HTTP over SSL connect : " << ec.message() << std::endl;
145145
return;
146146
}
147147

@@ -173,7 +173,7 @@ namespace ETP_NS
173173
boost::ignore_unused(bytes_transferred);
174174

175175
if (ec) {
176-
std::cerr << "Proxy handshake write : " << ec.message() << std::endl;
176+
std::cerr << "HTTP over SSL Proxy handshake write : " << ec.message() << std::endl;
177177
return;
178178
}
179179

@@ -207,7 +207,7 @@ namespace ETP_NS
207207
{
208208
boost::ignore_unused(bytes_transferred);
209209
if (ec) {
210-
std::cerr << "read : " << ec.message() << std::endl;
210+
std::cerr << "HTTP over SSL read : " << ec.message() << std::endl;
211211
return;
212212
}
213213

@@ -224,7 +224,7 @@ namespace ETP_NS
224224
on_handshake(boost::system::error_code ec)
225225
{
226226
if (ec) {
227-
std::cerr << "handshake : " << ec.message() << std::endl;
227+
std::cerr << "HTTP over SSL handshake : " << ec.message() << std::endl;
228228
return;
229229
}
230230

@@ -245,7 +245,7 @@ namespace ETP_NS
245245
boost::ignore_unused(bytes_transferred);
246246

247247
if (ec) {
248-
std::cerr << "write : " << ec.message() << std::endl;
248+
std::cerr << "HTTP over SSL write : " << ec.message() << std::endl;
249249
return;
250250
}
251251

@@ -266,7 +266,7 @@ namespace ETP_NS
266266
boost::ignore_unused(bytes_transferred);
267267

268268
if (ec) {
269-
std::cerr << "read : " << ec.message() << std::endl;
269+
std::cerr << "HTTP over SSL read : " << ec.message() << std::endl;
270270
return;
271271
}
272272

0 commit comments

Comments
 (0)