socket: Remove datapath::error from on_close
This commit is contained in:
+1
-1
@@ -26,7 +26,7 @@ namespace datapath {
|
|||||||
public /*events*/:
|
public /*events*/:
|
||||||
datapath::event<const std::vector<char>&> on_message;
|
datapath::event<const std::vector<char>&> on_message;
|
||||||
|
|
||||||
datapath::event<datapath::error> on_close;
|
datapath::event<> on_close;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool good() = 0;
|
virtual bool good() = 0;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ void datapath::windows::socket::_connect(HANDLE handle)
|
|||||||
void datapath::windows::socket::_disconnect()
|
void datapath::windows::socket::_disconnect()
|
||||||
{
|
{
|
||||||
if (this->on_close) {
|
if (this->on_close) {
|
||||||
this->on_close(datapath::error::Closed);
|
this->on_close();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -127,7 +127,8 @@ void datapath::windows::socket::_watcher()
|
|||||||
|
|
||||||
// Read content.
|
// Read content.
|
||||||
if (ReadFileEx(this->socket_handle, read_buffer.data(), DWORD(read_buffer.size()),
|
if (ReadFileEx(this->socket_handle, read_buffer.data(), DWORD(read_buffer.size()),
|
||||||
read_header_ov->get_overlapped(), NULL)) {
|
read_header_ov->get_overlapped(),
|
||||||
|
&datapath::windows::utility::def_io_completion_routine)) {
|
||||||
state = readstate::Header;
|
state = readstate::Header;
|
||||||
waitable = read_header_ov;
|
waitable = read_header_ov;
|
||||||
|
|
||||||
@@ -192,8 +193,8 @@ datapath::error datapath::windows::socket::write(std::shared_ptr<datapath::itask
|
|||||||
|
|
||||||
obj->_assign(data, ov);
|
obj->_assign(data, ov);
|
||||||
|
|
||||||
BOOL suc =
|
BOOL suc = WriteFileEx(socket_handle, obj->data().data(), DWORD(obj->data().size()), ov->get_overlapped(),
|
||||||
WriteFileEx(socket_handle, obj->data().data(), DWORD(obj->data().size()), ov->get_overlapped(), NULL);
|
&datapath::windows::utility::def_io_completion_routine);
|
||||||
if (suc) {
|
if (suc) {
|
||||||
return datapath::error::Success;
|
return datapath::error::Success;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ extern "C" {
|
|||||||
|
|
||||||
namespace datapath {
|
namespace datapath {
|
||||||
namespace windows {
|
namespace windows {
|
||||||
class socket : public isocket {
|
class socket : public isocket, public std::enable_shared_from_this<datapath::windows::socket> {
|
||||||
bool is_connected;
|
bool is_connected;
|
||||||
HANDLE socket_handle;
|
HANDLE socket_handle;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user