qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches
server.h
Go to the documentation of this file.
1
25
26#ifndef QB_IO_ASYNC_TCP_SERVER_H
27#define QB_IO_ASYNC_TCP_SERVER_H
28
29#include "../io_handler.h"
30#include "acceptor.h"
31
32namespace qb::io::async::tcp {
33
47template <typename _Derived, typename _Session, typename _Prot>
48class server
49 : public acceptor<server<_Derived, _Session, _Prot>, _Prot>
50 , public io_handler<_Derived, _Session> {
52 _Prot>;
53
54public:
58 server() = default;
59
68 void
70 this->registerSession(
71 std::forward<typename acceptor_type::accepted_socket_type>(new_io));
72 }
73
83 void
84 on(event::disconnected &&) {
85 // throw std::runtime_error("Server had been disconnected");
86 }
87};
88
89} // namespace qb::io::async::tcp
90
91#endif // QB_IO_ASYNC_TCP_SERVER_H
Asynchronous TCP connection acceptor implementation.
io_handler()=default
Default constructor.
_Session & registerSession(typename _Session::transport_io_type &&new_io, Args &&...args)
Register a new session.
Definition io_handler.h:138
typename _Prot::socket_type accepted_socket_type
Type of socket created for accepted connections.
Definition acceptor.h:84
void on(typename acceptor_type::accepted_socket_type &&new_io)
Handler for new accepted connections.
Definition server.h:69
void on(event::disconnected &&)
Handler for server disconnection events.
Definition server.h:84
server()=default
Default constructor.
Session management for the asynchronous IO framework.