From bb5dfd402fba69590aca7a853d424adb3539a655 Mon Sep 17 00:00:00 2001
From: Benny Baumann <BenBE@geshi.org>
Date: Sat, 2 Jan 2021 20:17:08 +0100
Subject: [PATCH] fix: Callback fixes

---
 src/net/async_server.hpp | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/src/net/async_server.hpp b/src/net/async_server.hpp
index ed56463..8485ee5 100644
--- a/src/net/async_server.hpp
+++ b/src/net/async_server.hpp
@@ -26,10 +26,10 @@ private:
 
 public:
     async_server_socket(auto_fd &&fd) : socket(std::forward(fd)) {
-    	// This constructor got a constructed socket as an argument
-    	// and forwards it to libev
-    	io.set<async_server_socket, &async_server_socket::get_accept_handler()>(this);
-    	io.start(this->socket, ev::READ);
+        // This constructor got a constructed socket as an argument
+        // and forwards it to libev
+        io.set<async_server_socket, &async_server_socket::cb_ev>(this);
+        io.start(this->socket.get(), ev::READ);
     }
     ~async_server_socket() {
         // Remove this socket from libev ...
@@ -43,6 +43,25 @@ public:
     void set_accept_handler(const accept_handler_type &value) {
         on_accept = value;
     }
+
+private:
+    void cb_ev(::ev::io &w, int events)
+    {
+        (void)w;
+
+        if (events & ::ev::READ) {
+            auto ah = this->get_accept_handler();
+            // Handle accepting clients
+        }
+
+        if (events & ::ev::WRITE) {
+            // Handle sending data (none for servers)
+        }
+
+        if (events & ::ev::ERROR) {
+            // Handle error conditions
+        }
+    }
 };
 
 }
-- 
GitLab