I have async tcp server, that read async massage from client. I should make some manipulation with massage that I rad and than send answer to client. Manipulations should be asynchronous, and after manipulations will be done, server should send answer to client.
I want to make next:
//...
std::string answer;
boost::asio::io_service &io_service_;
void do_read(){
//async read from client and call on_read()
}
void on_read(std::string msg){
//here I have a problem - I don't know, how to call func() asynchronous
//I want to do something like this:
RunAcync(boost::bind(&CClientSession::func, shared_from_this(), msg)
, boost::bind(&CClientSession::on_func_executed, shared_from_this())
,io_service_ );
do_read();
}
void func(std::string msg) {
//do long work hare with msg
answer = msg;
}
void on_func_executed(){
do_write(answer);
}
void do_write(std::string msg){
//async write to client and call on_write()
}
void on_write(){
do_read();
}
//...
so my func should be executed under the same threads as io_service.
PS:: This is part of classs, that works with client