166 {
167 websocketpp::lib::error_code ec;
168
170
171 if (ec) {
172 std::cout << "> Connect initialization error: " << ec.message() << std::endl;
173 return -1;
174 }
175
176 int new_id = m_next_id++;
177 connection_metadata::ptr metadata_ptr = websocketpp::lib::make_shared<connection_metadata>(new_id, con->get_handle(), uri);
178 m_connection_list[new_id] = metadata_ptr;
179
180 con->set_open_handler(websocketpp::lib::bind(
182 metadata_ptr,
183 &m_endpoint,
184 websocketpp::lib::placeholders::_1
185 ));
186 con->set_fail_handler(websocketpp::lib::bind(
188 metadata_ptr,
189 &m_endpoint,
190 websocketpp::lib::placeholders::_1
191 ));
192 con->set_close_handler(websocketpp::lib::bind(
194 metadata_ptr,
195 &m_endpoint,
196 websocketpp::lib::placeholders::_1
197 ));
198 con->set_message_handler(websocketpp::lib::bind(
200 metadata_ptr,
201 websocketpp::lib::placeholders::_1,
202 websocketpp::lib::placeholders::_2
203 ));
204
206
207 return new_id;
208 }