mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-10 00:52:11 +01:00
Added some notes.
This commit is contained in:
parent
059cae3625
commit
4f39060341
@ -36,6 +36,10 @@
|
|||||||
#include "event_loop.h"
|
#include "event_loop.h"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
// Inherit from socket?
|
||||||
|
// Could be called ServerSocket
|
||||||
|
// New connection callback -> make it a virtual func?
|
||||||
|
|
||||||
using NewConnectionCallback = std::function<void(int fd, const InetAddress &)>;
|
using NewConnectionCallback = std::function<void(int fd, const InetAddress &)>;
|
||||||
class Acceptor {
|
class Acceptor {
|
||||||
protected:
|
protected:
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
class EventLoop;
|
class EventLoop;
|
||||||
/**
|
/**
|
||||||
* @brief This class is used to implement reactor pattern. A Channel object
|
* @brief This class is used to implement reactor pattern. A Channel object
|
||||||
|
@ -35,6 +35,10 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
// inherit from socket?
|
||||||
|
// Could be called ClientSocket
|
||||||
|
// New connection callback -> make it a virtual func?
|
||||||
|
|
||||||
class Connector : public std::enable_shared_from_this<Connector> {
|
class Connector : public std::enable_shared_from_this<Connector> {
|
||||||
protected:
|
protected:
|
||||||
Connector(const Connector &) = delete;
|
Connector(const Connector &) = delete;
|
||||||
|
@ -99,8 +99,7 @@ TcpClient::~TcpClient() {
|
|||||||
loop_->runInLoop([conn, loop]() {
|
loop_->runInLoop([conn, loop]() {
|
||||||
conn->setCloseCallback([loop](const TcpConnectionPtr &connPtr) {
|
conn->setCloseCallback([loop](const TcpConnectionPtr &connPtr) {
|
||||||
loop->queueInLoop([connPtr]() {
|
loop->queueInLoop([connPtr]() {
|
||||||
static_cast<TcpConnectionImpl *>(connPtr.get())
|
static_cast<TcpConnectionImpl *>(connPtr.get())->connectDestroyed();
|
||||||
->connectDestroyed();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -43,6 +43,16 @@ class Connector;
|
|||||||
using ConnectorPtr = std::shared_ptr<Connector>;
|
using ConnectorPtr = std::shared_ptr<Connector>;
|
||||||
class SSLContext;
|
class SSLContext;
|
||||||
|
|
||||||
|
//maybe:
|
||||||
|
//Reference -> Socket -> ConnectionListener (Channel?) -> Connector (ClientSocket) -> TcpClient
|
||||||
|
// -> Acceptor (ServerSocket) -> TcpServer
|
||||||
|
//Reference -> TcpConnection (with a connectionlistener member) -> TcpConnectionDefault
|
||||||
|
//Also todo move around the core net classes a bit more
|
||||||
|
|
||||||
|
|
||||||
|
//should be ConnectionListener derived
|
||||||
|
//Inherit from Connector (which Could be called ClientSocket)?
|
||||||
|
|
||||||
class TcpClient {
|
class TcpClient {
|
||||||
protected:
|
protected:
|
||||||
TcpClient(const TcpClient &) = delete;
|
TcpClient(const TcpClient &) = delete;
|
||||||
|
@ -38,6 +38,10 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
// add new class TcpConnectionListener or ConnectionListener
|
||||||
|
//set_listener(ConnectionListener)
|
||||||
|
// instead of callbacks
|
||||||
|
|
||||||
class SSLContext;
|
class SSLContext;
|
||||||
std::shared_ptr<SSLContext> newSSLServerContext(const std::string &certPath, const std::string &keyPath, bool useOldTLS = false, const std::vector<std::pair<std::string, std::string> > &sslConfCmds = {});
|
std::shared_ptr<SSLContext> newSSLServerContext(const std::string &certPath, const std::string &keyPath, bool useOldTLS = false, const std::vector<std::pair<std::string, std::string> > &sslConfCmds = {});
|
||||||
|
|
||||||
|
@ -44,6 +44,8 @@
|
|||||||
class Acceptor;
|
class Acceptor;
|
||||||
class SSLContext;
|
class SSLContext;
|
||||||
|
|
||||||
|
//Inherit from Acceptor (-> Could be called ServerSocket)?
|
||||||
|
|
||||||
class TcpServer {
|
class TcpServer {
|
||||||
protected:
|
protected:
|
||||||
TcpServer(const TcpServer &) = delete;
|
TcpServer(const TcpServer &) = delete;
|
||||||
@ -125,7 +127,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
EventLoop *loop_;
|
EventLoop *loop_;
|
||||||
std::unique_ptr<Acceptor> acceptorPtr_;
|
std::unique_ptr<Acceptor> acceptorPtr_;
|
||||||
|
|
||||||
void newConnection(int fd, const InetAddress &peer);
|
void newConnection(int fd, const InetAddress &peer);
|
||||||
|
|
||||||
std::string serverName_;
|
std::string serverName_;
|
||||||
std::set<TcpConnectionPtr> connSet_;
|
std::set<TcpConnectionPtr> connSet_;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user