@@ -60,7 +60,7 @@ namespace sio
60
60
sync_close ();
61
61
}
62
62
63
- void client_impl::connect (const std::string& uri)
63
+ void client_impl::connect (const std::string& uri, const std::map<string,string>& query )
64
64
{
65
65
if (m_reconn_timer)
66
66
{
@@ -86,8 +86,18 @@ namespace sio
86
86
m_con_state = con_opening;
87
87
m_base_url = uri;
88
88
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
+
89
99
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 ));
91
101
m_network_thread.reset (new std::thread (lib::bind (&client_impl::run_loop,this )));// uri lifecycle?
92
102
93
103
}
@@ -182,17 +192,18 @@ namespace sio
182
192
" run loop end" );
183
193
}
184
194
185
- void client_impl::connect_impl (const std::string& uri)
195
+ void client_impl::connect_impl (const std::string& uri, const std::string& queryString )
186
196
{
187
197
do {
188
198
websocketpp::uri uo (uri);
189
199
std::ostringstream ss;
200
+
190
201
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 ;
192
203
}
193
204
else
194
205
{
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 ;
196
207
}
197
208
lib::error_code ec;
198
209
client_type::connection_ptr con = m_client.get_connection (ss.str (), ec);
@@ -303,7 +314,7 @@ namespace sio
303
314
this ->reset_states ();
304
315
LOG (" Reconnecting..." <<std::endl);
305
316
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 ));
307
318
}
308
319
}
309
320
0 commit comments