Files
EVEngine/src/modules/network/Session.cpp
T
西风逍遥游 eada3e1d2c 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.
2026-08-05 14:01:09 +08:00

32 lines
660 B
C++

#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