Please sign in to comment.
Separate disconnect from on_connection and also add on_destroy
Break on_connection event into on_connect and on_disconnect events to provide more fine-graine control over the TCPConnection instance. Add on_destroy event on TCPConnection for notifying its owner that the instance is going to destroy; and the owner can now safely get destructed. Different semantics between on_disconnect and on_destroy is simple and clear: on_disconnect event indicates the connection is closed and any further data transmission should be stopped outright and subsequent cleanup could be fulfilled internally; while on_destroy implies that the TCPConnection instance is about to destroy, and you shouldn't perform any operation on it but leave it to destruction. One usage of on_destroy event is how chat-client safelty quits its main loop.
- Loading branch information...
Showing with 152 additions and 68 deletions.
- +5 −5 examples/chat/chat_client.cpp
- +2 −1 examples/chat/chat_server.cpp
- +9 −5 examples/echo/echo_client.cpp
- +3 −3 examples/echo/echo_server.cpp
- +2 −1 ezio/common_event_handlers.h
- +13 −2 ezio/tcp_client.cpp
- +16 −3 ezio/tcp_client.h
- +6 −3 ezio/tcp_connection.cpp
- +15 −3 ezio/tcp_connection.h
- +14 −3 ezio/tcp_server.cpp
- +16 −3 ezio/tcp_server.h
- +35 −28 tests/connector_and_tcpclient.cpp
- +16 −8 tests/tcp_server_and_connection.cpp
Oops, something went wrong.