@@ -11,11 +11,7 @@ WebsocketBase::WebsocketBase() :
11
11
connected_callback (nullptr ),
12
12
closed_callback (nullptr ),
13
13
message_callback (nullptr ),
14
- // reconnect_timer(nullptr),
15
- // connection_attempts(0),
16
- // reconnect_backoff_ms(0),
17
- shutting_down (false )/* ,
18
- reconnecting(false)*/ {
14
+ shutting_down (false ) {
19
15
20
16
set_connection_options_base (connection_options);
21
17
@@ -38,17 +34,11 @@ void WebsocketBase::register_connected_callback(const std::function<void(const i
38
34
this ->connected_callback = callback;
39
35
}
40
36
41
- // void WebsocketBase::register_disconnected_callback(const std::function<void()>& callback) {
42
- // this->disconnected_callback = callback;
43
- // }
44
-
45
- void WebsocketBase::register_closed_callback (
46
- const std::function<void (const WebsocketCloseReason reason)>& callback) {
37
+ void WebsocketBase::register_closed_callback (const std::function<void (const WebsocketCloseReason reason)>& callback) {
47
38
this ->closed_callback = callback;
48
39
}
49
40
50
- void WebsocketBase::register_failed_callback (const std::function<void (const WebsocketCloseReason)> &callback)
51
- {
41
+ void WebsocketBase::register_failed_callback (const std::function<void (const WebsocketCloseReason)>& callback) {
52
42
this ->failed_callback = callback;
53
43
}
54
44
@@ -81,9 +71,6 @@ void WebsocketBase::disconnect(WebsocketCloseReason code) {
81
71
if (code == WebsocketCloseReason::Normal) {
82
72
this ->shutting_down = true ;
83
73
}
84
- // if (this->reconnect_timer) {
85
- // this->reconnect_timer.get()->cancel();
86
- // }
87
74
if (this ->ping_timer ) {
88
75
this ->ping_timer ->stop ();
89
76
}
@@ -119,36 +106,6 @@ void WebsocketBase::log_on_fail(const std::error_code& ec, const boost::system::
119
106
<< " , Transport error category: " << transport_ec.category ().name ();
120
107
}
121
108
122
- // long WebsocketBase::get_reconnect_interval() {
123
-
124
- // // We need to add 1 to the repeat times since the first try is already connection_attempt 1
125
- // if (this->connection_attempts > (this->connection_options.retry_backoff_repeat_times + 1)) {
126
- // return this->reconnect_backoff_ms;
127
- // }
128
-
129
- // std::random_device rd;
130
- // std::mt19937 gen(rd());
131
- // std::uniform_int_distribution<> distr(0, this->connection_options.retry_backoff_random_range_s);
132
-
133
- // int random_number = distr(gen);
134
-
135
- // if (this->connection_attempts == 1) {
136
- // this->reconnect_backoff_ms = (this->connection_options.retry_backoff_wait_minimum_s + random_number) * 1000;
137
- // return this->reconnect_backoff_ms;
138
- // }
139
-
140
- // this->reconnect_backoff_ms = this->reconnect_backoff_ms * 2 + (random_number * 1000);
141
- // return this->reconnect_backoff_ms;
142
- // }
143
-
144
- // void WebsocketBase::cancel_reconnect_timer() {
145
- // std::lock_guard<std::mutex> lk(this->reconnect_mutex);
146
- // if (this->reconnect_timer) {
147
- // this->reconnect_timer.get()->cancel();
148
- // }
149
- // this->reconnect_timer = nullptr;
150
- // }
151
-
152
109
void WebsocketBase::set_websocket_ping_interval (int32_t interval_s) {
153
110
if (this ->ping_timer ) {
154
111
this ->ping_timer ->stop ();
@@ -165,11 +122,6 @@ void WebsocketBase::set_authorization_key(const std::string& authorization_key)
165
122
166
123
void WebsocketBase::on_pong_timeout (websocketpp::connection_hdl hdl, std::string msg) {
167
124
this ->close (WebsocketCloseReason::GoingAway, " Pong timeout" , false );
168
- // if (!this->reconnecting) {
169
- // EVLOG_info << "Reconnecting because of a pong timeout after " << this->connection_options.pong_timeout_s << "s";
170
- // this->reconnecting = true;
171
- // this->close(WebsocketCloseReason::GoingAway, "Pong timeout");
172
- // }
173
125
}
174
126
175
127
} // namespace ocpp
0 commit comments