diff --git a/src/internal/sio_client_impl.cpp b/src/internal/sio_client_impl.cpp index cc025890..c7370541 100644 --- a/src/internal/sio_client_impl.cpp +++ b/src/internal/sio_client_impl.cpp @@ -60,7 +60,7 @@ namespace sio sync_close(); } - void client_impl::connect(const std::string& uri) + void client_impl::connect(const std::string& uri, const std::map& query) { if(m_reconn_timer) { @@ -86,8 +86,18 @@ namespace sio m_con_state = con_opening; m_base_url = uri; m_reconn_made = 0; + + std::string queryString; + for(std::map::const_iterator it=query.begin();it!=query.end();++it){ + queryString.append("&"); + queryString.append(it->first); + queryString.append("="); + queryString.append(it->second); + } + m_query_string=queryString; + this->reset_states(); - m_client.get_io_service().dispatch(lib::bind(&client_impl::connect_impl,this,uri)); + m_client.get_io_service().dispatch(lib::bind(&client_impl::connect_impl,this,uri,queryString)); m_network_thread.reset(new std::thread(lib::bind(&client_impl::run_loop,this)));//uri lifecycle? } @@ -182,17 +192,18 @@ namespace sio "run loop end"); } - void client_impl::connect_impl(const std::string& uri) + void client_impl::connect_impl(const std::string& uri, const std::string& queryString) { do{ websocketpp::uri uo(uri); std::ostringstream ss; + if (m_sid.size()==0) { - ss<<"ws://"<reset_states(); LOG("Reconnecting..."<& queryString); sio::socket::ptr const& socket(const std::string& nsp); @@ -120,7 +120,7 @@ namespace sio private: void run_loop(); - void connect_impl(const std::string& uri); + void connect_impl(const std::string& uri, const std::string& query); void close_impl(close::status::value const& code,std::string const& reason); @@ -165,6 +165,7 @@ namespace sio // Socket.IO server settings std::string m_sid; std::string m_base_url; + std::string m_query_string; unsigned int m_ping_interval; unsigned int m_ping_timeout; diff --git a/src/sio_client.cpp b/src/sio_client.cpp index d1c63692..1c7636a7 100755 --- a/src/sio_client.cpp +++ b/src/sio_client.cpp @@ -67,10 +67,16 @@ namespace sio { m_impl->clear_socket_listeners(); } - + void client::connect(const std::string& uri) { - m_impl->connect(uri); + const std::map query; + m_impl->connect(uri, query); + } + + void client::connect(const std::string& uri, const std::map& query) + { + m_impl->connect(uri, query); } socket::ptr const& client::socket(const std::string& nsp) diff --git a/src/sio_client.h b/src/sio_client.h index 87cd59e3..c752104d 100755 --- a/src/sio_client.h +++ b/src/sio_client.h @@ -56,6 +56,8 @@ namespace sio // Client Functions - such as send, etc. void connect(const std::string& uri); + void connect(const std::string& uri, const std::map& query); + void set_reconnect_attempts(int attempts); void set_reconnect_delay(unsigned millis);