X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=src%2Fcommand_client.cpp;h=0f44203cc734ef6b125e66282898e0768d4b6ef9;hp=376d3f965fd1d44e36c3bd7817a55285505db74b;hb=af84dfb53a739a0c8c343d9172f1847fa908906d;hpb=a64066eb0e456c92c4c06959616443e531d4b39d diff --git a/src/command_client.cpp b/src/command_client.cpp index 376d3f9..0f44203 100644 --- a/src/command_client.cpp +++ b/src/command_client.cpp @@ -51,6 +51,35 @@ command_client::command_client(client_connection& _c, long long _command_timeout read_hello(); } +/** @brief replace the connection currently in use with a new one + + @param _c reference of the new connection + + @note the old connection must still be valid when this method is called, + it can safely be deleted after this method returned + + @note all callbacks registered on the old connection will be copied over + to the new one +*/ +void command_client::replace_connection(client_connection& _c) +{ + // copy all callbacks registered on the old connection + for(callback_event_type e=static_cast(0); + e < __events_end; + e=static_cast(static_cast(e)+1)) + { + list > evcb=c.get_callback_list(e); + + for (list >::iterator i=evcb.begin(); i != evcb.end(); i++) + _c.add_callback(e,*i); + } + + // replace the connection + c=_c; + + read_hello(); +} + std::string command_client::read_packet(const long long &usec_timeout) { string resultpacket;