6 #ifndef KAGOME_CORE_API_TRANSPORT_SESSION_HPP 7 #define KAGOME_CORE_API_TRANSPORT_SESSION_HPP 9 #include <boost/asio/buffer.hpp> 10 #include <boost/asio/ip/tcp.hpp> 11 #include <boost/asio/read_until.hpp> 12 #include <boost/asio/streambuf.hpp> 13 #include <boost/asio/write.hpp> 14 #include <boost/signals2/signal.hpp> 29 using Signal = boost::signals2::signal<T>;
32 std::shared_ptr<Session> session);
37 using Socket = boost::asio::ip::tcp::socket;
40 using Timer = boost::asio::steady_timer;
53 virtual void start() = 0;
55 virtual Socket &socket() = 0;
62 on_request_ = std::move(callback);
70 on_close_ = std::move(handler);
78 std::shared_ptr<Session> session) {
79 on_request_(request, std::move(session));
86 virtual void respond(std::string_view message) = 0;
94 if (
nullptr != on_close_) on_close_(
id, type);
116 #endif // KAGOME_CORE_API_TRANSPORT_SESSION_HPP std::function< OnRequestSignature > on_request_
on request callback
boost::asio::steady_timer Timer
Signal< OnRequestSignature > OnRequest
void connectOnCloseHandler(OnCloseHandler &&handler)
connects on close callback
boost::asio::ip::tcp::socket Socket
boost::signals2::signal< T > Signal
void processRequest(std::string_view request, std::shared_ptr< Session > session)
process request message
void(std::string_view, std::shared_ptr< Session > session) OnRequestSignature
std::function< void(SessionId, SessionType)> OnCloseHandler
Event handlers.
boost::signals2::connection Connection
boost::system::error_code ErrorCode
boost::asio::streambuf Streambuf
void connectOnRequest(std::function< OnRequestSignature > callback)
connects on request callback
void notifyOnClose(SessionId id, SessionType type)
makes on close notification to listener