From 6626a5441b074fa7717189f75108de43296cdfdd Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sun, 6 Jan 2019 23:42:21 +0100 Subject: [PATCH] socket: Remove datapath::error from on_close --- include/isocket.hpp | 2 +- source/windows/socket.cpp | 9 +++++---- source/windows/socket.hpp | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/isocket.hpp b/include/isocket.hpp index 8b6c160..ad385ae 100644 --- a/include/isocket.hpp +++ b/include/isocket.hpp @@ -26,7 +26,7 @@ namespace datapath { public /*events*/: datapath::event&> on_message; - datapath::event on_close; + datapath::event<> on_close; public: virtual bool good() = 0; diff --git a/source/windows/socket.cpp b/source/windows/socket.cpp index 9e7d7ae..5264547 100644 --- a/source/windows/socket.cpp +++ b/source/windows/socket.cpp @@ -40,7 +40,7 @@ void datapath::windows::socket::_connect(HANDLE handle) void datapath::windows::socket::_disconnect() { if (this->on_close) { - this->on_close(datapath::error::Closed); + this->on_close(); } { @@ -127,7 +127,8 @@ void datapath::windows::socket::_watcher() // Read content. 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; waitable = read_header_ov; @@ -192,8 +193,8 @@ datapath::error datapath::windows::socket::write(std::shared_ptr_assign(data, ov); - BOOL suc = - WriteFileEx(socket_handle, obj->data().data(), DWORD(obj->data().size()), ov->get_overlapped(), NULL); + BOOL suc = WriteFileEx(socket_handle, obj->data().data(), DWORD(obj->data().size()), ov->get_overlapped(), + &datapath::windows::utility::def_io_completion_routine); if (suc) { return datapath::error::Success; } else { diff --git a/source/windows/socket.hpp b/source/windows/socket.hpp index 395113d..f7e2a2d 100644 --- a/source/windows/socket.hpp +++ b/source/windows/socket.hpp @@ -32,7 +32,7 @@ extern "C" { namespace datapath { namespace windows { - class socket : public isocket { + class socket : public isocket, public std::enable_shared_from_this { bool is_connected; HANDLE socket_handle;