Skip to content
Snippets Groups Projects
Verified Commit bb5dfd40 authored by Benny Baumann's avatar Benny Baumann
Browse files

fix: Callback fixes

parent efccdb13
No related branches found
No related tags found
No related merge requests found
...@@ -26,10 +26,10 @@ private: ...@@ -26,10 +26,10 @@ private:
public: public:
async_server_socket(auto_fd &&fd) : socket(std::forward(fd)) { async_server_socket(auto_fd &&fd) : socket(std::forward(fd)) {
// This constructor got a constructed socket as an argument // This constructor got a constructed socket as an argument
// and forwards it to libev // and forwards it to libev
io.set<async_server_socket, &async_server_socket::get_accept_handler()>(this); io.set<async_server_socket, &async_server_socket::cb_ev>(this);
io.start(this->socket, ev::READ); io.start(this->socket.get(), ev::READ);
} }
~async_server_socket() { ~async_server_socket() {
// Remove this socket from libev ... // Remove this socket from libev ...
...@@ -43,6 +43,25 @@ public: ...@@ -43,6 +43,25 @@ public:
void set_accept_handler(const accept_handler_type &value) { void set_accept_handler(const accept_handler_type &value) {
on_accept = 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
}
}
}; };
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment