feat: implement network module with TCP/UDP support and event handling

Add a new Network module that includes TCP and UDP socket management, HTTP request handling, and session management. Introduce event emission for network events and integrate with the existing event system. Update CMake configurations to include the new module and its dependencies.
This commit is contained in:
西风逍遥游 committed 2026-08-05 14:01:09 +08:00
1 parent ee60344d06
commit eada3e1d2c
22 files changed
+1677 -47

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
#include "network/Session.h"
#include "network/Channel.h"
#include "network/TcpSocket.h"
namespace eve::network {
Session::~Session() {
closeAll();
}
void Session::add(std::string name, Channel* ch) {
channels_[std::move(name)] = ch;
}
Channel* Session::get(std::string name) {
auto it = channels_.find(name);
return it == channels_.end() ? nullptr : it->second;
}
void Session::remove(std::string name) {
channels_.erase(name);
}
void Session::closeAll() {
for (auto& kv : channels_) {
if (kv.second && kv.second->getSocket()) kv.second->getSocket()->close();
}
channels_.clear();
}
} // namespace eve::network