mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
* Added listener and session classes. * Added client session class. * Fixed minor code issues. * Initial server implementation p2p connection * Added a seperate thread to run the two servers * Implemented basic web socket architecture * Implemented basic peer to peer socket network * Added a sample message * Initial socket architecture completed * Improved code readability * Improved comments
37 lines
893 B
C++
37 lines
893 B
C++
#ifndef _SOCK_SERVER_LISTENER_H_
|
|
#define _SOCK_SERVER_LISTENER_H_
|
|
|
|
#include <boost/asio.hpp>
|
|
#include "socket_session_handler.h"
|
|
|
|
namespace net = boost::asio; // namespace asio
|
|
|
|
using tcp = net::ip::tcp;
|
|
using error = boost::system::error_code; // from <boost/system/error_code.hpp>
|
|
|
|
namespace sock
|
|
{
|
|
|
|
/**
|
|
* Represents an active WebSocket server connection
|
|
* Based on the implementation from https://github.com/vinniefalco/CppCon2018
|
|
*/
|
|
class socket_server : public std::enable_shared_from_this<socket_server>
|
|
{
|
|
tcp::acceptor acceptor_;
|
|
tcp::socket socket_;
|
|
socket_session_handler &sess_handler_;
|
|
|
|
void fail(error ec, char const *what);
|
|
|
|
void on_accept(error ec);
|
|
|
|
public:
|
|
socket_server(net::io_context &ioc, tcp::endpoint endpoint, socket_session_handler &session_handler);
|
|
|
|
// Start accepting incoming connections
|
|
void run();
|
|
};
|
|
} // namespace sock
|
|
|
|
#endif |