@@ -135,10 +135,11 @@ class WS_client_connector : public WS_connector {
135135 static Response_handler create_response_handler (ConnectCallback cb, std::string key)
136136 {
137137 // @todo Try replace with unique_ptr
138- // create a new instance of the
139- auto ptr = std::shared_ptr<WS_client_connector>{
140- new WS_client_connector (std::move (cb), std::move (key))
141- };
138+ // create a new instance of a client connector
139+ // auto ptr = std::unique_ptr<WS_client_connector>{
140+ // new WS_client_connector(std::move(cb), std::move(key))
141+ // };
142+ auto ptr = std::make_shared<WS_client_connector>(std::move (cb), std::move (key));
142143
143144 return [ ptr{std::move (ptr)} ]
144145 (auto err, auto res, auto & conn)
@@ -178,15 +179,34 @@ class WS_client_connector : public WS_connector {
178179 on_connect_ (std::move (ws));
179180 }
180181
181- private:
182- std::string key_;
183-
182+ // Either use the ones above, or these below.
183+ /* *
184+ * @brief Constructor to be used when constructing unique instances
185+ * of the client connector.
186+ *
187+ * @param[in] on_connect On connect callback
188+ * @param[in] key The WS key
189+ */
184190 WS_client_connector (ConnectCallback on_connect, std::string key)
185191 : WS_connector(std::move(on_connect)),
186192 key_ (std::move(key))
187193 {
188194 }
189195
196+ /* *
197+ * @brief Creates a response handler based on the key and connect callback
198+ * set in the unique instance of the client connector.
199+ *
200+ * @return Returns a response handler pointing to this object.
201+ */
202+ Response_handler create_response_handler ()
203+ {
204+ return {this , &WS_client_connector::on_response};
205+ }
206+
207+ private:
208+ std::string key_;
209+
190210}; // < WS_client_connector
191211
192212} // < http
0 commit comments