提交 3eb335ad 编写于 作者: Y yang li

Make function tcp::socket_base::reset to be virtual.

上级 6b8936db
......@@ -479,6 +479,7 @@
* ASCS_MAX_SEND_BUF and ASCS_MAX_RECV_BUF, and unit been changed to byte.
* statistic.send_msg_sum may be bigger than before (but statistic.send_byte_sum will be the same), see ENHANCEMENTS section for more details.
* Not support gcc 4.6 any more, please use st_asio_wrapper instead.
* Make function tcp::socket_base::reset to be virtual.
*
* HIGHLIGHT:
* Make client_socket_base be able to call multi_client_base (via i_matrix) like server_socket_base call server_base (via i_server),
......
......@@ -39,11 +39,6 @@ public:
virtual const char* type_name() const {return "TCP (client endpoint)";}
virtual int type_id() const {return 1;}
//reset all, be ensure that there's no any operations performed on this socket when invoke it
//subclass must re-write this function to initialize itself, and then do not forget to invoke superclass' reset function too
//notice, when reusing this socket, object_pool will invoke this function, so if you want to do some additional initialization
// for this socket, do it at here and in the constructor.
//for tcp::single_client_base and ssl::single_client_base, this virtual function will never be called, please note.
virtual void reset() {need_reconnect = ASCS_RECONNECT; super::reset();}
bool set_server_addr(unsigned short port, const std::string& ip = ASCS_SERVER_IP) {return set_addr(server_addr, port, ip);}
......
......@@ -34,11 +34,6 @@ public:
virtual const char* type_name() const {return "TCP (server endpoint)";}
virtual int type_id() const {return 2;}
//reset all, be ensure that there's no any operations performed on this socket when invoke it
//subclass must re-write this function to initialize itself, and then do not forget to invoke superclass' reset function too
//notice, when reusing this socket, object_pool will invoke this function, so if you want to do some additional initialization
// for this socket, do it at here and in the constructor.
virtual void reset() {super::reset();}
virtual void take_over(std::shared_ptr<server_socket_base> socket_ptr) {} //restore this socket from socket_ptr
void disconnect() {force_shutdown();}
......
......@@ -54,8 +54,12 @@ public:
do_direct_send_msg(std::move(msg));
}
//reset all, be ensure that there's no any operations performed on this tcp::socket_base when invoke it
void reset() {status = link_status::BROKEN; last_send_msg.clear(); unpacker_->reset(); super::reset();}
//reset all, be ensure that there's no any operations performed on this socket when invoke it
//subclass must re-write this function to initialize itself, and then do not forget to invoke superclass' reset function too
//notice, when reusing this socket, object_pool will invoke this function, so if you want to do some additional initialization
// for this socket, do it at here and in the constructor.
//for tcp::single_client_base and ssl::single_client_base, this virtual function will never be called, please note.
virtual void reset() {status = link_status::BROKEN; last_send_msg.clear(); unpacker_->reset(); super::reset();}
//SOCKET status
bool is_broken() const {return link_status::BROKEN == status;}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册