qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches
accept.h
Go to the documentation of this file.
1
24
25#ifndef QB_IO_ASYNC_PROTOCOL_ACCEPT_H
26#define QB_IO_ASYNC_PROTOCOL_ACCEPT_H
27
28namespace qb::io::protocol {
29
45template <typename _IO_, typename _Socket>
46class accept : public async::AProtocol<_IO_> {
47public:
52 using message = _Socket;
53
57 accept() = delete;
58
63 accept(_IO_ &io) noexcept
65
76 std::size_t
77 getMessageSize() noexcept final {
78 return static_cast<size_t>(this->_io.getAccepted().is_open());
79 }
80
91 void
92 onMessage(std::size_t /*size*/) noexcept final { // size is unused
93 this->_io.on(std::move(this->_io.getAccepted()));
94 }
95
101 void
102 reset() noexcept final {}
103};
104
105} // namespace qb::io::protocol
106
107#endif // QB_IO_ASYNC_PROTOCOL_ACCEPT_H
Abstract base class for I/O-component-aware protocols (CRTP).
Definition protocol.h:146
_IO_ & _io
Reference to the I/O component instance that this protocol is associated with.
Definition protocol.h:166
accept()=delete
Default constructor is deleted as an I/O component reference is required.
typename _Prot::socket_type message
Definition accept.h:52
void reset() noexcept final
Resets the protocol state.
Definition accept.h:102
accept(_IO_ &io) noexcept
Constructor with I/O reference.
Definition accept.h:63
std::size_t getMessageSize() noexcept final
Checks if a new connection is available to be processed.
Definition accept.h:77
void onMessage(std::size_t) noexcept final
Processes a newly accepted connection.
Definition accept.h:92