diff options
author | Frederico Linhares <fred@linhares.blue> | 2025-03-28 14:53:08 -0300 |
---|---|---|
committer | Frederico Linhares <fred@linhares.blue> | 2025-03-28 14:53:08 -0300 |
commit | 76c2fd91a71585bfccf8ae9e30834a37514de24f (patch) | |
tree | e4a717639d6329c2e6638defadef3b62cf522259 /src/blu_cat/net/server/server.hpp | |
parent | 600a4f7586a31990cfdb02ab811768ca6afc909e (diff) |
feat Simplify interface for net connections
Diffstat (limited to 'src/blu_cat/net/server/server.hpp')
-rw-r--r-- | src/blu_cat/net/server/server.hpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/blu_cat/net/server/server.hpp b/src/blu_cat/net/server/server.hpp index 271d75a..00b277f 100644 --- a/src/blu_cat/net/server/server.hpp +++ b/src/blu_cat/net/server/server.hpp @@ -17,9 +17,10 @@ #ifndef BLU_CAT_SERVER_SERVER_H #define BLU_CAT_SERVER_SERVER_H 1 +#include <queue> + #include "../common/connection.hpp" #include "../common/connection_callback.hpp" -#include "../common/tsqueue.hpp" namespace BluCat::NET { @@ -30,9 +31,9 @@ class Server: public ConnectionCallback asio::io_context io_context; std::thread thread_context; asio::ip::tcp::acceptor acceptor; - MessageCallback *(*callback_instantiator)(); + void (*get_new_connection)(std::unique_ptr<Connection> c); - TSQueue<unsigned long> free_connection_slots; + std::queue<unsigned long> free_connection_slots; std::vector<Connection*> connections; void @@ -40,12 +41,10 @@ class Server: public ConnectionCallback public: void - read_messages(); - - void - end_connection(unsigned long index); + disconnect(unsigned long index); - Server(MessageCallback *(*callback_instantiator)(), const uint16_t port); + Server(void (*get_new_connection)(std::unique_ptr<Connection> c), + const uint16_t port); ~Server(); }; |