do_something_to_all(item,[buff,msg_len](echo_client::object_ctype&item2){item2->safe_send_msg(buff,msg_len,false);});//can_overflow is false, it's important
do_something_to_all(item,[&buff,&msg_len](echo_client::object_ctype&item2){item2->safe_send_msg(buff,msg_len,false);});//can_overflow is false, it's important
}
delete[]buff;
});
...
...
@@ -430,7 +430,7 @@ int main(int argc, const char* argv[])
//method #2, add clients first without any arguments, then set the server address.
//functions with a socket_ptr parameter will remove the link from object pool first, then call corresponding function, if you want to reconnect to the server,
//please call socket_ptr's 'disconnect' 'force_shutdown' or 'graceful_shutdown' with true 'reconnect' directly.
virtualvoiduninit(){this->stop();force_shutdown();}//if you wanna graceful shutdown, call graceful_shutdown before service_pump::stop_service invocation.
voidgraceful_shutdown(){this->do_something_to_all([](typenamePool::object_ctype&item){item->graceful_shutdown();});}//parameter sync must be false (the default value), or dead lock will occur.