@@ -60,7 +60,7 @@ namespace sio
6060 sync_close ();
6161 }
6262
63- void client_impl::connect (const std::string& uri)
63+ void client_impl::connect (const std::string& uri, const std::map<string,string>& query )
6464 {
6565 if (m_reconn_timer)
6666 {
@@ -86,8 +86,18 @@ namespace sio
8686 m_con_state = con_opening;
8787 m_base_url = uri;
8888 m_reconn_made = 0 ;
89+
90+ std::string queryString;
91+ for (std::map<std::string,std::string>::const_iterator it=query.begin ();it!=query.end ();++it){
92+ queryString.append (" &" );
93+ queryString.append (it->first );
94+ queryString.append (" =" );
95+ queryString.append (it->second );
96+ }
97+ m_query_string=queryString;
98+
8999 this ->reset_states ();
90- m_client.get_io_service ().dispatch (lib::bind (&client_impl::connect_impl,this ,uri));
100+ m_client.get_io_service ().dispatch (lib::bind (&client_impl::connect_impl,this ,uri,queryString ));
91101 m_network_thread.reset (new std::thread (lib::bind (&client_impl::run_loop,this )));// uri lifecycle?
92102
93103 }
@@ -182,17 +192,18 @@ namespace sio
182192 " run loop end" );
183193 }
184194
185- void client_impl::connect_impl (const std::string& uri)
195+ void client_impl::connect_impl (const std::string& uri, const std::string& queryString )
186196 {
187197 do {
188198 websocketpp::uri uo (uri);
189199 std::ostringstream ss;
200+
190201 if (m_sid.size ()==0 ) {
191- ss<<" ws://" <<uo.get_host ()<<" :" <<uo.get_port ()<<" /socket.io/?EIO=4&transport=websocket&t=" <<time (NULL );
202+ ss<<" ws://" <<uo.get_host ()<<" :" <<uo.get_port ()<<" /socket.io/?EIO=4&transport=websocket&t=" <<time (NULL )<<queryString ;
192203 }
193204 else
194205 {
195- ss<<" ws://" <<uo.get_host ()<<" :" <<uo.get_port ()<<" /socket.io/?EIO=4&transport=websocket&sid=" <<m_sid<<" &t=" <<time (NULL );
206+ ss<<" ws://" <<uo.get_host ()<<" :" <<uo.get_port ()<<" /socket.io/?EIO=4&transport=websocket&sid=" <<m_sid<<" &t=" <<time (NULL )<<queryString ;
196207 }
197208 lib::error_code ec;
198209 client_type::connection_ptr con = m_client.get_connection (ss.str (), ec);
@@ -303,7 +314,7 @@ namespace sio
303314 this ->reset_states ();
304315 LOG (" Reconnecting..." <<std::endl);
305316 if (m_reconnecting_listener) m_reconnecting_listener ();
306- m_client.get_io_service ().dispatch (lib::bind (&client_impl::connect_impl,this ,m_base_url));
317+ m_client.get_io_service ().dispatch (lib::bind (&client_impl::connect_impl,this ,m_base_url,m_query_string ));
307318 }
308319 }
309320
0 commit comments